@@ -1015,12 +1015,18 @@ impl<'a> Parser<'a> {
10151015 || self . check ( exp ! ( Tilde ) )
10161016 || self . check_keyword ( exp ! ( For ) )
10171017 || self . check ( exp ! ( OpenParen ) )
1018- || self . check ( exp ! ( OpenBracket ) )
1018+ || self . can_begin_maybe_const_bound ( )
10191019 || self . check_keyword ( exp ! ( Const ) )
10201020 || self . check_keyword ( exp ! ( Async ) )
10211021 || self . check_keyword ( exp ! ( Use ) )
10221022 }
10231023
1024+ fn can_begin_maybe_const_bound ( & mut self ) -> bool {
1025+ self . check ( exp ! ( OpenBracket ) )
1026+ && self . look_ahead ( 1 , |t| t. is_keyword ( kw:: Const ) )
1027+ && self . look_ahead ( 2 , |t| * t == token:: CloseBracket )
1028+ }
1029+
10241030 /// Parse a bound.
10251031 ///
10261032 /// ```ebnf
@@ -1199,10 +1205,7 @@ impl<'a> Parser<'a> {
11991205 let span = tilde. to ( self . prev_token . span ) ;
12001206 self . psess . gated_spans . gate ( sym:: const_trait_impl, span) ;
12011207 BoundConstness :: Maybe ( span)
1202- } else if self . check ( exp ! ( OpenBracket ) )
1203- && self . look_ahead ( 1 , |t| t. is_keyword ( kw:: Const ) )
1204- && self . look_ahead ( 2 , |t| * t == token:: CloseBracket )
1205- {
1208+ } else if self . can_begin_maybe_const_bound ( ) {
12061209 let start = self . token . span ;
12071210 self . bump ( ) ;
12081211 self . expect_keyword ( exp ! ( Const ) ) . unwrap ( ) ;
0 commit comments