mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
fix: Diagnose invalid derive attribute input
This commit is contained in:
parent
6757910934
commit
ea03defeac
7 changed files with 100 additions and 24 deletions
|
@ -83,10 +83,11 @@ pub use crate::{
|
|||
attrs::{HasAttrs, Namespace},
|
||||
diagnostics::{
|
||||
AddReferenceHere, AnyDiagnostic, BreakOutsideOfLoop, InactiveCode, IncorrectCase,
|
||||
InvalidDeriveTarget, MacroError, MismatchedArgCount, MissingFields, MissingMatchArms,
|
||||
MissingOkOrSomeInTailExpr, MissingUnsafe, NoSuchField, RemoveThisSemicolon,
|
||||
ReplaceFilterMapNextWithFindMap, UnimplementedBuiltinMacro, UnresolvedExternCrate,
|
||||
UnresolvedImport, UnresolvedMacroCall, UnresolvedModule, UnresolvedProcMacro,
|
||||
InvalidDeriveTarget, MacroError, MalformedDerive, MismatchedArgCount, MissingFields,
|
||||
MissingMatchArms, MissingOkOrSomeInTailExpr, MissingUnsafe, NoSuchField,
|
||||
RemoveThisSemicolon, ReplaceFilterMapNextWithFindMap, UnimplementedBuiltinMacro,
|
||||
UnresolvedExternCrate, UnresolvedImport, UnresolvedMacroCall, UnresolvedModule,
|
||||
UnresolvedProcMacro,
|
||||
},
|
||||
has_source::HasSource,
|
||||
semantics::{PathResolution, Semantics, SemanticsScope, TypeInfo},
|
||||
|
@ -669,6 +670,21 @@ impl Module {
|
|||
None => stdx::never!("derive diagnostic on item without derive attribute"),
|
||||
}
|
||||
}
|
||||
DefDiagnosticKind::MalformedDerive { ast, id } => {
|
||||
let node = ast.to_node(db.upcast());
|
||||
let derive = node.attrs().nth(*id as usize);
|
||||
match derive {
|
||||
Some(derive) => {
|
||||
acc.push(
|
||||
MalformedDerive {
|
||||
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