]> git.lizzy.rs Git - rust.git/blobdiff - crates/ide_db/src/helpers.rs
Merge #10563
[rust.git] / crates / ide_db / src / helpers.rs
index a52c4046bfe38c1fe5763d60b84ff4a9bbff041b..173e55b33f6ac7b6579b96d4a0065639be65740e 100644 (file)
@@ -13,7 +13,7 @@
 use either::Either;
 use hir::{ItemInNs, MacroDef, ModuleDef, Name, Semantics};
 use syntax::{
-    ast::{self, make, LoopBodyOwner},
+    ast::{self, make, HasLoopBody},
     AstNode, Direction, SyntaxElement, SyntaxKind, SyntaxToken, TokenAtOffset, WalkEvent, T,
 };
 
@@ -53,12 +53,9 @@ pub fn try_resolve_derive_input_at(
         .take_while(|tok| tok.kind() != T!['('] && tok.kind() != T![,])
         .collect();
     let path = ast::Path::parse(&tokens.into_iter().rev().join("")).ok()?;
-    match sema.scope(tt.syntax()).speculative_resolve(&path) {
-        Some(hir::PathResolution::Macro(makro)) if makro.kind() == hir::MacroKind::Derive => {
-            Some(makro)
-        }
-        _ => None,
-    }
+    sema.scope(tt.syntax())
+        .speculative_resolve_as_mac(&path)
+        .filter(|mac| mac.kind() == hir::MacroKind::Derive)
 }
 
 /// Picks the token with the highest rank returned by the passed in function.