aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-11-14 07:30:30 +0000
committerAleksey Kladov <[email protected]>2019-11-14 07:30:30 +0000
commitda2ca01ebaaaaa47aa09c5848c53b145a68af8fa (patch)
treebed1d8bfef7cd3c42917d30fae2d8002dd00c38c /crates/ra_hir_expand
parenta73b7bb3f6af134c781cba1126350749c5a91144 (diff)
Handle macro-generated expressions slightly less wrong
Diffstat (limited to 'crates/ra_hir_expand')
-rw-r--r--crates/ra_hir_expand/src/lib.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs
index c6ffa2c6f..930789b0f 100644
--- a/crates/ra_hir_expand/src/lib.rs
+++ b/crates/ra_hir_expand/src/lib.rs
@@ -223,7 +223,7 @@ impl<N: AstNode> AstId<N> {
223 } 223 }
224} 224}
225 225
226#[derive(Debug, PartialEq, Eq, Clone, Copy)] 226#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
227pub struct Source<T> { 227pub struct Source<T> {
228 pub file_id: HirFileId, 228 pub file_id: HirFileId,
229 pub ast: T, 229 pub ast: T,
@@ -233,6 +233,9 @@ impl<T> Source<T> {
233 pub fn map<F: FnOnce(T) -> U, U>(self, f: F) -> Source<U> { 233 pub fn map<F: FnOnce(T) -> U, U>(self, f: F) -> Source<U> {
234 Source { file_id: self.file_id, ast: f(self.ast) } 234 Source { file_id: self.file_id, ast: f(self.ast) }
235 } 235 }
236 pub fn as_ref(&self) -> Source<&T> {
237 Source { file_id: self.file_id, ast: &self.ast }
238 }
236 pub fn file_syntax(&self, db: &impl db::AstDatabase) -> SyntaxNode { 239 pub fn file_syntax(&self, db: &impl db::AstDatabase) -> SyntaxNode {
237 db.parse_or_expand(self.file_id).expect("source created from invalid file") 240 db.parse_or_expand(self.file_id).expect("source created from invalid file")
238 } 241 }