@@ -862,18 +862,6 @@ pub fn find_repr_attrs(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
862862 if let Some ( items) = attr. meta_item_list ( ) {
863863 sess. mark_attr_used ( attr) ;
864864 for item in items {
865- if !item. is_meta_item ( ) {
866- handle_errors (
867- & sess. parse_sess ,
868- item. span ( ) ,
869- AttrError :: UnsupportedLiteral (
870- "meta item in `repr` must be an identifier" ,
871- false ,
872- ) ,
873- ) ;
874- continue ;
875- }
876-
877865 let mut recognised = false ;
878866 if item. is_word ( ) {
879867 let hint = match item. name_or_empty ( ) {
@@ -890,23 +878,6 @@ pub fn find_repr_attrs(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
890878 acc. push ( h) ;
891879 }
892880 } else if let Some ( ( name, value) ) = item. name_value_literal ( ) {
893- let parse_alignment = |node : & ast:: LitKind | -> Result < u32 , & ' static str > {
894- if let ast:: LitKind :: Int ( literal, ast:: LitIntType :: Unsuffixed ) = node {
895- if literal. is_power_of_two ( ) {
896- // rustc_middle::ty::layout::Align restricts align to <= 2^29
897- if * literal <= 1 << 29 {
898- Ok ( * literal as u32 )
899- } else {
900- Err ( "larger than 2^29" )
901- }
902- } else {
903- Err ( "not a power of two" )
904- }
905- } else {
906- Err ( "not an unsuffixed integer" )
907- }
908- } ;
909-
910881 let mut literal_error = None ;
911882 if name == sym:: align {
912883 recognised = true ;
@@ -966,13 +937,7 @@ pub fn find_repr_attrs(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
966937 }
967938 if !recognised {
968939 // Not a word we recognize
969- struct_span_err ! (
970- diagnostic,
971- item. span( ) ,
972- E0552 ,
973- "unrecognized representation hint"
974- )
975- . emit ( ) ;
940+ diagnostic. delay_span_bug ( item. span ( ) , "unrecognized representation hint" ) ;
976941 }
977942 }
978943 }
@@ -1080,3 +1045,16 @@ fn allow_unstable<'a>(
10801045 name
10811046 } )
10821047}
1048+
1049+ pub fn parse_alignment ( node : & ast:: LitKind ) -> Result < u32 , & ' static str > {
1050+ if let ast:: LitKind :: Int ( literal, ast:: LitIntType :: Unsuffixed ) = node {
1051+ if literal. is_power_of_two ( ) {
1052+ // rustc_middle::ty::layout::Align restricts align to <= 2^29
1053+ if * literal <= 1 << 29 { Ok ( * literal as u32 ) } else { Err ( "larger than 2^29" ) }
1054+ } else {
1055+ Err ( "not a power of two" )
1056+ }
1057+ } else {
1058+ Err ( "not an unsuffixed integer" )
1059+ }
1060+ }
0 commit comments