Skip to content

Commit e439668

Browse files
authored
Rollup merge of #61500 - estebank:expregression, r=petrochenkov
Fix regression 61475 Addresses #61475.
2 parents a898de2 + 5716e26 commit e439668

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

src/libsyntax/parse/parser.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -628,10 +628,10 @@ impl<'a> Parser<'a> {
628628
}
629629
_ => {
630630
Err(if self.prev_token_kind == PrevTokenKind::DocComment {
631-
self.span_fatal_err(self.prev_span, Error::UselessDocComment)
632-
} else {
633-
self.expected_ident_found()
634-
})
631+
self.span_fatal_err(self.prev_span, Error::UselessDocComment)
632+
} else {
633+
self.expected_ident_found()
634+
})
635635
}
636636
}
637637
}
@@ -1657,8 +1657,8 @@ impl<'a> Parser<'a> {
16571657
path = self.parse_path(PathStyle::Type)?;
16581658
path_span = path_lo.to(self.prev_span);
16591659
} else {
1660-
path = ast::Path { segments: Vec::new(), span: DUMMY_SP };
16611660
path_span = self.span.to(self.span);
1661+
path = ast::Path { segments: Vec::new(), span: path_span };
16621662
}
16631663

16641664
// See doc comment for `unmatched_angle_bracket_count`.
@@ -2844,7 +2844,11 @@ impl<'a> Parser<'a> {
28442844
// want to keep their span info to improve diagnostics in these cases in a later stage.
28452845
(true, Some(AssocOp::Multiply)) | // `{ 42 } *foo = bar;` or `{ 42 } * 3`
28462846
(true, Some(AssocOp::Subtract)) | // `{ 42 } -5`
2847-
(true, Some(AssocOp::Add)) => { // `{ 42 } + 42
2847+
(true, Some(AssocOp::LAnd)) | // `{ 42 } &&x` (#61475)
2848+
(true, Some(AssocOp::Add)) // `{ 42 } + 42
2849+
// If the next token is a keyword, then the tokens above *are* unambiguously incorrect:
2850+
// `if x { a } else { b } && if y { c } else { d }`
2851+
if !self.look_ahead(1, |t| t.is_reserved_ident()) => {
28482852
// These cases are ambiguous and can't be identified in the parser alone
28492853
let sp = self.sess.source_map().start_point(self.span);
28502854
self.sess.ambiguous_block_expr_parse.borrow_mut().insert(sp, lhs.span);
@@ -5298,7 +5302,7 @@ impl<'a> Parser<'a> {
52985302
let mut where_clause = WhereClause {
52995303
id: ast::DUMMY_NODE_ID,
53005304
predicates: Vec::new(),
5301-
span: DUMMY_SP,
5305+
span: self.prev_span.to(self.prev_span),
53025306
};
53035307

53045308
if !self.eat_keyword(kw::Where) {

src/test/ui/issues/issue-61475.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// run-pass
2+
#![allow(dead_code)]
3+
4+
enum E {
5+
A, B
6+
}
7+
8+
fn main() {
9+
match &&E::A {
10+
&&E::A => {
11+
}
12+
&&E::B => {
13+
}
14+
};
15+
}

0 commit comments

Comments
 (0)