From 2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:50 +0200 Subject: Merging upstream version 1.69.0+dfsg1. Signed-off-by: Daniel Baumann --- src/tools/rust-analyzer/crates/hir/src/semantics.rs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'src/tools/rust-analyzer/crates/hir/src/semantics.rs') diff --git a/src/tools/rust-analyzer/crates/hir/src/semantics.rs b/src/tools/rust-analyzer/crates/hir/src/semantics.rs index e0d261039..486b7ee62 100644 --- a/src/tools/rust-analyzer/crates/hir/src/semantics.rs +++ b/src/tools/rust-analyzer/crates/hir/src/semantics.rs @@ -1319,10 +1319,7 @@ impl<'db> SemanticsImpl<'db> { let _p = profile::span("Semantics::analyze_impl"); let node = self.find_file(node); - let container = match self.with_ctx(|ctx| ctx.find_container(node)) { - Some(it) => it, - None => return None, - }; + let container = self.with_ctx(|ctx| ctx.find_container(node))?; let resolver = match container { ChildContainer::DefWithBodyId(def) => { @@ -1472,14 +1469,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::::cast) else { return false }; let def = match &enclosing_item { Either::Left(ast::Item::Fn(it)) if it.unsafe_token().is_some() => return true, @@ -1589,7 +1579,7 @@ fn find_root(node: &SyntaxNode) -> SyntaxNode { node.ancestors().last().unwrap() } -/// `SemanticScope` encapsulates the notion of a scope (the set of visible +/// `SemanticsScope` encapsulates the notion of a scope (the set of visible /// names) at a particular program point. /// /// It is a bit tricky, as scopes do not really exist inside the compiler. -- cgit v1.2.3