mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
implement AstNode
for Either
This commit is contained in:
parent
32be158630
commit
cfc01150bf
2 changed files with 31 additions and 8 deletions
|
@ -1472,14 +1472,7 @@ impl<'db> SemanticsImpl<'db> {
|
|||
}
|
||||
|
||||
fn is_inside_unsafe(&self, expr: &ast::Expr) -> bool {
|
||||
let item_or_variant = |ancestor: SyntaxNode| {
|
||||
if ast::Item::can_cast(ancestor.kind()) {
|
||||
ast::Item::cast(ancestor).map(Either::Left)
|
||||
} else {
|
||||
ast::Variant::cast(ancestor).map(Either::Right)
|
||||
}
|
||||
};
|
||||
let Some(enclosing_item) = expr.syntax().ancestors().find_map(item_or_variant) else { return false };
|
||||
let Some(enclosing_item) = expr.syntax().ancestors().find_map(Either::<ast::Item, ast::Variant>::cast) else { return false };
|
||||
|
||||
let def = match &enclosing_item {
|
||||
Either::Left(ast::Item::Fn(it)) if it.unsafe_token().is_some() => return true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue