diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs index 549c5efe7c..38546ead3c 100644 --- a/crates/ide/src/syntax_highlighting.rs +++ b/crates/ide/src/syntax_highlighting.rs @@ -706,8 +706,7 @@ fn highlight_func_by_name_ref( sema: &Semantics, name_ref: &ast::NameRef, ) -> Option { - let parent = name_ref.syntax().parent()?; - let method_call = ast::MethodCallExpr::cast(parent)?; + let method_call = name_ref.syntax().parent().and_then(ast::MethodCallExpr::cast)?; highlight_method_call(sema, &method_call) }