diff --git a/Cargo.lock b/Cargo.lock index 67bfbf0109..4c83000683 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1343,9 +1343,9 @@ checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" [[package]] name = "rowan" -version = "0.15.5" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce1f383129e417a6265b16ed78e6e9307748f0863b2ba75f78ff14717db5b017" +checksum = "e88acf7b001007e9e8c989fe7449f6601d909e5dd2c56399fc158977ad6c56e8" dependencies = [ "countme", "hashbrown", diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs index 984a464ed1..e89f8a5429 100644 --- a/crates/hir/src/source_analyzer.rs +++ b/crates/hir/src/source_analyzer.rs @@ -650,9 +650,7 @@ fn scope_for_offset( .filter_map(|(id, scope)| { let InFile { file_id, value } = source_map.expr_syntax(*id).ok()?; if from_file == file_id { - let root = db.parse_or_expand(file_id)?; - let node = value.to_node(&root); - return Some((node.syntax().text_range(), scope)); + return Some((value.text_range(), scope)); } // FIXME handle attribute expansion diff --git a/crates/syntax/Cargo.toml b/crates/syntax/Cargo.toml index 1ff3170a74..a56c9dec40 100644 --- a/crates/syntax/Cargo.toml +++ b/crates/syntax/Cargo.toml @@ -13,7 +13,7 @@ doctest = false [dependencies] cov-mark = "2.0.0-pre.1" itertools = "0.10.3" -rowan = "0.15.5" +rowan = "0.15.8" rustc_lexer = { version = "725.0.0", package = "rustc-ap-rustc_lexer" } rustc-hash = "1.1.0" once_cell = "1.12.0" diff --git a/crates/syntax/src/ptr.rs b/crates/syntax/src/ptr.rs index bd96e35cc6..a886972fff 100644 --- a/crates/syntax/src/ptr.rs +++ b/crates/syntax/src/ptr.rs @@ -14,6 +14,8 @@ use std::{ marker::PhantomData, }; +use rowan::TextRange; + use crate::{syntax_node::RustLanguage, AstNode, SyntaxNode}; /// A "pointer" to a [`SyntaxNode`], via location in the source code. @@ -60,6 +62,10 @@ impl AstPtr { self.raw.clone() } + pub fn text_range(&self) -> TextRange { + self.raw.text_range() + } + pub fn cast(self) -> Option> { if !U::can_cast(self.raw.kind()) { return None;