@@ -985,18 +985,7 @@ impl<'a> Parser<'a> {
985985 /// See `parse_generic_ty_bound` for the complete grammar of trait bound modifiers.
986986 fn parse_trait_bound_modifiers ( & mut self ) -> PResult < ' a , TraitBoundModifiers > {
987987 let modifier_lo = self . token . span ;
988- let constness = if self . eat ( exp ! ( Tilde ) ) {
989- let tilde = self . prev_token . span ;
990- self . expect_keyword ( exp ! ( Const ) ) ?;
991- let span = tilde. to ( self . prev_token . span ) ;
992- self . psess . gated_spans . gate ( sym:: const_trait_impl, span) ;
993- BoundConstness :: Maybe ( span)
994- } else if self . eat_keyword ( exp ! ( Const ) ) {
995- self . psess . gated_spans . gate ( sym:: const_trait_impl, self . prev_token . span ) ;
996- BoundConstness :: Always ( self . prev_token . span )
997- } else {
998- BoundConstness :: Never
999- } ;
988+ let constness = self . parse_bound_constness ( ) ?;
1000989
1001990 let asyncness = if self . token_uninterpolated_span ( ) . at_least_rust_2018 ( )
1002991 && self . eat_keyword ( exp ! ( Async ) )
@@ -1058,6 +1047,21 @@ impl<'a> Parser<'a> {
10581047 Ok ( TraitBoundModifiers { constness, asyncness, polarity } )
10591048 }
10601049
1050+ fn parse_bound_constness ( & mut self ) -> PResult < ' a , BoundConstness > {
1051+ Ok ( if self . eat ( exp ! ( Tilde ) ) {
1052+ let tilde = self . prev_token . span ;
1053+ self . expect_keyword ( exp ! ( Const ) ) ?;
1054+ let span = tilde. to ( self . prev_token . span ) ;
1055+ self . psess . gated_spans . gate ( sym:: const_trait_impl, span) ;
1056+ BoundConstness :: Maybe ( span)
1057+ } else if self . eat_keyword ( exp ! ( Const ) ) {
1058+ self . psess . gated_spans . gate ( sym:: const_trait_impl, self . prev_token . span ) ;
1059+ BoundConstness :: Always ( self . prev_token . span )
1060+ } else {
1061+ BoundConstness :: Never
1062+ } )
1063+ }
1064+
10611065 /// Parses a type bound according to:
10621066 /// ```ebnf
10631067 /// TY_BOUND = TY_BOUND_NOPAREN | (TY_BOUND_NOPAREN)
0 commit comments