Auto merge of #87296 - Aaron1011:inert-warn, r=petrochenkov
Warn on inert attributes used on bang macro invocation These attributes are currently discarded. This may change in the future (see #63221), but for now, placing inert attributes on a macro invocation does nothing, so we should warn users about it. Technically, it's possible for there to be attribute macro on the same macro invocation (or at a higher scope), which inspects the inert attribute. For example: ```rust #[look_for_inline_attr] #[inline] my_macro!() #[look_for_nested_inline] mod foo { #[inline] my_macro!() } ``` However, this would be a very strange thing to do. Anyone running into this can manually suppress the warning.
This commit is contained in:
commit
18840b0719
7 changed files with 115 additions and 24 deletions
|
@ -734,6 +734,16 @@ pub trait LintContext: Sized {
|
|||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
BuiltinLintDiagnostics::UnusedBuiltinAttribute {
|
||||
attr_name,
|
||||
macro_name,
|
||||
invoc_span
|
||||
} => {
|
||||
db.span_note(
|
||||
invoc_span,
|
||||
&format!("the built-in attribute `{attr_name}` will be ignored, since it's applied to the macro invocation `{macro_name}`")
|
||||
);
|
||||
}
|
||||
}
|
||||
// Rewrap `db`, and pass control to the user.
|
||||
decorate(LintDiagnosticBuilder::new(db));
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#![feature(box_syntax)]
|
||||
#![feature(box_patterns)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(format_args_capture)]
|
||||
#![feature(iter_order_by)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(never_type)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue