@@ -42,7 +42,9 @@ struct CheckAttrVisitor<'a> {
4242impl < ' a > CheckAttrVisitor < ' a > {
4343 fn check_inline ( & self , attr : & ast:: Attribute , target : Target ) {
4444 if target != Target :: Fn {
45- span_err ! ( self . sess, attr. span, E0518 , "attribute should be applied to function" ) ;
45+ struct_span_err ! ( self . sess, attr. span, E0518 , "attribute should be applied to function" )
46+ . span_label ( attr. span , & format ! ( "requires a function" ) )
47+ . emit ( ) ;
4648 }
4749 }
4850
@@ -56,18 +58,20 @@ impl<'a> CheckAttrVisitor<'a> {
5658
5759 let mut conflicting_reprs = 0 ;
5860 for word in words {
61+
5962 let name = match word. name ( ) {
6063 Some ( word) => word,
6164 None => continue ,
6265 } ;
6366
64- let message = match & * name {
67+ let ( message, label ) = match & * name {
6568 "C" => {
6669 conflicting_reprs += 1 ;
6770 if target != Target :: Struct &&
6871 target != Target :: Union &&
6972 target != Target :: Enum {
70- "attribute should be applied to struct, enum or union"
73+ ( "attribute should be applied to struct, enum or union" ,
74+ "a struct, enum or union" )
7175 } else {
7276 continue
7377 }
@@ -77,15 +81,17 @@ impl<'a> CheckAttrVisitor<'a> {
7781 // can be used to modify another repr hint
7882 if target != Target :: Struct &&
7983 target != Target :: Union {
80- "attribute should be applied to struct or union"
84+ ( "attribute should be applied to struct or union" ,
85+ "a struct or union" )
8186 } else {
8287 continue
8388 }
8489 }
8590 "simd" => {
8691 conflicting_reprs += 1 ;
8792 if target != Target :: Struct {
88- "attribute should be applied to struct"
93+ ( "attribute should be applied to struct" ,
94+ "a struct" )
8995 } else {
9096 continue
9197 }
@@ -95,15 +101,17 @@ impl<'a> CheckAttrVisitor<'a> {
95101 "isize" | "usize" => {
96102 conflicting_reprs += 1 ;
97103 if target != Target :: Enum {
98- "attribute should be applied to enum"
104+ ( "attribute should be applied to enum" ,
105+ "an enum" )
99106 } else {
100107 continue
101108 }
102109 }
103110 _ => continue ,
104111 } ;
105-
106- span_err ! ( self . sess, attr. span, E0517 , "{}" , message) ;
112+ struct_span_err ! ( self . sess, attr. span, E0517 , "{}" , message)
113+ . span_label ( attr. span , & format ! ( "requires {}" , label) )
114+ . emit ( ) ;
107115 }
108116 if conflicting_reprs > 1 {
109117 span_warn ! ( self . sess, attr. span, E0566 ,
0 commit comments