@@ -985,18 +985,7 @@ impl<'a> Parser<'a> {
985
985
/// See `parse_generic_ty_bound` for the complete grammar of trait bound modifiers.
986
986
fn parse_trait_bound_modifiers ( & mut self ) -> PResult < ' a , TraitBoundModifiers > {
987
987
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 ( ) ?;
1000
989
1001
990
let asyncness = if self . token_uninterpolated_span ( ) . at_least_rust_2018 ( )
1002
991
&& self . eat_keyword ( exp ! ( Async ) )
@@ -1058,6 +1047,21 @@ impl<'a> Parser<'a> {
1058
1047
Ok ( TraitBoundModifiers { constness, asyncness, polarity } )
1059
1048
}
1060
1049
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
+
1061
1065
/// Parses a type bound according to:
1062
1066
/// ```ebnf
1063
1067
/// TY_BOUND = TY_BOUND_NOPAREN | (TY_BOUND_NOPAREN)
0 commit comments