From 0a38983ee3d4a38a026dfb44ae9cd99f66145d3d Mon Sep 17 00:00:00 2001 From: Gygaxis Vainhardt <44003709+AloeareV@users.noreply.github.com> Date: Wed, 27 Oct 2021 22:24:11 -0300 Subject: [PATCH] Remove three transmutes from helix-core syntax.rs (#923) --- helix-core/src/syntax.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index 281a70f9..f3e3f238 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -437,7 +437,7 @@ impl Syntax { /// Iterate over the highlighted regions for a given slice of source code. pub fn highlight_iter<'a>( - &self, + &'a self, source: RopeSlice<'a>, range: Option>, cancellation_flag: Option<&'a AtomicUsize>, @@ -452,11 +452,10 @@ impl Syntax { let highlighter = &mut ts_parser.borrow_mut(); highlighter.cursors.pop().unwrap_or_else(QueryCursor::new) }); - let tree_ref = unsafe { mem::transmute::<_, &'static Tree>(self.tree()) }; + let tree_ref = self.tree(); let cursor_ref = unsafe { mem::transmute::<_, &'static mut QueryCursor>(&mut cursor) }; - let query_ref = unsafe { mem::transmute::<_, &'static Query>(&self.config.query) }; - let config_ref = - unsafe { mem::transmute::<_, &'static HighlightConfiguration>(self.config.as_ref()) }; + let query_ref = &self.config.query; + let config_ref = self.config.as_ref(); // if reusing cursors & no range this resets to whole range cursor_ref.set_byte_range(range.clone().unwrap_or(0..usize::MAX));