mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
fix: Simplify macro statement expansion handling
This commit is contained in:
parent
f8c416e1b9
commit
531e152390
10 changed files with 155 additions and 110 deletions
|
@ -539,24 +539,26 @@ impl SourceAnalyzer {
|
|||
_ => (),
|
||||
}
|
||||
}
|
||||
let macro_expr = match macro_call
|
||||
.map(|it| it.syntax().parent().and_then(ast::MacroExpr::cast))
|
||||
.transpose()
|
||||
{
|
||||
Some(it) => it,
|
||||
None => return false,
|
||||
};
|
||||
|
||||
if let (Some((def, body, sm)), Some(infer)) = (&self.def, &self.infer) {
|
||||
if let Some(expr_ids) = sm.macro_expansion_expr(macro_call) {
|
||||
if let Some(expanded_expr) = sm.macro_expansion_expr(macro_expr.as_ref()) {
|
||||
let mut is_unsafe = false;
|
||||
for &expr_id in expr_ids {
|
||||
unsafe_expressions(
|
||||
db,
|
||||
infer,
|
||||
*def,
|
||||
body,
|
||||
expr_id,
|
||||
&mut |UnsafeExpr { inside_unsafe_block, .. }| {
|
||||
is_unsafe |= !inside_unsafe_block
|
||||
},
|
||||
);
|
||||
if is_unsafe {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
unsafe_expressions(
|
||||
db,
|
||||
infer,
|
||||
*def,
|
||||
body,
|
||||
expanded_expr,
|
||||
&mut |UnsafeExpr { inside_unsafe_block, .. }| is_unsafe |= !inside_unsafe_block,
|
||||
);
|
||||
return is_unsafe;
|
||||
}
|
||||
}
|
||||
false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue