Visit more targets when checking attrs
This commit is contained in:
parent
ea098255f7
commit
396022b90b
@ -54,6 +54,7 @@ pub enum Target {
|
||||
ForeignTy,
|
||||
GenericParam(GenericParamKind),
|
||||
MacroDef,
|
||||
Param,
|
||||
}
|
||||
|
||||
impl Display for Target {
|
||||
@ -96,6 +97,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
GenericParamKind::Const => "const parameter",
|
||||
},
|
||||
Target::MacroDef => "macro def",
|
||||
Target::Param => "function param",
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -1101,17 +1101,6 @@ fn visit_arm(&mut self, arm: &'tcx hir::Arm<'tcx>) {
|
||||
intravisit::walk_arm(self, arm);
|
||||
}
|
||||
|
||||
fn visit_macro_def(&mut self, macro_def: &'tcx hir::MacroDef<'tcx>) {
|
||||
self.check_attributes(
|
||||
macro_def.hir_id,
|
||||
¯o_def.attrs,
|
||||
¯o_def.span,
|
||||
Target::MacroDef,
|
||||
None,
|
||||
);
|
||||
intravisit::walk_macro_def(self, macro_def);
|
||||
}
|
||||
|
||||
fn visit_foreign_item(&mut self, f_item: &'tcx ForeignItem<'tcx>) {
|
||||
let target = Target::from_foreign_item(f_item);
|
||||
self.check_attributes(
|
||||
@ -1157,6 +1146,23 @@ fn visit_variant(
|
||||
self.check_attributes(variant.id, variant.attrs, &variant.span, Target::Variant, None);
|
||||
intravisit::walk_variant(self, variant, generics, item_id)
|
||||
}
|
||||
|
||||
fn visit_macro_def(&mut self, macro_def: &'tcx hir::MacroDef<'tcx>) {
|
||||
self.check_attributes(
|
||||
macro_def.hir_id,
|
||||
macro_def.attrs,
|
||||
¯o_def.span,
|
||||
Target::MacroDef,
|
||||
None,
|
||||
);
|
||||
intravisit::walk_macro_def(self, macro_def);
|
||||
}
|
||||
|
||||
fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) {
|
||||
self.check_attributes(param.hir_id, param.attrs, ¶m.span, Target::Param, None);
|
||||
|
||||
intravisit::walk_param(self, param);
|
||||
}
|
||||
}
|
||||
|
||||
fn is_c_like_enum(item: &Item<'_>) -> bool {
|
||||
|
@ -3,8 +3,8 @@
|
||||
#![feature(decl_macro)] //~ ERROR `feature` is ambiguous
|
||||
|
||||
extern crate builtin_attrs;
|
||||
use builtin_attrs::{test, bench};
|
||||
use builtin_attrs::*;
|
||||
use builtin_attrs::{bench, test};
|
||||
|
||||
#[repr(C)] //~ ERROR `repr` is ambiguous
|
||||
struct S;
|
||||
|
@ -12,7 +12,7 @@ LL | #[repr(C)]
|
||||
|
|
||||
= note: `repr` could refer to a built-in attribute
|
||||
note: `repr` could also refer to the attribute macro imported here
|
||||
--> $DIR/ambiguous-builtin-attrs.rs:7:5
|
||||
--> $DIR/ambiguous-builtin-attrs.rs:6:5
|
||||
|
|
||||
LL | use builtin_attrs::*;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
@ -26,7 +26,7 @@ LL | #[cfg_attr(all(), repr(C))]
|
||||
|
|
||||
= note: `repr` could refer to a built-in attribute
|
||||
note: `repr` could also refer to the attribute macro imported here
|
||||
--> $DIR/ambiguous-builtin-attrs.rs:7:5
|
||||
--> $DIR/ambiguous-builtin-attrs.rs:6:5
|
||||
|
|
||||
LL | use builtin_attrs::*;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
@ -40,7 +40,7 @@ LL | fn non_macro_expanded_location<#[repr(C)] T>() {
|
||||
|
|
||||
= note: `repr` could refer to a built-in attribute
|
||||
note: `repr` could also refer to the attribute macro imported here
|
||||
--> $DIR/ambiguous-builtin-attrs.rs:7:5
|
||||
--> $DIR/ambiguous-builtin-attrs.rs:6:5
|
||||
|
|
||||
LL | use builtin_attrs::*;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
@ -54,7 +54,7 @@ LL | #[repr(C)]
|
||||
|
|
||||
= note: `repr` could refer to a built-in attribute
|
||||
note: `repr` could also refer to the attribute macro imported here
|
||||
--> $DIR/ambiguous-builtin-attrs.rs:7:5
|
||||
--> $DIR/ambiguous-builtin-attrs.rs:6:5
|
||||
|
|
||||
LL | use builtin_attrs::*;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
@ -82,7 +82,7 @@ LL | #![feature(decl_macro)]
|
||||
|
|
||||
= note: `feature` could refer to a built-in attribute
|
||||
note: `feature` could also refer to the attribute macro imported here
|
||||
--> $DIR/ambiguous-builtin-attrs.rs:7:5
|
||||
--> $DIR/ambiguous-builtin-attrs.rs:6:5
|
||||
|
|
||||
LL | use builtin_attrs::*;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
Loading…
Reference in New Issue
Block a user