@@ -862,18 +862,6 @@ pub fn find_repr_attrs(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
862
862
if let Some ( items) = attr. meta_item_list ( ) {
863
863
sess. mark_attr_used ( attr) ;
864
864
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
-
877
865
let mut recognised = false ;
878
866
if item. is_word ( ) {
879
867
let hint = match item. name_or_empty ( ) {
@@ -890,23 +878,6 @@ pub fn find_repr_attrs(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
890
878
acc. push ( h) ;
891
879
}
892
880
} 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
-
910
881
let mut literal_error = None ;
911
882
if name == sym:: align {
912
883
recognised = true ;
@@ -966,13 +937,7 @@ pub fn find_repr_attrs(sess: &Session, attr: &Attribute) -> Vec<ReprAttr> {
966
937
}
967
938
if !recognised {
968
939
// 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" ) ;
976
941
}
977
942
}
978
943
}
@@ -1080,3 +1045,16 @@ fn allow_unstable<'a>(
1080
1045
name
1081
1046
} )
1082
1047
}
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