@@ -880,19 +880,12 @@ impl<'a> Parser<'a> {
880880 } else if self . is_static_global ( ) {
881881 // FOREIGN STATIC ITEM
882882 self . bump ( ) ; // `static`
883- self . parse_item_foreign_static ( ) ?
884- } else if self . token . is_keyword ( kw:: Const ) {
885- // Treat `const` as `static` for error recovery, but don't add it to expected tokens.
886- self . bump ( ) ; // `const`
887- self . struct_span_err ( self . prev_span , "extern items cannot be `const`" )
888- . span_suggestion (
889- self . prev_span ,
890- "try using a static value" ,
891- "static" . to_owned ( ) ,
892- Applicability :: MachineApplicable ,
893- )
894- . emit ( ) ;
895- self . parse_item_foreign_static ( ) ?
883+ let mutbl = self . parse_mutability ( ) ;
884+ let ( ident, ty, expr) = self . parse_item_const_common ( Some ( mutbl) ) ?;
885+ ( ident, ForeignItemKind :: Static ( ty, mutbl, expr) )
886+ } else if self . eat_keyword ( kw:: Const ) {
887+ let ( ident, ty, expr) = self . parse_item_const_common ( None ) ?;
888+ ( ident, ForeignItemKind :: Const ( ty, expr) )
896889 } else if self . isnt_macro_invocation ( ) {
897890 return Err ( self . missing_assoc_item_kind_err ( "extern" , self . prev_span ) ) ;
898891 } else if self . token . is_path_start ( ) {
@@ -906,14 +899,6 @@ impl<'a> Parser<'a> {
906899 Ok ( P ( self . mk_item ( lo, ident, kind, vis, attrs) ) )
907900 }
908901
909- /// Parses a static item from a foreign module.
910- /// Assumes that the `static` keyword is already parsed.
911- fn parse_item_foreign_static ( & mut self ) -> PResult < ' a , ( Ident , ForeignItemKind ) > {
912- let mutbl = self . parse_mutability ( ) ;
913- let ( ident, ty, expr) = self . parse_item_const_common ( Some ( mutbl) ) ?;
914- Ok ( ( ident, ForeignItemKind :: Static ( ty, mutbl, expr) ) )
915- }
916-
917902 /// Parses a type from a foreign module.
918903 fn parse_item_foreign_type ( & mut self ) -> PResult < ' a , ( Ident , ForeignItemKind ) > {
919904 let ( ident, kind) = self . parse_assoc_ty ( ) ?;
0 commit comments