Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 17b5112

Browse filesBrowse files
authored
Unrolled build for rust-lang#133623
Rollup merge of rust-lang#133623 - nnethercote:parse_expr_bottom-spans, r=compiler-errors Improve span handling in `parse_expr_bottom`. `parse_expr_bottom` stores `this.token.span` in `lo`, but then fails to use it in many places where it could. This commit fixes that, and likewise (to a smaller extent) in `parse_ty_common`. r? ``@spastorino``
2 parents e48ddd8 + 90ad2ad commit 17b5112
Copy full SHA for 17b5112

File tree

Expand file treeCollapse file tree

3 files changed

+14
-21
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+14
-21
lines changed

‎compiler/rustc_parse/src/parser/diagnostics.rs

Copy file name to clipboardExpand all lines: compiler/rustc_parse/src/parser/diagnostics.rs
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,6 @@ impl<'a> Parser<'a> {
19901990
/// `await? <expr>`, `await(<expr>)`, and `await { <expr> }`.
19911991
pub(super) fn recover_incorrect_await_syntax(
19921992
&mut self,
1993-
lo: Span,
19941993
await_sp: Span,
19951994
) -> PResult<'a, P<Expr>> {
19961995
let (hi, expr, is_question) = if self.token == token::Not {
@@ -1999,8 +1998,8 @@ impl<'a> Parser<'a> {
19991998
} else {
20001999
self.recover_await_prefix(await_sp)?
20012000
};
2002-
let (sp, guar) = self.error_on_incorrect_await(lo, hi, &expr, is_question);
2003-
let expr = self.mk_expr_err(lo.to(sp), guar);
2001+
let (sp, guar) = self.error_on_incorrect_await(await_sp, hi, &expr, is_question);
2002+
let expr = self.mk_expr_err(await_sp.to(sp), guar);
20042003
self.maybe_recover_from_bad_qpath(expr)
20052004
}
20062005

‎compiler/rustc_parse/src/parser/expr.rs

Copy file name to clipboardExpand all lines: compiler/rustc_parse/src/parser/expr.rs
+8-11Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,34 +1446,31 @@ impl<'a> Parser<'a> {
14461446
this.parse_expr_closure()
14471447
} else {
14481448
assert!(this.eat_keyword(kw::For));
1449-
this.parse_expr_for(None, this.prev_token.span)
1449+
this.parse_expr_for(None, lo)
14501450
}
14511451
} else if this.eat_keyword(kw::While) {
1452-
this.parse_expr_while(None, this.prev_token.span)
1452+
this.parse_expr_while(None, lo)
14531453
} else if let Some(label) = this.eat_label() {
14541454
this.parse_expr_labeled(label, true)
14551455
} else if this.eat_keyword(kw::Loop) {
1456-
let sp = this.prev_token.span;
1457-
this.parse_expr_loop(None, this.prev_token.span).map_err(|mut err| {
1458-
err.span_label(sp, "while parsing this `loop` expression");
1456+
this.parse_expr_loop(None, lo).map_err(|mut err| {
1457+
err.span_label(lo, "while parsing this `loop` expression");
14591458
err
14601459
})
14611460
} else if this.eat_keyword(kw::Match) {
1462-
let match_sp = this.prev_token.span;
14631461
this.parse_expr_match().map_err(|mut err| {
1464-
err.span_label(match_sp, "while parsing this `match` expression");
1462+
err.span_label(lo, "while parsing this `match` expression");
14651463
err
14661464
})
14671465
} else if this.eat_keyword(kw::Unsafe) {
1468-
let sp = this.prev_token.span;
14691466
this.parse_expr_block(None, lo, BlockCheckMode::Unsafe(ast::UserProvided)).map_err(
14701467
|mut err| {
1471-
err.span_label(sp, "while parsing this `unsafe` expression");
1468+
err.span_label(lo, "while parsing this `unsafe` expression");
14721469
err
14731470
},
14741471
)
14751472
} else if this.check_inline_const(0) {
1476-
this.parse_const_block(lo.to(this.token.span), false)
1473+
this.parse_const_block(lo, false)
14771474
} else if this.may_recover() && this.is_do_catch_block() {
14781475
this.recover_do_catch()
14791476
} else if this.is_try_block() {
@@ -1514,7 +1511,7 @@ impl<'a> Parser<'a> {
15141511
this.parse_expr_closure()
15151512
}
15161513
} else if this.eat_keyword_noexpect(kw::Await) {
1517-
this.recover_incorrect_await_syntax(lo, this.prev_token.span)
1514+
this.recover_incorrect_await_syntax(lo)
15181515
} else {
15191516
this.parse_expr_lit()
15201517
}

‎compiler/rustc_parse/src/parser/ty.rs

Copy file name to clipboardExpand all lines: compiler/rustc_parse/src/parser/ty.rs
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ impl<'a> Parser<'a> {
274274
// Function pointer type
275275
self.parse_ty_bare_fn(lo, ThinVec::new(), None, recover_return_sign)?
276276
} else if self.check_keyword(kw::For) {
277-
let for_span = self.token.span;
278277
// Function pointer type or bound list (trait object type) starting with a poly-trait.
279278
// `for<'lt> [unsafe] [extern "ABI"] fn (&'lt S) -> T`
280279
// `for<'lt> Trait1<'lt> + Trait2 + 'a`
@@ -302,7 +301,7 @@ impl<'a> Parser<'a> {
302301
kw: kw.name.as_str(),
303302
sugg: errors::TransposeDynOrImplSugg {
304303
removal_span,
305-
insertion_span: for_span.shrink_to_lo(),
304+
insertion_span: lo.shrink_to_lo(),
306305
kw: kw.name.as_str(),
307306
},
308307
});
@@ -345,16 +344,14 @@ impl<'a> Parser<'a> {
345344
// FIXME(c_variadic): Should we just allow `...` syntactically
346345
// anywhere in a type and use semantic restrictions instead?
347346
// NOTE: This may regress certain MBE calls if done incorrectly.
348-
let guar = self
349-
.dcx()
350-
.emit_err(NestedCVariadicType { span: lo.to(self.prev_token.span) });
347+
let guar = self.dcx().emit_err(NestedCVariadicType { span: lo });
351348
TyKind::Err(guar)
352349
}
353350
}
354351
} else {
355352
let msg = format!("expected type, found {}", super::token_descr(&self.token));
356-
let mut err = self.dcx().struct_span_err(self.token.span, msg);
357-
err.span_label(self.token.span, "expected type");
353+
let mut err = self.dcx().struct_span_err(lo, msg);
354+
err.span_label(lo, "expected type");
358355
return Err(err);
359356
};
360357

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.