Skip to content

Commit 288202e

Browse files
committed
Fix regression #61475
1 parent 61d286e commit 288202e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-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
}
@@ -1660,8 +1660,8 @@ impl<'a> Parser<'a> {
16601660
path = self.parse_path(PathStyle::Type)?;
16611661
path_span = path_lo.to(self.prev_span);
16621662
} else {
1663-
path = ast::Path { segments: Vec::new(), span: DUMMY_SP };
16641663
path_span = self.span.to(self.span);
1664+
path = ast::Path { segments: Vec::new(), span: path_span };
16651665
}
16661666

16671667
// See doc comment for `unmatched_angle_bracket_count`.
@@ -2847,7 +2847,11 @@ impl<'a> Parser<'a> {
28472847
// want to keep their span info to improve diagnostics in these cases in a later stage.
28482848
(true, Some(AssocOp::Multiply)) | // `{ 42 } *foo = bar;` or `{ 42 } * 3`
28492849
(true, Some(AssocOp::Subtract)) | // `{ 42 } -5`
2850-
(true, Some(AssocOp::Add)) => { // `{ 42 } + 42
2850+
(true, Some(AssocOp::LAnd)) | // `{ 42 } &&x` (#61475)
2851+
(true, Some(AssocOp::Add)) // `{ 42 } + 42
2852+
// If the next token is a keyword, then the tokens above *are* unambiguously incorrect:
2853+
// `if x { a } else { b } && if y { c } else { d }`
2854+
if !self.look_ahead(1, |t| t.is_reserved_ident()) => {
28512855
// These cases are ambiguous and can't be identified in the parser alone
28522856
let sp = self.sess.source_map().start_point(self.span);
28532857
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) {

0 commit comments

Comments
 (0)