@@ -47,27 +47,27 @@ struct CheckAttrVisitor<'a> {
47
47
48
48
impl < ' a > CheckAttrVisitor < ' a > {
49
49
/// Check any attribute.
50
- fn check_attribute ( & self , attr : & ast:: Attribute , target : Target ) {
50
+ fn check_attribute ( & self , attr : & ast:: Attribute , item : & ast :: Item , target : Target ) {
51
51
if let Some ( name) = attr. name ( ) {
52
52
match & * name. as_str ( ) {
53
- "inline" => self . check_inline ( attr, target) ,
54
- "repr" => self . check_repr ( attr, target) ,
53
+ "inline" => self . check_inline ( attr, item , target) ,
54
+ "repr" => self . check_repr ( attr, item , target) ,
55
55
_ => ( ) ,
56
56
}
57
57
}
58
58
}
59
59
60
60
/// Check if an `#[inline]` is applied to a function.
61
- fn check_inline ( & self , attr : & ast:: Attribute , target : Target ) {
61
+ fn check_inline ( & self , attr : & ast:: Attribute , item : & ast :: Item , target : Target ) {
62
62
if target != Target :: Fn {
63
63
struct_span_err ! ( self . sess, attr. span, E0518 , "attribute should be applied to function" )
64
- . span_label ( attr . span , "requires a function" )
64
+ . span_label ( item . span , "not a function" )
65
65
. emit ( ) ;
66
66
}
67
67
}
68
68
69
69
/// Check if an `#[repr]` attr is valid.
70
- fn check_repr ( & self , attr : & ast:: Attribute , target : Target ) {
70
+ fn check_repr ( & self , attr : & ast:: Attribute , item : & ast :: Item , target : Target ) {
71
71
let words = match attr. meta_item_list ( ) {
72
72
Some ( words) => words,
73
73
None => {
@@ -139,7 +139,7 @@ impl<'a> CheckAttrVisitor<'a> {
139
139
_ => continue ,
140
140
} ;
141
141
struct_span_err ! ( self . sess, attr. span, E0517 , "{}" , message)
142
- . span_label ( attr . span , format ! ( "requires {}" , label) )
142
+ . span_label ( item . span , format ! ( "not {}" , label) )
143
143
. emit ( ) ;
144
144
}
145
145
if conflicting_reprs > 1 {
@@ -153,7 +153,7 @@ impl<'a> Visitor<'a> for CheckAttrVisitor<'a> {
153
153
fn visit_item ( & mut self , item : & ' a ast:: Item ) {
154
154
let target = Target :: from_item ( item) ;
155
155
for attr in & item. attrs {
156
- self . check_attribute ( attr, target) ;
156
+ self . check_attribute ( attr, item , target) ;
157
157
}
158
158
visit:: walk_item ( self , item) ;
159
159
}
0 commit comments