Skip to content

Commit 2bd27fb

Browse files
committed
parser: fix span for leading vert.
1 parent acb1130 commit 2bd27fb

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/libsyntax/parse/parser/pat.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ impl<'a> Parser<'a> {
5050
pub(super) fn parse_top_pat(&mut self, gate_or: GateOr) -> PResult<'a, P<Pat>> {
5151
// Allow a '|' before the pats (RFCs 1925, 2530, and 2535).
5252
let gated_leading_vert = self.eat_or_separator() && gate_or == GateOr::Yes;
53+
let leading_vert_span = self.prev_span;
5354

5455
// Parse the possibly-or-pattern.
5556
let pat = self.parse_pat_with_or(None, gate_or, RecoverComma::Yes)?;
@@ -61,7 +62,7 @@ impl<'a> Parser<'a> {
6162
if gated_leading_vert {
6263
let mut or_pattern_spans = self.sess.gated_spans.or_patterns.borrow_mut();
6364
if or_pattern_spans.is_empty() {
64-
or_pattern_spans.push(self.prev_span);
65+
or_pattern_spans.push(leading_vert_span);
6566
}
6667
}
6768

src/test/ui/or-patterns/feature-gate-or_patterns-leading-for.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0658]: or-patterns syntax is experimental
2-
--> $DIR/feature-gate-or_patterns-leading-for.rs:7:11
2+
--> $DIR/feature-gate-or_patterns-leading-for.rs:7:9
33
|
44
LL | for | A in 0 {}
5-
| ^
5+
| ^
66
|
77
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
88
= help: add `#![feature(or_patterns)]` to the crate attributes to enable

src/test/ui/or-patterns/feature-gate-or_patterns-leading-let.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0658]: or-patterns syntax is experimental
2-
--> $DIR/feature-gate-or_patterns-leading-let.rs:7:11
2+
--> $DIR/feature-gate-or_patterns-leading-let.rs:7:9
33
|
44
LL | let | A;
5-
| ^
5+
| ^
66
|
77
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
88
= help: add `#![feature(or_patterns)]` to the crate attributes to enable

0 commit comments

Comments
 (0)