File tree Expand file tree Collapse file tree 2 files changed +3
-4
lines changed
src/librustc_parse/parser Expand file tree Collapse file tree 2 files changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -1055,10 +1055,11 @@ impl<'a> Parser<'a> {
10551055 }
10561056
10571057 pub ( super ) fn try_macro_suggestion ( & mut self ) -> DiagnosticBuilder < ' a > {
1058+ let is_try = self . token . is_keyword ( kw:: Try ) ;
10581059 let is_questionmark = self . look_ahead ( 1 , |t| t == & token:: Not ) ; //check for !
10591060 let is_open = self . look_ahead ( 2 , |t| t == & token:: OpenDelim ( token:: Paren ) ) ; //check for (
10601061
1061- if is_questionmark && is_open {
1062+ if is_try && is_questionmark && is_open {
10621063 let lo = self . token . span ;
10631064 self . bump ( ) ; //remove try
10641065 self . bump ( ) ; //remove !
Original file line number Diff line number Diff line change @@ -1001,14 +1001,12 @@ impl<'a> Parser<'a> {
10011001
10021002 fn parse_lit_expr ( & mut self , attrs : AttrVec ) -> PResult < ' a , P < Expr > > {
10031003 let lo = self . token . span ;
1004- let is_try = self . token . is_keyword ( kw:: Try ) ;
10051004 match self . parse_opt_lit ( ) {
10061005 Some ( literal) => {
10071006 let expr = self . mk_expr ( lo. to ( self . prev_token . span ) , ExprKind :: Lit ( literal) , attrs) ;
10081007 self . maybe_recover_from_bad_qpath ( expr, true )
10091008 }
1010- None if is_try => Err ( self . try_macro_suggestion ( ) ) ,
1011- None => Err ( self . expected_expression_found ( ) ) ,
1009+ None => Err ( self . try_macro_suggestion ( ) ) ,
10121010 }
10131011 }
10141012
You can’t perform that action at this time.
0 commit comments