Skip to content

Commit 367db83

Browse files
committed
Auto merge of #115785 - fmease:fix-pat-regression, r=wesleywiser
Only suggest turbofish in patterns if we may recover Fixes [after backport] #115780. CC #103534.
2 parents d9c8274 + 3ed77e9 commit 367db83

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

compiler/rustc_parse/src/parser/pat.rs

+2-1
Original file line numberDiff line numberDiff 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 numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
}

0 commit comments

Comments
 (0)