@@ -56,18 +56,21 @@ impl<'a> CheckAttrVisitor<'a> {
56
56
57
57
let mut conflicting_reprs = 0 ;
58
58
for word in words {
59
+
59
60
let name = match word. name ( ) {
60
61
Some ( word) => word,
61
62
None => continue ,
62
63
} ;
63
64
64
- let message = match & * name {
65
+ let word: & str = & word. name ( ) ;
66
+ let ( message, label) = match word {
65
67
"C" => {
66
68
conflicting_reprs += 1 ;
67
69
if target != Target :: Struct &&
68
70
target != Target :: Union &&
69
71
target != Target :: Enum {
70
- "attribute should be applied to struct, enum or union"
72
+ ( "attribute should be applied to struct, enum or union" ,
73
+ "a struct, enum or union" )
71
74
} else {
72
75
continue
73
76
}
@@ -85,7 +88,8 @@ impl<'a> CheckAttrVisitor<'a> {
85
88
"simd" => {
86
89
conflicting_reprs += 1 ;
87
90
if target != Target :: Struct {
88
- "attribute should be applied to struct"
91
+ ( "attribute should be applied to struct" ,
92
+ "a struct" )
89
93
} else {
90
94
continue
91
95
}
@@ -95,15 +99,17 @@ impl<'a> CheckAttrVisitor<'a> {
95
99
"isize" | "usize" => {
96
100
conflicting_reprs += 1 ;
97
101
if target != Target :: Enum {
98
- "attribute should be applied to enum"
102
+ ( "attribute should be applied to enum" ,
103
+ "an enum" )
99
104
} else {
100
105
continue
101
106
}
102
107
}
103
108
_ => continue ,
104
109
} ;
105
-
106
- span_err ! ( self . sess, attr. span, E0517 , "{}" , message) ;
110
+ struct_span_err ! ( self . sess, attr. span, E0517 , "{}" , message)
111
+ . span_label ( attr. span , & format ! ( "requires {}" , label) )
112
+ . emit ( ) ;
107
113
}
108
114
if conflicting_reprs > 1 {
109
115
span_warn ! ( self . sess, attr. span, E0566 ,
0 commit comments