mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
fix: Diagnose using derive
on non-adt items
This commit is contained in:
parent
966cae384f
commit
6757910934
6 changed files with 99 additions and 27 deletions
|
@ -83,10 +83,10 @@ pub use crate::{
|
|||
attrs::{HasAttrs, Namespace},
|
||||
diagnostics::{
|
||||
AddReferenceHere, AnyDiagnostic, BreakOutsideOfLoop, InactiveCode, IncorrectCase,
|
||||
MacroError, MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkOrSomeInTailExpr,
|
||||
MissingUnsafe, NoSuchField, RemoveThisSemicolon, ReplaceFilterMapNextWithFindMap,
|
||||
UnimplementedBuiltinMacro, UnresolvedExternCrate, UnresolvedImport, UnresolvedMacroCall,
|
||||
UnresolvedModule, UnresolvedProcMacro,
|
||||
InvalidDeriveTarget, MacroError, MismatchedArgCount, MissingFields, MissingMatchArms,
|
||||
MissingOkOrSomeInTailExpr, MissingUnsafe, NoSuchField, RemoveThisSemicolon,
|
||||
ReplaceFilterMapNextWithFindMap, UnimplementedBuiltinMacro, UnresolvedExternCrate,
|
||||
UnresolvedImport, UnresolvedMacroCall, UnresolvedModule, UnresolvedProcMacro,
|
||||
},
|
||||
has_source::HasSource,
|
||||
semantics::{PathResolution, Semantics, SemanticsScope, TypeInfo},
|
||||
|
@ -654,6 +654,21 @@ impl Module {
|
|||
.into(),
|
||||
);
|
||||
}
|
||||
DefDiagnosticKind::InvalidDeriveTarget { ast, id } => {
|
||||
let node = ast.to_node(db.upcast());
|
||||
let derive = node.attrs().nth(*id as usize);
|
||||
match derive {
|
||||
Some(derive) => {
|
||||
acc.push(
|
||||
InvalidDeriveTarget {
|
||||
node: ast.with_value(SyntaxNodePtr::from(AstPtr::new(&derive))),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
None => stdx::never!("derive diagnostic on item without derive attribute"),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for decl in self.declarations(db) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue