diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-26 13:18:03 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-26 13:18:03 +0000 |
commit | 4822d26540a2eb13505604f2285198ff8fb69fbc (patch) | |
tree | 89d0c72996be70f99835f500cec24a8f80165a36 /crates/ra_hir | |
parent | 36dca8de93c07be62724f973aa4c8a045941d218 (diff) | |
parent | 0623164c1d1ec461570c7d3d330d7c90fb00cf6e (diff) |
Merge #2406
2406: Add hygiene information to SourceAnalyzer r=matklad a=edwin0cheng
This should fix https://github.com/rust-analyzer/rust-analyzer/pull/2392#issuecomment-557964686
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 95a94c3f0..82cb66583 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -14,7 +14,8 @@ use hir_def::{ | |||
14 | DefWithBodyId, | 14 | DefWithBodyId, |
15 | }; | 15 | }; |
16 | use hir_expand::{ | 16 | use hir_expand::{ |
17 | name::AsName, AstId, HirFileId, MacroCallId, MacroCallLoc, MacroFileKind, Source, | 17 | hygiene::Hygiene, name::AsName, AstId, HirFileId, MacroCallId, MacroCallLoc, MacroFileKind, |
18 | Source, | ||
18 | }; | 19 | }; |
19 | use ra_syntax::{ | 20 | use ra_syntax::{ |
20 | ast::{self, AstNode}, | 21 | ast::{self, AstNode}, |
@@ -240,10 +241,10 @@ impl SourceAnalyzer { | |||
240 | pub fn resolve_macro_call( | 241 | pub fn resolve_macro_call( |
241 | &self, | 242 | &self, |
242 | db: &impl HirDatabase, | 243 | db: &impl HirDatabase, |
243 | macro_call: &ast::MacroCall, | 244 | macro_call: Source<&ast::MacroCall>, |
244 | ) -> Option<MacroDef> { | 245 | ) -> Option<MacroDef> { |
245 | // This must be a normal source file rather than macro file. | 246 | let hygiene = Hygiene::new(db, macro_call.file_id); |
246 | let path = macro_call.path().and_then(Path::from_ast)?; | 247 | let path = macro_call.value.path().and_then(|ast| Path::from_src(ast, &hygiene))?; |
247 | self.resolver.resolve_path_as_macro(db, &path).map(|it| it.into()) | 248 | self.resolver.resolve_path_as_macro(db, &path).map(|it| it.into()) |
248 | } | 249 | } |
249 | 250 | ||
@@ -445,7 +446,7 @@ impl SourceAnalyzer { | |||
445 | db: &impl HirDatabase, | 446 | db: &impl HirDatabase, |
446 | macro_call: Source<&ast::MacroCall>, | 447 | macro_call: Source<&ast::MacroCall>, |
447 | ) -> Option<Expansion> { | 448 | ) -> Option<Expansion> { |
448 | let def = self.resolve_macro_call(db, macro_call.value)?.id; | 449 | let def = self.resolve_macro_call(db, macro_call)?.id; |
449 | let ast_id = AstId::new( | 450 | let ast_id = AstId::new( |
450 | macro_call.file_id, | 451 | macro_call.file_id, |
451 | db.ast_id_map(macro_call.file_id).ast_id(macro_call.value), | 452 | db.ast_id_map(macro_call.file_id).ast_id(macro_call.value), |