This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
compiler/rustc_parse/src/parser Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -830,7 +830,8 @@ impl<'a> Parser<'a> {
830830 ) -> PResult < ' a , PatKind > {
831831 let ident = self . parse_ident ( ) ?;
832832
833- if !matches ! ( syntax_loc, Some ( PatternLocation :: FunctionParameter ) )
833+ if self . may_recover ( )
834+ && !matches ! ( syntax_loc, Some ( PatternLocation :: FunctionParameter ) )
834835 && self . check_noexpect ( & token:: Lt )
835836 && self . look_ahead ( 1 , |t| t. can_begin_type ( ) )
836837 {
Original file line number Diff line number Diff line change 1+ // Regression test for issue #115780.
2+ // Ensure that we don't emit a parse error for the token sequence `Ident "<" Ty` in pattern position
3+ // if we are inside a macro call since it can be valid input for a subsequent macro rule.
4+ // See also #103534.
5+
6+ // check-pass
7+
8+ macro_rules! mdo {
9+ ( $p: pat =<< $e: expr ; $( $t: tt ) * ) => {
10+ $e. and_then( |$p| mdo! { $( $t ) * } )
11+ } ;
12+ ( ret<$ty: ty> $e: expr; ) => { Some :: <$ty>( $e) } ;
13+ }
14+
15+ fn main ( ) {
16+ mdo ! {
17+ x_val =<< Some ( 0 ) ;
18+ y_val =<< Some ( 1 ) ;
19+ ret<( i32 , i32 ) > ( x_val, y_val) ;
20+ } ;
21+ }
You can’t perform that action at this time.
0 commit comments