1
Fork 0

Ban ...X pats, harden tests, and improve diagnostics.

Also fix a bug with the span passed in `mk_range`.
This commit is contained in:
Mazdak Farrokhzad 2020-01-11 06:49:43 +01:00
parent e621797264
commit 883932c6ba
19 changed files with 263 additions and 124 deletions

View file

@ -1966,7 +1966,7 @@ impl<'a> Parser<'a> {
limits: RangeLimits, limits: RangeLimits,
) -> PResult<'a, ExprKind> { ) -> PResult<'a, ExprKind> {
if end.is_none() && limits == RangeLimits::Closed { if end.is_none() && limits == RangeLimits::Closed {
self.error_inclusive_range_with_no_end(self.token.span); self.error_inclusive_range_with_no_end(self.prev_span);
Ok(ExprKind::Err) Ok(ExprKind::Err)
} else { } else {
Ok(ExprKind::Range(start, end, limits)) Ok(ExprKind::Range(start, end, limits))

View file

@ -661,14 +661,34 @@ impl<'a> Parser<'a> {
pub(super) fn error_inclusive_range_with_no_end(&self, span: Span) { pub(super) fn error_inclusive_range_with_no_end(&self, span: Span) {
use rustc_error_codes::E0586; use rustc_error_codes::E0586;
struct_span_err!(self.sess.span_diagnostic, span, E0586, "inclusive range with no end") struct_span_err!(self.sess.span_diagnostic, span, E0586, "inclusive range with no end")
.help("inclusive ranges must be bounded at the end (`..=b` or `a..=b`)") .span_suggestion_short(
span,
"use `..` instead",
"..".to_string(),
Applicability::MachineApplicable,
)
.note("inclusive ranges must be bounded at the end (`..=b` or `a..=b`)")
.emit(); .emit();
} }
/// Parse a range-to pattern, e.g. `..X` and `..=X` where `X` remains to be parsed. /// Parse a range-to pattern, `..X` or `..=X` where `X` remains to be parsed.
fn parse_pat_range_to(&mut self, re: Spanned<RangeEnd>) -> PResult<'a, PatKind> { ///
/// The form `...X` is prohibited to reduce confusion with the potential
/// expression syntax `...expr` for splatting in expressions.
fn parse_pat_range_to(&mut self, mut re: Spanned<RangeEnd>) -> PResult<'a, PatKind> {
let end = self.parse_pat_range_end()?; let end = self.parse_pat_range_end()?;
self.sess.gated_spans.gate(sym::half_open_range_patterns, re.span.to(self.prev_span)); self.sess.gated_spans.gate(sym::half_open_range_patterns, re.span.to(self.prev_span));
if let RangeEnd::Included(ref mut syn @ RangeSyntax::DotDotDot) = &mut re.node {
*syn = RangeSyntax::DotDotEq;
self.struct_span_err(re.span, "range-to patterns with `...` are not allowed")
.span_suggestion_short(
re.span,
"use `..=` instead",
"..=".to_string(),
Applicability::MachineApplicable,
)
.emit();
}
Ok(PatKind::Range(None, Some(end), re)) Ok(PatKind::Range(None, Some(end), re))
} }

View file

@ -1,10 +1,10 @@
error[E0586]: inclusive range with no end error[E0586]: inclusive range with no end
--> $DIR/E0586.rs:3:22 --> $DIR/E0586.rs:3:19
| |
LL | let x = &tmp[1..=]; LL | let x = &tmp[1..=];
| ^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: aborting due to previous error error: aborting due to previous error

View file

@ -8,6 +8,7 @@ fn foo() {
//~^ ERROR half-open range patterns are unstable //~^ ERROR half-open range patterns are unstable
if let ...5 = 0 {} if let ...5 = 0 {}
//~^ ERROR half-open range patterns are unstable //~^ ERROR half-open range patterns are unstable
//~| ERROR range-to patterns with `...` are not allowed
if let ..5 = 0 {} if let ..5 = 0 {}
//~^ ERROR half-open range patterns are unstable //~^ ERROR half-open range patterns are unstable
if let 5.. = 0 {} if let 5.. = 0 {}

View file

@ -1,18 +1,24 @@
error[E0586]: inclusive range with no end error: range-to patterns with `...` are not allowed
--> $DIR/feature-gate-half-open-range-patterns.rs:15:13 --> $DIR/feature-gate-half-open-range-patterns.rs:9:12
| |
LL | if let 5..= = 0 {} LL | if let ...5 = 0 {}
| ^^^ | ^^^ help: use `..=` instead
|
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error[E0586]: inclusive range with no end error[E0586]: inclusive range with no end
--> $DIR/feature-gate-half-open-range-patterns.rs:18:13 --> $DIR/feature-gate-half-open-range-patterns.rs:16:13
|
LL | if let 5..= = 0 {}
| ^^^ help: use `..` instead
|
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error[E0586]: inclusive range with no end
--> $DIR/feature-gate-half-open-range-patterns.rs:19:13
| |
LL | if let 5... = 0 {} LL | if let 5... = 0 {}
| ^^^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error[E0658]: half-open range patterns are unstable error[E0658]: half-open range patterns are unstable
--> $DIR/feature-gate-half-open-range-patterns.rs:7:12 --> $DIR/feature-gate-half-open-range-patterns.rs:7:12
@ -33,7 +39,7 @@ LL | if let ...5 = 0 {}
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable = help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
error[E0658]: half-open range patterns are unstable error[E0658]: half-open range patterns are unstable
--> $DIR/feature-gate-half-open-range-patterns.rs:11:12 --> $DIR/feature-gate-half-open-range-patterns.rs:12:12
| |
LL | if let ..5 = 0 {} LL | if let ..5 = 0 {}
| ^^^ | ^^^
@ -42,7 +48,7 @@ LL | if let ..5 = 0 {}
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable = help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
error[E0658]: half-open range patterns are unstable error[E0658]: half-open range patterns are unstable
--> $DIR/feature-gate-half-open-range-patterns.rs:13:12 --> $DIR/feature-gate-half-open-range-patterns.rs:14:12
| |
LL | if let 5.. = 0 {} LL | if let 5.. = 0 {}
| ^^^ | ^^^
@ -51,7 +57,7 @@ LL | if let 5.. = 0 {}
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable = help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
error[E0658]: half-open range patterns are unstable error[E0658]: half-open range patterns are unstable
--> $DIR/feature-gate-half-open-range-patterns.rs:15:12 --> $DIR/feature-gate-half-open-range-patterns.rs:16:12
| |
LL | if let 5..= = 0 {} LL | if let 5..= = 0 {}
| ^^^^ | ^^^^
@ -60,7 +66,7 @@ LL | if let 5..= = 0 {}
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable = help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
error[E0658]: half-open range patterns are unstable error[E0658]: half-open range patterns are unstable
--> $DIR/feature-gate-half-open-range-patterns.rs:18:12 --> $DIR/feature-gate-half-open-range-patterns.rs:19:12
| |
LL | if let 5... = 0 {} LL | if let 5... = 0 {}
| ^^^^ | ^^^^
@ -68,7 +74,7 @@ LL | if let 5... = 0 {}
= note: for more information, see https://github.com/rust-lang/rust/issues/67264 = note: for more information, see https://github.com/rust-lang/rust/issues/67264
= help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable = help: add `#![feature(half_open_range_patterns)]` to the crate attributes to enable
error: aborting due to 8 previous errors error: aborting due to 9 previous errors
Some errors have detailed explanations: E0586, E0658. Some errors have detailed explanations: E0586, E0658.
For more information about an error, try `rustc --explain E0586`. For more information about an error, try `rustc --explain E0586`.

View file

@ -0,0 +1,32 @@
// Test that `...X` range-to patterns are syntactically invalid.
//
// See https://github.com/rust-lang/rust/pull/67258#issuecomment-565656155
// for the reason why. To summarize, we might want to introduce `...expr` as
// an expression form for splatting (or "untupling") in an expression context.
// While there is no syntactic ambiguity with `...X` in a pattern context,
// there's a potential confusion factor here, and we would prefer to keep patterns
// and expressions in-sync. As such, we do not allow `...X` in patterns either.
#![feature(half_open_range_patterns)]
fn main() {}
#[cfg(FALSE)]
fn syntax() {
match scrutinee {
...X => {} //~ ERROR range-to patterns with `...` are not allowed
...0 => {} //~ ERROR range-to patterns with `...` are not allowed
...'a' => {} //~ ERROR range-to patterns with `...` are not allowed
...0.0f32 => {} //~ ERROR range-to patterns with `...` are not allowed
}
}
fn syntax2() {
macro_rules! mac {
($e:expr) => {
let ...$e; //~ ERROR range-to patterns with `...` are not allowed
}
}
mac!(0);
}

View file

@ -0,0 +1,35 @@
error: range-to patterns with `...` are not allowed
--> $DIR/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs:17:9
|
LL | ...X => {}
| ^^^ help: use `..=` instead
error: range-to patterns with `...` are not allowed
--> $DIR/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs:18:9
|
LL | ...0 => {}
| ^^^ help: use `..=` instead
error: range-to patterns with `...` are not allowed
--> $DIR/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs:19:9
|
LL | ...'a' => {}
| ^^^ help: use `..=` instead
error: range-to patterns with `...` are not allowed
--> $DIR/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs:20:9
|
LL | ...0.0f32 => {}
| ^^^ help: use `..=` instead
error: range-to patterns with `...` are not allowed
--> $DIR/half-open-range-pats-inclusive-dotdotdot-bad-syntax.rs:27:17
|
LL | let ...$e;
| ^^^ help: use `..=` instead
...
LL | mac!(0);
| -------- in this macro invocation
error: aborting due to 5 previous errors

View file

@ -13,3 +13,14 @@ fn foo() {
if let X... = 1 {} //~ ERROR inclusive range with no end if let X... = 1 {} //~ ERROR inclusive range with no end
if let X..= = 1 {} //~ ERROR inclusive range with no end if let X..= = 1 {} //~ ERROR inclusive range with no end
} }
fn bar() {
macro_rules! mac {
($e:expr) => {
let $e...; //~ ERROR inclusive range with no end
let $e..=; //~ ERROR inclusive range with no end
}
}
mac!(0);
}

View file

@ -2,34 +2,56 @@ error[E0586]: inclusive range with no end
--> $DIR/half-open-range-pats-inclusive-no-end.rs:10:13 --> $DIR/half-open-range-pats-inclusive-no-end.rs:10:13
| |
LL | if let 0... = 1 {} LL | if let 0... = 1 {}
| ^^^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error[E0586]: inclusive range with no end error[E0586]: inclusive range with no end
--> $DIR/half-open-range-pats-inclusive-no-end.rs:11:13 --> $DIR/half-open-range-pats-inclusive-no-end.rs:11:13
| |
LL | if let 0..= = 1 {} LL | if let 0..= = 1 {}
| ^^^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error[E0586]: inclusive range with no end error[E0586]: inclusive range with no end
--> $DIR/half-open-range-pats-inclusive-no-end.rs:13:13 --> $DIR/half-open-range-pats-inclusive-no-end.rs:13:13
| |
LL | if let X... = 1 {} LL | if let X... = 1 {}
| ^^^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error[E0586]: inclusive range with no end error[E0586]: inclusive range with no end
--> $DIR/half-open-range-pats-inclusive-no-end.rs:14:13 --> $DIR/half-open-range-pats-inclusive-no-end.rs:14:13
| |
LL | if let X..= = 1 {} LL | if let X..= = 1 {}
| ^^^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: aborting due to 4 previous errors error[E0586]: inclusive range with no end
--> $DIR/half-open-range-pats-inclusive-no-end.rs:20:19
|
LL | let $e...;
| ^^^ help: use `..` instead
...
LL | mac!(0);
| -------- in this macro invocation
|
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error[E0586]: inclusive range with no end
--> $DIR/half-open-range-pats-inclusive-no-end.rs:21:19
|
LL | let $e..=;
| ^^^ help: use `..` instead
...
LL | mac!(0);
| -------- in this macro invocation
|
= note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0586`. For more information about this error, try `rustc --explain E0586`.

View file

@ -20,5 +20,7 @@ fn syntax() {
&..=0 | _ => {} &..=0 | _ => {}
//~^ ERROR the range pattern here has ambiguous interpretation //~^ ERROR the range pattern here has ambiguous interpretation
&...0 | _ => {} &...0 | _ => {}
//~^ ERROR the range pattern here has ambiguous interpretation
//~| ERROR range-to patterns with `...` are not allowed
} }
} }

View file

@ -8,9 +8,9 @@ error[E0586]: inclusive range with no end
--> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:10:11 --> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:10:11
| |
LL | &0..= | _ => {} LL | &0..= | _ => {}
| ^^^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: the range pattern here has ambiguous interpretation error: the range pattern here has ambiguous interpretation
--> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:10:10 --> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:10:10
@ -22,9 +22,9 @@ error[E0586]: inclusive range with no end
--> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:13:11 --> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:13:11
| |
LL | &0... | _ => {} LL | &0... | _ => {}
| ^^^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: the range pattern here has ambiguous interpretation error: the range pattern here has ambiguous interpretation
--> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:18:10 --> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:18:10
@ -38,6 +38,18 @@ error: the range pattern here has ambiguous interpretation
LL | &..=0 | _ => {} LL | &..=0 | _ => {}
| ^^^^ help: add parentheses to clarify the precedence: `(..=0)` | ^^^^ help: add parentheses to clarify the precedence: `(..=0)`
error: aborting due to 6 previous errors error: range-to patterns with `...` are not allowed
--> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:22:10
|
LL | &...0 | _ => {}
| ^^^ help: use `..=` instead
error: the range pattern here has ambiguous interpretation
--> $DIR/half-open-range-pats-ref-ambiguous-interp.rs:22:10
|
LL | &...0 | _ => {}
| ^^^^ help: add parentheses to clarify the precedence: `(..=0)`
error: aborting due to 8 previous errors
For more information about this error, try `rustc --explain E0586`. For more information about this error, try `rustc --explain E0586`.

View file

@ -11,22 +11,20 @@ fn main() {}
fn syntax() { fn syntax() {
match scrutinee { match scrutinee {
X.. | 0.. | 'a'.. | 0.0f32.. => {} X.. | 0.. | 'a'.. | 0.0f32.. => {}
..=X | ...X | ..X => {} ..=X | ..X => {}
..=0 | ...0 | ..0 => {} ..=0 | ..0 => {}
..='a' | ...'a' | ..'a' => {} ..='a' | ..'a' => {}
..=0.0f32 | ...0.0f32 | ..0.0f32 => {} ..=0.0f32 | ..0.0f32 => {}
} }
}
fn syntax2() {
macro_rules! mac { macro_rules! mac {
($e:expr) => { ($e:expr) => {
let ..$e; match 0u8 { ..$e => {}, _ => {} }
let ...$e; match 0u8 { ..=$e => {}, _ => {} }
let ..=$e; match 0u8 { $e.. => {}, _ => {} }
let $e..;
let $e...;
let $e..=;
} }
} }
mac!(42u8);
mac!(0);
} }

View file

@ -1,4 +1,4 @@
// Make sure that invalid ranges generate an error during HIR lowering, not an ICE // Make sure that invalid ranges generate an error during parsing, not an ICE
pub fn main() { pub fn main() {
..; ..;
@ -6,12 +6,12 @@ pub fn main() {
..1; ..1;
0..1; 0..1;
..=; //~ERROR inclusive range with no end ..=; //~ERROR inclusive range with no end
//~^HELP bounded at the end //~^HELP use `..` instead
} }
fn _foo1() { fn _foo1() {
..=1; ..=1;
0..=1; 0..=1;
0..=; //~ERROR inclusive range with no end 0..=; //~ERROR inclusive range with no end
//~^HELP bounded at the end //~^HELP use `..` instead
} }

View file

@ -1,18 +1,18 @@
error[E0586]: inclusive range with no end error[E0586]: inclusive range with no end
--> $DIR/impossible_range.rs:8:8 --> $DIR/impossible_range.rs:8:5
| |
LL | ..=; LL | ..=;
| ^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error[E0586]: inclusive range with no end error[E0586]: inclusive range with no end
--> $DIR/impossible_range.rs:15:9 --> $DIR/impossible_range.rs:15:6
| |
LL | 0..=; LL | 0..=;
| ^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -342,9 +342,9 @@ error[E0586]: inclusive range with no end
--> $DIR/attr-stmt-expr-attr-bad.rs:94:35 --> $DIR/attr-stmt-expr-attr-bad.rs:94:35
| |
LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } } LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } }
| ^^^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: expected one of `=>`, `if`, or `|`, found `#` error: expected one of `=>`, `if`, or `|`, found `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:94:38 --> $DIR/attr-stmt-expr-attr-bad.rs:94:38
@ -356,9 +356,9 @@ error[E0586]: inclusive range with no end
--> $DIR/attr-stmt-expr-attr-bad.rs:97:35 --> $DIR/attr-stmt-expr-attr-bad.rs:97:35
| |
LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } } LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } }
| ^^^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: expected one of `=>`, `if`, or `|`, found `#` error: expected one of `=>`, `if`, or `|`, found `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:97:38 --> $DIR/attr-stmt-expr-attr-bad.rs:97:38
@ -376,9 +376,9 @@ error[E0586]: inclusive range with no end
--> $DIR/attr-stmt-expr-attr-bad.rs:102:35 --> $DIR/attr-stmt-expr-attr-bad.rs:102:35
| |
LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } } LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } }
| ^^^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: expected one of `=>`, `if`, or `|`, found `#` error: expected one of `=>`, `if`, or `|`, found `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:102:38 --> $DIR/attr-stmt-expr-attr-bad.rs:102:38

View file

@ -2,5 +2,5 @@
pub fn main() { pub fn main() {
for _ in 1..= {} //~ERROR inclusive range with no end for _ in 1..= {} //~ERROR inclusive range with no end
//~^HELP bounded at the end //~^HELP use `..` instead
} }

View file

@ -1,10 +1,10 @@
error[E0586]: inclusive range with no end error[E0586]: inclusive range with no end
--> $DIR/range_inclusive.rs:4:19 --> $DIR/range_inclusive.rs:4:15
| |
LL | for _ in 1..= {} LL | for _ in 1..= {}
| ^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: aborting due to previous error error: aborting due to previous error

View file

@ -107,15 +107,15 @@ fn inclusive_to() {
fn inclusive2_to() { fn inclusive2_to() {
if let ...3 = 0 {} if let ...3 = 0 {}
//~^ ERROR `...` range patterns are deprecated //~^ ERROR range-to patterns with `...` are not allowed
if let ...Y = 0 {} if let ...Y = 0 {}
//~^ ERROR `...` range patterns are deprecated //~^ ERROR range-to patterns with `...` are not allowed
if let ...true = 0 {} if let ...true = 0 {}
//~^ ERROR `...` range patterns are deprecated //~^ ERROR range-to patterns with `...` are not allowed
//~| ERROR only char and numeric types //~| ERROR only char and numeric types
if let ....3 = 0 {} if let ....3 = 0 {}
//~^ ERROR float literals must have an integer part //~^ ERROR float literals must have an integer part
//~| ERROR `...` range patterns are deprecated //~| ERROR range-to patterns with `...` are not allowed
//~| ERROR mismatched types //~| ERROR mismatched types
} }
@ -135,7 +135,7 @@ fn with_macro_expr_var() {
($e:expr) => { ($e:expr) => {
let ..$e; let ..$e;
let ...$e; let ...$e;
//~^ ERROR `...` range patterns are deprecated //~^ ERROR range-to patterns with `...` are not allowed
let ..=$e; let ..=$e;
let $e..; let $e..;
let $e...; //~ ERROR inclusive range with no end let $e...; //~ ERROR inclusive range with no end

View file

@ -44,25 +44,25 @@ error[E0586]: inclusive range with no end
--> $DIR/recover-range-pats.rs:69:13 --> $DIR/recover-range-pats.rs:69:13
| |
LL | if let 0..= = 0 {} LL | if let 0..= = 0 {}
| ^^^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error[E0586]: inclusive range with no end error[E0586]: inclusive range with no end
--> $DIR/recover-range-pats.rs:70:13 --> $DIR/recover-range-pats.rs:70:13
| |
LL | if let X..= = 0 {} LL | if let X..= = 0 {}
| ^^^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error[E0586]: inclusive range with no end error[E0586]: inclusive range with no end
--> $DIR/recover-range-pats.rs:71:16 --> $DIR/recover-range-pats.rs:71:16
| |
LL | if let true..= = 0 {} LL | if let true..= = 0 {}
| ^^^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: float literals must have an integer part error: float literals must have an integer part
--> $DIR/recover-range-pats.rs:73:12 --> $DIR/recover-range-pats.rs:73:12
@ -74,33 +74,33 @@ error[E0586]: inclusive range with no end
--> $DIR/recover-range-pats.rs:73:14 --> $DIR/recover-range-pats.rs:73:14
| |
LL | if let .0..= = 0 {} LL | if let .0..= = 0 {}
| ^^^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error[E0586]: inclusive range with no end error[E0586]: inclusive range with no end
--> $DIR/recover-range-pats.rs:79:13 --> $DIR/recover-range-pats.rs:79:13
| |
LL | if let 0... = 0 {} LL | if let 0... = 0 {}
| ^^^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error[E0586]: inclusive range with no end error[E0586]: inclusive range with no end
--> $DIR/recover-range-pats.rs:80:13 --> $DIR/recover-range-pats.rs:80:13
| |
LL | if let X... = 0 {} LL | if let X... = 0 {}
| ^^^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error[E0586]: inclusive range with no end error[E0586]: inclusive range with no end
--> $DIR/recover-range-pats.rs:81:16 --> $DIR/recover-range-pats.rs:81:16
| |
LL | if let true... = 0 {} LL | if let true... = 0 {}
| ^^^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: float literals must have an integer part error: float literals must have an integer part
--> $DIR/recover-range-pats.rs:83:12 --> $DIR/recover-range-pats.rs:83:12
@ -112,9 +112,9 @@ error[E0586]: inclusive range with no end
--> $DIR/recover-range-pats.rs:83:14 --> $DIR/recover-range-pats.rs:83:14
| |
LL | if let .0... = 0 {} LL | if let .0... = 0 {}
| ^^^ | ^^^ help: use `..` instead
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: float literals must have an integer part error: float literals must have an integer part
--> $DIR/recover-range-pats.rs:93:15 --> $DIR/recover-range-pats.rs:93:15
@ -128,33 +128,66 @@ error: float literals must have an integer part
LL | if let ..=.0 = 0 {} LL | if let ..=.0 = 0 {}
| ^^ help: must have an integer part: `0.0` | ^^ help: must have an integer part: `0.0`
error: range-to patterns with `...` are not allowed
--> $DIR/recover-range-pats.rs:109:12
|
LL | if let ...3 = 0 {}
| ^^^ help: use `..=` instead
error: range-to patterns with `...` are not allowed
--> $DIR/recover-range-pats.rs:111:12
|
LL | if let ...Y = 0 {}
| ^^^ help: use `..=` instead
error: range-to patterns with `...` are not allowed
--> $DIR/recover-range-pats.rs:113:12
|
LL | if let ...true = 0 {}
| ^^^ help: use `..=` instead
error: float literals must have an integer part error: float literals must have an integer part
--> $DIR/recover-range-pats.rs:116:15 --> $DIR/recover-range-pats.rs:116:15
| |
LL | if let ....3 = 0 {} LL | if let ....3 = 0 {}
| ^^ help: must have an integer part: `0.3` | ^^ help: must have an integer part: `0.3`
error: range-to patterns with `...` are not allowed
--> $DIR/recover-range-pats.rs:116:12
|
LL | if let ....3 = 0 {}
| ^^^ help: use `..=` instead
error: range-to patterns with `...` are not allowed
--> $DIR/recover-range-pats.rs:137:17
|
LL | let ...$e;
| ^^^ help: use `..=` instead
...
LL | mac!(0);
| -------- in this macro invocation
error[E0586]: inclusive range with no end error[E0586]: inclusive range with no end
--> $DIR/recover-range-pats.rs:141:19 --> $DIR/recover-range-pats.rs:141:19
| |
LL | let $e...; LL | let $e...;
| ^^^ | ^^^ help: use `..` instead
... ...
LL | mac!(0); LL | mac!(0);
| -------- in this macro invocation | -------- in this macro invocation
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error[E0586]: inclusive range with no end error[E0586]: inclusive range with no end
--> $DIR/recover-range-pats.rs:142:19 --> $DIR/recover-range-pats.rs:142:19
| |
LL | let $e..=; LL | let $e..=;
| ^^^ | ^^^ help: use `..` instead
... ...
LL | mac!(0); LL | mac!(0);
| -------- in this macro invocation | -------- in this macro invocation
| |
= help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
error: `...` range patterns are deprecated error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:42:13 --> $DIR/recover-range-pats.rs:42:13
@ -210,30 +243,6 @@ error: `...` range patterns are deprecated
LL | if let X... .0 = 0 {} LL | if let X... .0 = 0 {}
| ^^^ help: use `..=` for an inclusive range | ^^^ help: use `..=` for an inclusive range
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:109:12
|
LL | if let ...3 = 0 {}
| ^^^ help: use `..=` for an inclusive range
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:111:12
|
LL | if let ...Y = 0 {}
| ^^^ help: use `..=` for an inclusive range
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:113:12
|
LL | if let ...true = 0 {}
| ^^^ help: use `..=` for an inclusive range
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:116:12
|
LL | if let ....3 = 0 {}
| ^^^ help: use `..=` for an inclusive range
error: `...` range patterns are deprecated error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:126:20 --> $DIR/recover-range-pats.rs:126:20
| |
@ -243,15 +252,6 @@ LL | let $e1...$e2;
LL | mac2!(0, 1); LL | mac2!(0, 1);
| ------------ in this macro invocation | ------------ in this macro invocation
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:137:17
|
LL | let ...$e;
| ^^^ help: use `..=` for an inclusive range
...
LL | mac!(0);
| -------- in this macro invocation
error[E0029]: only char and numeric types are allowed in range patterns error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:20:12 --> $DIR/recover-range-pats.rs:20:12
| |