Skip to content

Commit d9dfa89

Browse files
committed
Fix span bug
1 parent a72f39f commit d9dfa89

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

compiler/rustc_parse/src/parser/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ impl<'a> Parser<'a> {
10751075
} else if self.eat_keyword(kw::Unsafe) {
10761076
self.parse_block_expr(None, lo, BlockCheckMode::Unsafe(ast::UserProvided), attrs)
10771077
} else if self.eat_keyword(kw::Const) {
1078-
self.parse_const_block(lo.to(self.token.span))
1078+
self.parse_const_block(lo.to(self.prev_token.span))
10791079
} else if self.is_do_catch_block() {
10801080
self.recover_do_catch(attrs)
10811081
} else if self.is_try_block() {

compiler/rustc_parse/src/parser/pat.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ impl<'a> Parser<'a> {
339339
PatKind::Box(pat)
340340
} else if self.eat_keyword(kw::Const) {
341341
// Parse `const { pat }`
342-
let const_expr = self.parse_const_block(lo.to(self.token.span))?;
342+
let const_expr = self.parse_const_block(lo.to(self.prev_token.span))?;
343343

344344
if let Some(re) = self.parse_range_end() {
345345
self.parse_pat_range_begin_with(const_expr, re)?
@@ -755,7 +755,7 @@ impl<'a> Parser<'a> {
755755
fn parse_pat_range_end(&mut self) -> PResult<'a, P<Expr>> {
756756
if self.check_inline_const(0) {
757757
self.eat_keyword(kw::Const);
758-
self.parse_const_block(self.token.span)
758+
self.parse_const_block(self.prev_token.span)
759759
} else if self.check_path() {
760760
let lo = self.token.span;
761761
let (qself, path) = if self.eat_lt() {

src/test/ui/feature-gate-inline_const.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0658]: inline-const is experimental
22
--> $DIR/feature-gate-inline_const.rs:2:13
33
|
44
LL | let _ = const {
5-
| ^^^^^^^
5+
| ^^^^^
66
|
77
= note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
88
= help: add `#![feature(inline_const)]` to the crate attributes to enable

src/test/ui/parser/keyword-const-as-identifier.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0658]: inline-const is experimental
88
--> $DIR/keyword-const-as-identifier.rs:2:9
99
|
1010
LL | let const = "foo";
11-
| ^^^^^^^
11+
| ^^^^^
1212
|
1313
= note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
1414
= help: add `#![feature(inline_const)]` to the crate attributes to enable

0 commit comments

Comments
 (0)