@@ -1036,18 +1036,7 @@ impl<'a> Parser<'a> {
1036
1036
/// See `parse_generic_ty_bound` for the complete grammar of trait bound modifiers.
1037
1037
fn parse_trait_bound_modifiers ( & mut self ) -> PResult < ' a , TraitBoundModifiers > {
1038
1038
let modifier_lo = self . token . span ;
1039
- let constness = if self . eat ( exp ! ( Tilde ) ) {
1040
- let tilde = self . prev_token . span ;
1041
- self . expect_keyword ( exp ! ( Const ) ) ?;
1042
- let span = tilde. to ( self . prev_token . span ) ;
1043
- self . psess . gated_spans . gate ( sym:: const_trait_impl, span) ;
1044
- BoundConstness :: Maybe ( span)
1045
- } else if self . eat_keyword ( exp ! ( Const ) ) {
1046
- self . psess . gated_spans . gate ( sym:: const_trait_impl, self . prev_token . span ) ;
1047
- BoundConstness :: Always ( self . prev_token . span )
1048
- } else {
1049
- BoundConstness :: Never
1050
- } ;
1039
+ let constness = self . parse_bound_constness ( ) ?;
1051
1040
1052
1041
let asyncness = if self . token_uninterpolated_span ( ) . at_least_rust_2018 ( )
1053
1042
&& self . eat_keyword ( exp ! ( Async ) )
@@ -1109,6 +1098,21 @@ impl<'a> Parser<'a> {
1109
1098
Ok ( TraitBoundModifiers { constness, asyncness, polarity } )
1110
1099
}
1111
1100
1101
+ fn parse_bound_constness ( & mut self ) -> PResult < ' a , BoundConstness > {
1102
+ Ok ( if self . eat ( exp ! ( Tilde ) ) {
1103
+ let tilde = self . prev_token . span ;
1104
+ self . expect_keyword ( exp ! ( Const ) ) ?;
1105
+ let span = tilde. to ( self . prev_token . span ) ;
1106
+ self . psess . gated_spans . gate ( sym:: const_trait_impl, span) ;
1107
+ BoundConstness :: Maybe ( span)
1108
+ } else if self . eat_keyword ( exp ! ( Const ) ) {
1109
+ self . psess . gated_spans . gate ( sym:: const_trait_impl, self . prev_token . span ) ;
1110
+ BoundConstness :: Always ( self . prev_token . span )
1111
+ } else {
1112
+ BoundConstness :: Never
1113
+ } )
1114
+ }
1115
+
1112
1116
/// Parses a type bound according to:
1113
1117
/// ```ebnf
1114
1118
/// TY_BOUND = TY_BOUND_NOPAREN | (TY_BOUND_NOPAREN)
0 commit comments