@@ -995,18 +995,7 @@ impl<'a> Parser<'a> {
995
995
/// See `parse_generic_ty_bound` for the complete grammar of trait bound modifiers.
996
996
fn parse_trait_bound_modifiers ( & mut self ) -> PResult < ' a , TraitBoundModifiers > {
997
997
let modifier_lo = self . token . span ;
998
- let constness = if self . eat ( exp ! ( Tilde ) ) {
999
- let tilde = self . prev_token . span ;
1000
- self . expect_keyword ( exp ! ( Const ) ) ?;
1001
- let span = tilde. to ( self . prev_token . span ) ;
1002
- self . psess . gated_spans . gate ( sym:: const_trait_impl, span) ;
1003
- BoundConstness :: Maybe ( span)
1004
- } else if self . eat_keyword ( exp ! ( Const ) ) {
1005
- self . psess . gated_spans . gate ( sym:: const_trait_impl, self . prev_token . span ) ;
1006
- BoundConstness :: Always ( self . prev_token . span )
1007
- } else {
1008
- BoundConstness :: Never
1009
- } ;
998
+ let constness = self . parse_bound_constness ( ) ?;
1010
999
1011
1000
let asyncness = if self . token_uninterpolated_span ( ) . at_least_rust_2018 ( )
1012
1001
&& self . eat_keyword ( exp ! ( Async ) )
@@ -1068,6 +1057,21 @@ impl<'a> Parser<'a> {
1068
1057
Ok ( TraitBoundModifiers { constness, asyncness, polarity } )
1069
1058
}
1070
1059
1060
+ fn parse_bound_constness ( & mut self ) -> PResult < ' a , BoundConstness > {
1061
+ Ok ( if self . eat ( exp ! ( Tilde ) ) {
1062
+ let tilde = self . prev_token . span ;
1063
+ self . expect_keyword ( exp ! ( Const ) ) ?;
1064
+ let span = tilde. to ( self . prev_token . span ) ;
1065
+ self . psess . gated_spans . gate ( sym:: const_trait_impl, span) ;
1066
+ BoundConstness :: Maybe ( span)
1067
+ } else if self . eat_keyword ( exp ! ( Const ) ) {
1068
+ self . psess . gated_spans . gate ( sym:: const_trait_impl, self . prev_token . span ) ;
1069
+ BoundConstness :: Always ( self . prev_token . span )
1070
+ } else {
1071
+ BoundConstness :: Never
1072
+ } )
1073
+ }
1074
+
1071
1075
/// Parses a type bound according to:
1072
1076
/// ```ebnf
1073
1077
/// TY_BOUND = TY_BOUND_NOPAREN | (TY_BOUND_NOPAREN)
0 commit comments