]> git.lizzy.rs Git - rust.git/blobdiff - crates/ide/src/syntax_highlighting/highlight.rs
internal: Expand the derive attribute into a pseudo expansion
[rust.git] / crates / ide / src / syntax_highlighting / highlight.rs
index c869db3b8b7d74f8a890ae1d8cca50d993f5a67f..85c0c1b286ebb859b08e68ff33ae7ef366442caf 100644 (file)
     Highlight, HlMod, HlTag,
 };
 
-pub(super) fn token(
-    sema: &Semantics<RootDatabase>,
-    krate: Option<hir::Crate>,
-    token: SyntaxToken,
-) -> Option<Highlight> {
+pub(super) fn token(sema: &Semantics<RootDatabase>, token: SyntaxToken) -> Option<Highlight> {
     if let Some(comment) = ast::Comment::cast(token.clone()) {
         let h = HlTag::Comment;
         return Some(match comment.kind().doc {
@@ -39,17 +35,10 @@ pub(super) fn token(
         INT_NUMBER | FLOAT_NUMBER => HlTag::NumericLiteral.into(),
         BYTE => HlTag::ByteLiteral.into(),
         CHAR => HlTag::CharLiteral.into(),
-        IDENT => {
-            let tt = ast::TokenTree::cast(token.parent()?)?;
-            let ident = ast::Ident::cast(token)?;
+        IDENT if token.parent().and_then(ast::TokenTree::cast).is_some() => {
             // from this point on we are inside a token tree, this only happens for identifiers
             // that were not mapped down into macro invocations
-            (|| {
-                let attr = tt.parent_meta()?.parent_attr()?;
-                let res = sema.resolve_derive_ident(&attr, &ident)?;
-                Some(highlight_def(sema, krate, Definition::from(res)))
-            })()
-            .unwrap_or_else(|| HlTag::None.into())
+            HlTag::None.into()
         }
         p if p.is_punct() => punctuation(sema, token, p),
         k if k.is_keyword() => keyword(sema, token, k)?,