@@ -52,6 +52,7 @@ impl<'a> CheckAttrVisitor<'a> {
5252 }
5353 } ;
5454
55+ let mut conflicting_reprs = 0 ;
5556 for word in words {
5657 let name = match word. name ( ) {
5758 Some ( word) => word,
@@ -60,13 +61,24 @@ impl<'a> CheckAttrVisitor<'a> {
6061
6162 let message = match & * name {
6263 "C" => {
64+ conflicting_reprs += 1 ;
6365 if target != Target :: Struct && target != Target :: Enum {
6466 "attribute should be applied to struct or enum"
6567 } else {
6668 continue
6769 }
6870 }
69- "packed" | "simd" => {
71+ "packed" => {
72+ // Do not increment conflicting_reprs here, because "packed"
73+ // can be used to modify another repr hint
74+ if target != Target :: Struct {
75+ "attribute should be applied to struct"
76+ } else {
77+ continue
78+ }
79+ }
80+ "simd" => {
81+ conflicting_reprs += 1 ;
7082 if target != Target :: Struct {
7183 "attribute should be applied to struct"
7284 } else {
@@ -76,6 +88,7 @@ impl<'a> CheckAttrVisitor<'a> {
7688 "i8" | "u8" | "i16" | "u16" |
7789 "i32" | "u32" | "i64" | "u64" |
7890 "isize" | "usize" => {
91+ conflicting_reprs += 1 ;
7992 if target != Target :: Enum {
8093 "attribute should be applied to enum"
8194 } else {
@@ -87,6 +100,10 @@ impl<'a> CheckAttrVisitor<'a> {
87100
88101 span_err ! ( self . sess, attr. span, E0517 , "{}" , message) ;
89102 }
103+ if conflicting_reprs > 1 {
104+ span_warn ! ( self . sess, attr. span, E0566 ,
105+ "conflicting representation hints" ) ;
106+ }
90107 }
91108
92109 fn check_attribute ( & self , attr : & ast:: Attribute , target : Target ) {
0 commit comments