diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-14 07:36:47 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-14 07:36:47 +0000 |
commit | 8af85263f7cd249356382aa61b98094594165364 (patch) | |
tree | bed1d8bfef7cd3c42917d30fae2d8002dd00c38c /crates/ra_hir_expand/src | |
parent | 38a3c76d154231ded00ca1decfd55bdaebe67bae (diff) | |
parent | da2ca01ebaaaaa47aa09c5848c53b145a68af8fa (diff) |
Merge #2235
2235: Handle macro-generated expressions slightly less wrong r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_expand/src')
-rw-r--r-- | crates/ra_hir_expand/src/lib.rs | 5 |
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)] |
227 | pub struct Source<T> { | 227 | pub 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 | } |