@@ -47,27 +47,27 @@ struct CheckAttrVisitor<'a> {
4747
4848impl < ' a > CheckAttrVisitor < ' a > {
4949 /// 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 ) {
5151 if let Some ( name) = attr. name ( ) {
5252 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) ,
5555 _ => ( ) ,
5656 }
5757 }
5858 }
5959
6060 /// 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 ) {
6262 if target != Target :: Fn {
6363 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" )
6565 . emit ( ) ;
6666 }
6767 }
6868
6969 /// 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 ) {
7171 let words = match attr. meta_item_list ( ) {
7272 Some ( words) => words,
7373 None => {
@@ -139,7 +139,7 @@ impl<'a> CheckAttrVisitor<'a> {
139139 _ => continue ,
140140 } ;
141141 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) )
143143 . emit ( ) ;
144144 }
145145 if conflicting_reprs > 1 {
@@ -153,7 +153,7 @@ impl<'a> Visitor<'a> for CheckAttrVisitor<'a> {
153153 fn visit_item ( & mut self , item : & ' a ast:: Item ) {
154154 let target = Target :: from_item ( item) ;
155155 for attr in & item. attrs {
156- self . check_attribute ( attr, target) ;
156+ self . check_attribute ( attr, item , target) ;
157157 }
158158 visit:: walk_item ( self , item) ;
159159 }
0 commit comments