Unnamed repository; edit this file 'description' to name the repository.
fix: ensure that highlight_related works for macro_expr
roife 2024-07-20
parent ae6e8d5 · commit d94dcfa
-rw-r--r--crates/ide/src/goto_definition.rs1
-rw-r--r--crates/ide/src/highlight_related.rs18
2 files changed, 13 insertions, 6 deletions
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs
index 284fd7861d..ed9db32631 100644
--- a/crates/ide/src/goto_definition.rs
+++ b/crates/ide/src/goto_definition.rs
@@ -14,7 +14,6 @@ use ide_db::{
FileId, RootDatabase,
};
use itertools::Itertools;
-use span::FileRange;
use syntax::{
ast::{self, HasLoopBody, Label},
match_ast, AstNode, AstToken,
diff --git a/crates/ide/src/highlight_related.rs b/crates/ide/src/highlight_related.rs
index 065c3f2452..b1efd90d4e 100644
--- a/crates/ide/src/highlight_related.rs
+++ b/crates/ide/src/highlight_related.rs
@@ -575,12 +575,20 @@ impl<'a> WalkExpandedExprCtx<'a> {
}
if let ast::Expr::MacroExpr(expr) = expr {
- if let Some(expanded) = expr
- .macro_call()
- .and_then(|call| self.sema.expand(&call))
- .and_then(ast::MacroStmts::cast)
+ if let Some(expanded) =
+ expr.macro_call().and_then(|call| self.sema.expand(&call))
{
- self.handle_expanded(expanded, cb);
+ match_ast! {
+ match expanded {
+ ast::MacroStmts(it) => {
+ self.handle_expanded(it, cb);
+ },
+ ast::Expr(it) => {
+ self.walk(&it, cb);
+ },
+ _ => {}
+ }
+ }
}
}
}