From 38af99f05f76dfcdb36e5b498a64b8c39b2fa27a Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sun, 17 Mar 2024 09:42:16 -0400 Subject: [PATCH] Bump tree-sitter to 0.22.2 --- Cargo.lock | 5 +++-- Cargo.toml | 2 +- helix-core/src/syntax.rs | 20 +++++++------------- xtask/src/querycheck.rs | 2 +- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7b73b1b1a..0a17dec8f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2404,8 +2404,9 @@ dependencies = [ [[package]] name = "tree-sitter" -version = "0.20.10" -source = "git+https://github.com/helix-editor/tree-sitter?rev=660481dbf71413eba5a928b0b0ab8da50c1109e0#660481dbf71413eba5a928b0b0ab8da50c1109e0" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdb9c9f15eae91dcd00ee0d86a281d16e6263786991b662b34fa9632c21a046b" dependencies = [ "cc", "regex", diff --git a/Cargo.toml b/Cargo.toml index 91f6e7cae..e56aedc8f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ package.helix-tui.opt-level = 2 package.helix-term.opt-level = 2 [workspace.dependencies] -tree-sitter = { version = "0.20", git = "https://github.com/helix-editor/tree-sitter", rev = "660481dbf71413eba5a928b0b0ab8da50c1109e0" } +tree-sitter = { version = "0.22" } nucleo = "0.2.0" [workspace.package] diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index 3b224e1b2..0e8917191 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -21,7 +21,7 @@ collections::{HashMap, HashSet, VecDeque}, fmt::{self, Display}, hash::{Hash, Hasher}, - mem::{replace, transmute}, + mem::replace, path::{Path, PathBuf}, str::FromStr, sync::Arc, @@ -805,7 +805,7 @@ fn load_query(&self, kind: &str) -> Option { if query_text.is_empty() { return None; } - let lang = self.highlight_config.get()?.as_ref()?.language; + let lang = &self.highlight_config.get()?.as_ref()?.language; Query::new(lang, &query_text) .map_err(|e| { log::error!( @@ -1544,13 +1544,7 @@ fn eq(&self, other: &Self) -> bool { impl Hash for LanguageLayer { fn hash(&self, state: &mut H) { self.depth.hash(state); - // The transmute is necessary here because tree_sitter::Language does not derive Hash at the moment. - // However it does use #[repr] transparent so the transmute here is safe - // as `Language` (which `Grammar` is an alias for) is just a newtype wrapper around a (thin) pointer. - // This is also compatible with the PartialEq implementation of language - // as that is just a pointer comparison. - let language: *const () = unsafe { transmute(self.config.language) }; - language.hash(state); + self.config.language.hash(state); self.ranges.hash(state); } } @@ -1567,7 +1561,7 @@ fn parse(&mut self, parser: &mut Parser, source: RopeSlice) -> Result<(), Error> .map_err(|_| Error::InvalidRanges)?; parser - .set_language(self.config.language) + .set_language(&self.config.language) .map_err(|_| Error::InvalidLanguage)?; // unsafe { syntax.parser.set_cancellation_flag(cancellation_flag) }; @@ -1867,7 +1861,7 @@ pub fn new( // Construct a single query by concatenating the three query strings, but record the // range of pattern indices that belong to each individual string. - let query = Query::new(language, &query_source)?; + let query = Query::new(&language, &query_source)?; let mut highlights_pattern_index = 0; for i in 0..(query.pattern_count()) { let pattern_offset = query.start_byte_for_pattern(i); @@ -1876,7 +1870,7 @@ pub fn new( } } - let injections_query = Query::new(language, injection_query)?; + let injections_query = Query::new(&language, injection_query)?; let combined_injections_patterns = (0..injections_query.pattern_count()) .filter(|&i| { injections_query @@ -2730,7 +2724,7 @@ fn test_textobject_queries() { .unwrap(); let language = get_language("rust").unwrap(); - let query = Query::new(language, query_str).unwrap(); + let query = Query::new(&language, query_str).unwrap(); let textobject = TextObjectQuery { query }; let mut cursor = QueryCursor::new(); diff --git a/xtask/src/querycheck.rs b/xtask/src/querycheck.rs index 454d0e5cd..a27f85e63 100644 --- a/xtask/src/querycheck.rs +++ b/xtask/src/querycheck.rs @@ -21,7 +21,7 @@ pub fn query_check() -> Result<(), DynError> { let query_text = read_query(language_name, query_file); if let Ok(lang) = language { if !query_text.is_empty() { - if let Err(reason) = Query::new(lang, &query_text) { + if let Err(reason) = Query::new(&lang, &query_text) { return Err(format!( "Failed to parse {} queries for {}: {}", query_file, language_name, reason