@@ -6,7 +6,7 @@ use crate::syntax::report::Errors;
66use crate :: syntax:: repr:: Repr ;
77use crate :: syntax:: Atom :: * ;
88use crate :: syntax:: {
9- attrs, error, Alignment , Api , Array , Derive , Doc , Enum , EnumRepr , ExternFn , ExternType , FnKind ,
9+ attrs, error, Api , Array , Derive , Doc , Enum , EnumRepr , ExternFn , ExternType , FnKind ,
1010 ForeignName , Impl , Include , IncludeKind , Lang , Lifetimes , NamedType , Namespace , Pair , Ptr ,
1111 Receiver , Ref , Signature , SliceRef , Struct , Ty1 , Type , TypeAlias , Var , Variant ,
1212} ;
@@ -79,10 +79,13 @@ fn parse_struct(cx: &mut Errors, mut item: ItemStruct, namespace: &Namespace) ->
7979 } ,
8080 ) ;
8181
82- let alignment = if let Some ( Repr :: Align ( x) ) = repr {
83- Some ( Alignment :: Align ( x) )
84- } else {
85- None
82+ let align = match repr {
83+ Some ( Repr :: Align ( align) ) => Some ( align) ,
84+ Some ( Repr :: Atom ( _atom, span) ) => {
85+ cx. push ( Error :: new ( span, "unsupported alignment on a struct" ) ) ;
86+ None
87+ }
88+ None => None ,
8689 } ;
8790
8891 let named_fields = match item. fields {
@@ -186,7 +189,7 @@ fn parse_struct(cx: &mut Errors, mut item: ItemStruct, namespace: &Namespace) ->
186189 cfg,
187190 doc,
188191 derives,
189- alignment ,
192+ align ,
190193 attrs,
191194 visibility,
192195 struct_token,
@@ -207,7 +210,7 @@ fn parse_enum(cx: &mut Errors, item: ItemEnum, namespace: &Namespace) -> Api {
207210 let mut rust_name = None ;
208211 let attrs = attrs:: parse (
209212 cx,
210- item. attrs . clone ( ) ,
213+ item. attrs ,
211214 attrs:: Parser {
212215 cfg : Some ( & mut cfg) ,
213216 doc : Some ( & mut doc) ,
@@ -232,9 +235,9 @@ fn parse_enum(cx: &mut Errors, item: ItemEnum, namespace: &Namespace) -> Api {
232235 }
233236
234237 let repr = match repr {
235- Some ( Repr :: Atom ( atom) ) => Some ( atom) ,
236- Some ( Repr :: Align ( _ ) ) => {
237- cx. error ( & item , "repr(align) on enums is not supported " ) ;
238+ Some ( Repr :: Atom ( atom, _span ) ) => Some ( atom) ,
239+ Some ( Repr :: Align ( align ) ) => {
240+ cx. error ( align , "C++ does not support custom alignment on an enum " ) ;
238241 None
239242 }
240243 None => None ,
0 commit comments