diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-20 13:36:19 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-20 13:36:19 +0000 |
commit | 4ef9cab41a9d8a0a9a683c327f022b6ca9524a37 (patch) | |
tree | fc8009de0176c6904c3dd0484775e85592c9464d /crates/ra_ide_api/src/expand.rs | |
parent | b568bcfe6d94d5f4c6cdc012b766473e5b771a26 (diff) | |
parent | 0a9c80053ffcd72d076ca3792bf4a9ddb94eaf95 (diff) |
Merge #2318
2318: Fix panic when use `Expand Macro` on `assert_eq` r=matklad a=edwin0cheng
The cause of this [bug](https://github.com/rust-analyzer/rust-analyzer/pull/2291#issuecomment-555651542) is, when calling `SourceAnalyzer::expand` when an `ast::MacroCall` which is outside of `SourceAnalyzer::node`.
Note that if we use a node in `SourceAnalyzer::new` with a `MacroFile` file id, the resolver inside `SourceAnalyzer` still will not work properly. Another PR will need to fix it.
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/expand.rs')
-rw-r--r-- | crates/ra_ide_api/src/expand.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/crates/ra_ide_api/src/expand.rs b/crates/ra_ide_api/src/expand.rs index 0ad125a9e..2f1abf509 100644 --- a/crates/ra_ide_api/src/expand.rs +++ b/crates/ra_ide_api/src/expand.rs | |||
@@ -55,7 +55,7 @@ pub(crate) fn descend_into_macros( | |||
55 | } | 55 | } |
56 | let source_analyzer = | 56 | let source_analyzer = |
57 | hir::SourceAnalyzer::new(db, token.with_value(token.value.parent()).as_ref(), None); | 57 | hir::SourceAnalyzer::new(db, token.with_value(token.value.parent()).as_ref(), None); |
58 | let exp = source_analyzer.expand(db, ¯o_call)?; | 58 | let exp = source_analyzer.expand(db, token.with_value(¯o_call))?; |
59 | exp.map_token_down(db, token.as_ref()) | 59 | exp.map_token_down(db, token.as_ref()) |
60 | }) | 60 | }) |
61 | .last() | 61 | .last() |