mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
Handle macro-generated expressions slightly less wrong
This commit is contained in:
parent
a73b7bb3f6
commit
da2ca01eba
6 changed files with 62 additions and 48 deletions
|
@ -223,7 +223,7 @@ impl<N: AstNode> AstId<N> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
|
||||
pub struct Source<T> {
|
||||
pub file_id: HirFileId,
|
||||
pub ast: T,
|
||||
|
@ -233,6 +233,9 @@ impl<T> Source<T> {
|
|||
pub fn map<F: FnOnce(T) -> U, U>(self, f: F) -> Source<U> {
|
||||
Source { file_id: self.file_id, ast: f(self.ast) }
|
||||
}
|
||||
pub fn as_ref(&self) -> Source<&T> {
|
||||
Source { file_id: self.file_id, ast: &self.ast }
|
||||
}
|
||||
pub fn file_syntax(&self, db: &impl db::AstDatabase) -> SyntaxNode {
|
||||
db.parse_or_expand(self.file_id).expect("source created from invalid file")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue