summaryrefslogtreecommitdiffstats
path: root/src/tools/rust-analyzer/crates/hir/src/semantics.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/rust-analyzer/crates/hir/src/semantics.rs')
-rw-r--r--src/tools/rust-analyzer/crates/hir/src/semantics.rs16
1 files changed, 3 insertions, 13 deletions
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::<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,
@@ -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.