mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
parser: fix span for leading vert.
This commit is contained in:
parent
acb11305e8
commit
2bd27fbdfe
@ -50,6 +50,7 @@ impl<'a> Parser<'a> {
|
|||||||
pub(super) fn parse_top_pat(&mut self, gate_or: GateOr) -> PResult<'a, P<Pat>> {
|
pub(super) fn parse_top_pat(&mut self, gate_or: GateOr) -> PResult<'a, P<Pat>> {
|
||||||
// Allow a '|' before the pats (RFCs 1925, 2530, and 2535).
|
// Allow a '|' before the pats (RFCs 1925, 2530, and 2535).
|
||||||
let gated_leading_vert = self.eat_or_separator() && gate_or == GateOr::Yes;
|
let gated_leading_vert = self.eat_or_separator() && gate_or == GateOr::Yes;
|
||||||
|
let leading_vert_span = self.prev_span;
|
||||||
|
|
||||||
// Parse the possibly-or-pattern.
|
// Parse the possibly-or-pattern.
|
||||||
let pat = self.parse_pat_with_or(None, gate_or, RecoverComma::Yes)?;
|
let pat = self.parse_pat_with_or(None, gate_or, RecoverComma::Yes)?;
|
||||||
@ -61,7 +62,7 @@ impl<'a> Parser<'a> {
|
|||||||
if gated_leading_vert {
|
if gated_leading_vert {
|
||||||
let mut or_pattern_spans = self.sess.gated_spans.or_patterns.borrow_mut();
|
let mut or_pattern_spans = self.sess.gated_spans.or_patterns.borrow_mut();
|
||||||
if or_pattern_spans.is_empty() {
|
if or_pattern_spans.is_empty() {
|
||||||
or_pattern_spans.push(self.prev_span);
|
or_pattern_spans.push(leading_vert_span);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0658]: or-patterns syntax is experimental
|
error[E0658]: or-patterns syntax is experimental
|
||||||
--> $DIR/feature-gate-or_patterns-leading-for.rs:7:11
|
--> $DIR/feature-gate-or_patterns-leading-for.rs:7:9
|
||||||
|
|
|
|
||||||
LL | for | A in 0 {}
|
LL | for | A in 0 {}
|
||||||
| ^
|
| ^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
error[E0658]: or-patterns syntax is experimental
|
error[E0658]: or-patterns syntax is experimental
|
||||||
--> $DIR/feature-gate-or_patterns-leading-let.rs:7:11
|
--> $DIR/feature-gate-or_patterns-leading-let.rs:7:9
|
||||||
|
|
|
|
||||||
LL | let | A;
|
LL | let | A;
|
||||||
| ^
|
| ^
|
||||||
|
|
|
|
||||||
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
Loading…
Reference in New Issue
Block a user