Rollup merge of #62550 - Centril:rest-patterns, r=petrochenkov

Implement RFC 2707 + Parser recovery for range patterns

Implement https://github.com/rust-lang/rfcs/pull/2707.

- Add a new basic syntactic pattern form `ast::PatKind::Rest` (parsed as `..` or `DOTDOT`) and simplify `ast::PatKind::{Slice, Tuple, TupleStruct}` as a result.

- Lower `ast::PatKind::Rest` in combination with the aforementioned `PatKind` variants as well as `PatKind::Ident`. The HIR remains unchanged for now (may be advisable to make slight adjustments later).

- Refactor `parser.rs` wrt. parsing sequences and lists of things in the process.

- Add parser recovery for range patterns of form `X..`, `X..=`, `X...`, `..Y`, `..=Y`, and `...Y`.
   This should make it easy to actually support these patterns semantically later if we so desire.

cc https://github.com/rust-lang/rust/issues/62254

r? @petrochenkov
This commit is contained in:
Mazdak Farrokhzad 2019-07-28 11:11:04 +02:00 committed by GitHub
commit 75e23ff411
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
87 changed files with 1547 additions and 676 deletions

View file

@ -1,7 +1,13 @@
fn main() {
let a = Vec::new();
let a: &[u8] = &[];
match a {
[1, tail.., tail..] => {}, //~ ERROR: expected one of `,` or `@`, found `..`
[1, tail @ .., tail @ ..] => {},
//~^ ERROR identifier `tail` is bound more than once in the same pattern
//~| ERROR subslice patterns are unstable
//~| ERROR subslice patterns are unstable
//~| ERROR `..` can only be used once per slice pattern
_ => ()
}
}
const RECOVERY_WITNESS: () = 0; //~ ERROR mismatched types

View file

@ -1,8 +1,45 @@
error: expected one of `,` or `@`, found `..`
--> $DIR/match-vec-invalid.rs:4:25
error[E0416]: identifier `tail` is bound more than once in the same pattern
--> $DIR/match-vec-invalid.rs:4:24
|
LL | [1, tail.., tail..] => {},
| ^^ expected one of `,` or `@` here
LL | [1, tail @ .., tail @ ..] => {},
| ^^^^ used in a pattern more than once
error: aborting due to previous error
error[E0658]: subslice patterns are unstable
--> $DIR/match-vec-invalid.rs:4:13
|
LL | [1, tail @ .., tail @ ..] => {},
| ^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/62254
= help: add `#![feature(slice_patterns)]` to the crate attributes to enable
error[E0658]: subslice patterns are unstable
--> $DIR/match-vec-invalid.rs:4:24
|
LL | [1, tail @ .., tail @ ..] => {},
| ^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/62254
= help: add `#![feature(slice_patterns)]` to the crate attributes to enable
error: `..` can only be used once per slice pattern
--> $DIR/match-vec-invalid.rs:4:31
|
LL | [1, tail @ .., tail @ ..] => {},
| -- ^^ can only be used once per slice pattern
| |
| previously used here
error[E0308]: mismatched types
--> $DIR/match-vec-invalid.rs:13:30
|
LL | const RECOVERY_WITNESS: () = 0;
| ^ expected (), found integer
|
= note: expected type `()`
found type `{integer}`
error: aborting due to 5 previous errors
Some errors have detailed explanations: E0308, E0416, E0658.
For more information about an error, try `rustc --explain E0308`.

View file

@ -1,3 +1,9 @@
fn main() {
struct Test(&'static u8, [u8; 0]);
let x = Test(&0, []);
let Test(&desc[..]) = x; //~ ERROR: expected one of `)`, `,`, or `@`, found `[`
//~^ ERROR subslice patterns are unstable
}
const RECOVERY_WITNESS: () = 0; //~ ERROR mismatched types

View file

@ -1,8 +1,28 @@
error: expected one of `)`, `,`, or `@`, found `[`
--> $DIR/pat-lt-bracket-6.rs:2:19
--> $DIR/pat-lt-bracket-6.rs:5:19
|
LL | let Test(&desc[..]) = x;
| ^ expected one of `)`, `,`, or `@` here
error: aborting due to previous error
error[E0658]: subslice patterns are unstable
--> $DIR/pat-lt-bracket-6.rs:5:20
|
LL | let Test(&desc[..]) = x;
| ^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/62254
= help: add `#![feature(slice_patterns)]` to the crate attributes to enable
error[E0308]: mismatched types
--> $DIR/pat-lt-bracket-6.rs:9:30
|
LL | const RECOVERY_WITNESS: () = 0;
| ^ expected (), found integer
|
= note: expected type `()`
found type `{integer}`
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0308, E0658.
For more information about an error, try `rustc --explain E0308`.

View file

@ -1,3 +1,8 @@
fn main() {
for thing(x[]) in foo {} //~ ERROR: expected one of `)`, `,`, or `@`, found `[`
struct Thing(u8, [u8; 0]);
let foo = core::iter::empty();
for Thing(x[]) in foo {} //~ ERROR: expected one of `)`, `,`, or `@`, found `[`
}
const RECOVERY_WITNESS: () = 0; //~ ERROR mismatched types

View file

@ -1,8 +1,18 @@
error: expected one of `)`, `,`, or `@`, found `[`
--> $DIR/pat-lt-bracket-7.rs:2:16
--> $DIR/pat-lt-bracket-7.rs:5:16
|
LL | for thing(x[]) in foo {}
LL | for Thing(x[]) in foo {}
| ^ expected one of `)`, `,`, or `@` here
error: aborting due to previous error
error[E0308]: mismatched types
--> $DIR/pat-lt-bracket-7.rs:8:30
|
LL | const RECOVERY_WITNESS: () = 0;
| ^ expected (), found integer
|
= note: expected type `()`
found type `{integer}`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.

View file

@ -1,6 +1,7 @@
// check-pass
fn main() {
match (0, 1, 2) {
(pat, ..,) => {}
//~^ ERROR trailing comma is not permitted after `..`
}
}

View file

@ -1,8 +0,0 @@
error: trailing comma is not permitted after `..`
--> $DIR/pat-tuple-2.rs:3:17
|
LL | (pat, ..,) => {}
| ^ trailing comma is not permitted after `..`
error: aborting due to previous error

View file

@ -1,6 +1,6 @@
fn main() {
match (0, 1, 2) {
(.., pat, ..) => {}
//~^ ERROR `..` can only be used once per tuple or tuple struct pattern
//~^ ERROR `..` can only be used once per tuple pattern
}
}

View file

@ -1,10 +1,10 @@
error: `..` can only be used once per tuple or tuple struct pattern
error: `..` can only be used once per tuple pattern
--> $DIR/pat-tuple-3.rs:3:19
|
LL | (.., pat, ..) => {}
| -- ^^ can only be used once per pattern
| -- ^^ can only be used once per tuple pattern
| |
| previously present here
| previously used here
error: aborting due to previous error

View file

@ -1,5 +1,11 @@
fn main() {
const PAT: u8 = 0;
match 0 {
(.. pat) => {} //~ ERROR expected one of `)` or `,`, found `pat`
(.. PAT) => {}
//~^ ERROR `..X` range patterns are not supported
//~| ERROR exclusive range pattern syntax is experimental
}
}
const RECOVERY_WITNESS: () = 0; //~ ERROR mismatched types

View file

@ -1,8 +1,28 @@
error: expected one of `)` or `,`, found `pat`
--> $DIR/pat-tuple-4.rs:3:13
error: `..X` range patterns are not supported
--> $DIR/pat-tuple-4.rs:5:10
|
LL | (.. pat) => {}
| ^^^ expected one of `)` or `,` here
LL | (.. PAT) => {}
| ^^^^^^ help: try using the minimum value for the type: `MIN..PAT`
error: aborting due to previous error
error[E0658]: exclusive range pattern syntax is experimental
--> $DIR/pat-tuple-4.rs:5:10
|
LL | (.. PAT) => {}
| ^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/37854
= help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
error[E0308]: mismatched types
--> $DIR/pat-tuple-4.rs:11:30
|
LL | const RECOVERY_WITNESS: () = 0;
| ^ expected (), found integer
|
= note: expected type `()`
found type `{integer}`
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0308, E0658.
For more information about an error, try `rustc --explain E0308`.

View file

@ -1,5 +1,10 @@
fn main() {
const PAT: u8 = 0;
match (0, 1) {
(pat ..) => {} //~ ERROR unexpected token: `)`
(PAT ..) => {}
//~^ ERROR `X..` range patterns are not supported
//~| ERROR exclusive range pattern syntax is experimental
//~| ERROR mismatched types
}
}

View file

@ -1,8 +1,30 @@
error: unexpected token: `)`
--> $DIR/pat-tuple-5.rs:3:16
error: `X..` range patterns are not supported
--> $DIR/pat-tuple-5.rs:5:10
|
LL | (pat ..) => {}
| ^
LL | (PAT ..) => {}
| ^^^^^^ help: try using the maximum value for the type: `PAT..MAX`
error: aborting due to previous error
error[E0658]: exclusive range pattern syntax is experimental
--> $DIR/pat-tuple-5.rs:5:10
|
LL | (PAT ..) => {}
| ^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/37854
= help: add `#![feature(exclusive_range_pattern)]` to the crate attributes to enable
error[E0308]: mismatched types
--> $DIR/pat-tuple-5.rs:5:10
|
LL | match (0, 1) {
| ------ this match expression has type `({integer}, {integer})`
LL | (PAT ..) => {}
| ^^^^^^ expected tuple, found u8
|
= note: expected type `({integer}, {integer})`
found type `u8`
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0308, E0658.
For more information about an error, try `rustc --explain E0308`.

View file

@ -0,0 +1,123 @@
// Here we test all kinds of range patterns in terms of parsing / recovery.
// We want to ensure that:
// 1. Things parse as they should.
// 2. Or at least we have parser recovery if they don't.
#![feature(exclusive_range_pattern)]
#![deny(ellipsis_inclusive_range_patterns)]
fn main() {}
const X: u8 = 0;
const Y: u8 = 3;
fn exclusive_from_to() {
if let 0..3 = 0 {} // OK.
if let 0..Y = 0 {} // OK.
if let X..3 = 0 {} // OK.
if let X..Y = 0 {} // OK.
if let true..Y = 0 {} //~ ERROR only char and numeric types
if let X..true = 0 {} //~ ERROR only char and numeric types
if let .0..Y = 0 {} //~ ERROR mismatched types
//~^ ERROR float literals must have an integer part
if let X.. .0 = 0 {} //~ ERROR mismatched types
//~^ ERROR float literals must have an integer part
}
fn inclusive_from_to() {
if let 0..=3 = 0 {} // OK.
if let 0..=Y = 0 {} // OK.
if let X..=3 = 0 {} // OK.
if let X..=Y = 0 {} // OK.
if let true..=Y = 0 {} //~ ERROR only char and numeric types
if let X..=true = 0 {} //~ ERROR only char and numeric types
if let .0..=Y = 0 {} //~ ERROR mismatched types
//~^ ERROR float literals must have an integer part
if let X..=.0 = 0 {} //~ ERROR mismatched types
//~^ ERROR float literals must have an integer part
}
fn inclusive2_from_to() {
if let 0...3 = 0 {} //~ ERROR `...` range patterns are deprecated
if let 0...Y = 0 {} //~ ERROR `...` range patterns are deprecated
if let X...3 = 0 {} //~ ERROR `...` range patterns are deprecated
if let X...Y = 0 {} //~ ERROR `...` range patterns are deprecated
if let true...Y = 0 {} //~ ERROR only char and numeric types
//~^ ERROR `...` range patterns are deprecated
if let X...true = 0 {} //~ ERROR only char and numeric types
//~^ ERROR `...` range patterns are deprecated
if let .0...Y = 0 {} //~ ERROR mismatched types
//~^ ERROR float literals must have an integer part
//~| ERROR `...` range patterns are deprecated
if let X... .0 = 0 {} //~ ERROR mismatched types
//~^ ERROR float literals must have an integer part
//~| ERROR `...` range patterns are deprecated
}
fn exclusive_from() {
if let 0.. = 0 {} //~ ERROR `X..` range patterns are not supported
if let X.. = 0 {} //~ ERROR `X..` range patterns are not supported
if let true.. = 0 {} //~ ERROR `X..` range patterns are not supported
//~^ ERROR only char and numeric types
if let .0.. = 0 {} //~ ERROR `X..` range patterns are not supported
//~^ ERROR float literals must have an integer part
//~| ERROR mismatched types
}
fn inclusive_from() {
if let 0..= = 0 {} //~ ERROR `X..=` range patterns are not supported
if let X..= = 0 {} //~ ERROR `X..=` range patterns are not supported
if let true..= = 0 {} //~ ERROR `X..=` range patterns are not supported
//~| ERROR only char and numeric types
if let .0..= = 0 {} //~ ERROR `X..=` range patterns are not supported
//~^ ERROR float literals must have an integer part
//~| ERROR mismatched types
}
fn inclusive2_from() {
if let 0... = 0 {} //~ ERROR `X...` range patterns are not supported
//~^ ERROR `...` range patterns are deprecated
if let X... = 0 {} //~ ERROR `X...` range patterns are not supported
//~^ ERROR `...` range patterns are deprecated
if let true... = 0 {} //~ ERROR `X...` range patterns are not supported
//~^ ERROR `...` range patterns are deprecated
//~| ERROR only char and numeric types
if let .0... = 0 {} //~ ERROR `X...` range patterns are not supported
//~^ ERROR float literals must have an integer part
//~| ERROR `...` range patterns are deprecated
//~| ERROR mismatched types
}
fn exclusive_to() {
if let ..0 = 0 {} //~ ERROR `..X` range patterns are not supported
if let ..Y = 0 {} //~ ERROR `..X` range patterns are not supported
if let ..true = 0 {} //~ ERROR `..X` range patterns are not supported
//~| ERROR only char and numeric types
if let .. .0 = 0 {} //~ ERROR `..X` range patterns are not supported
//~^ ERROR float literals must have an integer part
//~| ERROR mismatched types
}
fn inclusive_to() {
if let ..=3 = 0 {} //~ ERROR `..=X` range patterns are not supported
if let ..=Y = 0 {} //~ ERROR `..=X` range patterns are not supported
if let ..=true = 0 {} //~ ERROR `..=X` range patterns are not supported
//~| ERROR only char and numeric types
if let ..=.0 = 0 {} //~ ERROR `..=X` range patterns are not supported
//~^ ERROR float literals must have an integer part
//~| ERROR mismatched types
}
fn inclusive2_to() {
if let ...3 = 0 {} //~ ERROR `...X` range patterns are not supported
//~^ ERROR `...` range patterns are deprecated
if let ...Y = 0 {} //~ ERROR `...X` range patterns are not supported
//~^ ERROR `...` range patterns are deprecated
if let ...true = 0 {} //~ ERROR `...X` range patterns are not supported
//~^ ERROR `...` range patterns are deprecated
//~| ERROR only char and numeric types
if let ....3 = 0 {} //~ ERROR `...X` range patterns are not supported
//~^ ERROR float literals must have an integer part
//~| ERROR `...` range patterns are deprecated
//~| ERROR mismatched types
}

View file

@ -0,0 +1,538 @@
error: float literals must have an integer part
--> $DIR/recover-range-pats.rs:21:12
|
LL | if let .0..Y = 0 {}
| ^^ help: must have an integer part: `0.0`
error: float literals must have an integer part
--> $DIR/recover-range-pats.rs:23:16
|
LL | if let X.. .0 = 0 {}
| ^^ help: must have an integer part: `0.0`
error: float literals must have an integer part
--> $DIR/recover-range-pats.rs:34:12
|
LL | if let .0..=Y = 0 {}
| ^^ help: must have an integer part: `0.0`
error: float literals must have an integer part
--> $DIR/recover-range-pats.rs:36:16
|
LL | if let X..=.0 = 0 {}
| ^^ help: must have an integer part: `0.0`
error: float literals must have an integer part
--> $DIR/recover-range-pats.rs:49:12
|
LL | if let .0...Y = 0 {}
| ^^ help: must have an integer part: `0.0`
error: float literals must have an integer part
--> $DIR/recover-range-pats.rs:52:17
|
LL | if let X... .0 = 0 {}
| ^^ help: must have an integer part: `0.0`
error: `X..` range patterns are not supported
--> $DIR/recover-range-pats.rs:58:12
|
LL | if let 0.. = 0 {}
| ^^^ help: try using the maximum value for the type: `0..MAX`
error: `X..` range patterns are not supported
--> $DIR/recover-range-pats.rs:59:12
|
LL | if let X.. = 0 {}
| ^^^ help: try using the maximum value for the type: `X..MAX`
error: `X..` range patterns are not supported
--> $DIR/recover-range-pats.rs:60:12
|
LL | if let true.. = 0 {}
| ^^^^^^ help: try using the maximum value for the type: `true..MAX`
error: float literals must have an integer part
--> $DIR/recover-range-pats.rs:62:12
|
LL | if let .0.. = 0 {}
| ^^ help: must have an integer part: `0.0`
error: `X..` range patterns are not supported
--> $DIR/recover-range-pats.rs:62:12
|
LL | if let .0.. = 0 {}
| ^^^^ help: try using the maximum value for the type: `0.0..MAX`
error: `X..=` range patterns are not supported
--> $DIR/recover-range-pats.rs:68:12
|
LL | if let 0..= = 0 {}
| ^^^^ help: try using the maximum value for the type: `0..=MAX`
error: `X..=` range patterns are not supported
--> $DIR/recover-range-pats.rs:69:12
|
LL | if let X..= = 0 {}
| ^^^^ help: try using the maximum value for the type: `X..=MAX`
error: `X..=` range patterns are not supported
--> $DIR/recover-range-pats.rs:70:12
|
LL | if let true..= = 0 {}
| ^^^^^^^ help: try using the maximum value for the type: `true..=MAX`
error: float literals must have an integer part
--> $DIR/recover-range-pats.rs:72:12
|
LL | if let .0..= = 0 {}
| ^^ help: must have an integer part: `0.0`
error: `X..=` range patterns are not supported
--> $DIR/recover-range-pats.rs:72:12
|
LL | if let .0..= = 0 {}
| ^^^^^ help: try using the maximum value for the type: `0.0..=MAX`
error: `X...` range patterns are not supported
--> $DIR/recover-range-pats.rs:78:12
|
LL | if let 0... = 0 {}
| ^^^^ help: try using the maximum value for the type: `0...MAX`
error: `X...` range patterns are not supported
--> $DIR/recover-range-pats.rs:80:12
|
LL | if let X... = 0 {}
| ^^^^ help: try using the maximum value for the type: `X...MAX`
error: `X...` range patterns are not supported
--> $DIR/recover-range-pats.rs:82:12
|
LL | if let true... = 0 {}
| ^^^^^^^ help: try using the maximum value for the type: `true...MAX`
error: float literals must have an integer part
--> $DIR/recover-range-pats.rs:85:12
|
LL | if let .0... = 0 {}
| ^^ help: must have an integer part: `0.0`
error: `X...` range patterns are not supported
--> $DIR/recover-range-pats.rs:85:12
|
LL | if let .0... = 0 {}
| ^^^^^ help: try using the maximum value for the type: `0.0...MAX`
error: `..X` range patterns are not supported
--> $DIR/recover-range-pats.rs:92:12
|
LL | if let ..0 = 0 {}
| ^^^ help: try using the minimum value for the type: `MIN..0`
error: `..X` range patterns are not supported
--> $DIR/recover-range-pats.rs:93:12
|
LL | if let ..Y = 0 {}
| ^^^ help: try using the minimum value for the type: `MIN..Y`
error: `..X` range patterns are not supported
--> $DIR/recover-range-pats.rs:94:12
|
LL | if let ..true = 0 {}
| ^^^^^^ help: try using the minimum value for the type: `MIN..true`
error: float literals must have an integer part
--> $DIR/recover-range-pats.rs:96:15
|
LL | if let .. .0 = 0 {}
| ^^ help: must have an integer part: `0.0`
error: `..X` range patterns are not supported
--> $DIR/recover-range-pats.rs:96:12
|
LL | if let .. .0 = 0 {}
| ^^^^^ help: try using the minimum value for the type: `MIN..0.0`
error: `..=X` range patterns are not supported
--> $DIR/recover-range-pats.rs:102:12
|
LL | if let ..=3 = 0 {}
| ^^^^ help: try using the minimum value for the type: `MIN..=3`
error: `..=X` range patterns are not supported
--> $DIR/recover-range-pats.rs:103:12
|
LL | if let ..=Y = 0 {}
| ^^^^ help: try using the minimum value for the type: `MIN..=Y`
error: `..=X` range patterns are not supported
--> $DIR/recover-range-pats.rs:104:12
|
LL | if let ..=true = 0 {}
| ^^^^^^^ help: try using the minimum value for the type: `MIN..=true`
error: float literals must have an integer part
--> $DIR/recover-range-pats.rs:106:15
|
LL | if let ..=.0 = 0 {}
| ^^ help: must have an integer part: `0.0`
error: `..=X` range patterns are not supported
--> $DIR/recover-range-pats.rs:106:12
|
LL | if let ..=.0 = 0 {}
| ^^^^^ help: try using the minimum value for the type: `MIN..=0.0`
error: `...X` range patterns are not supported
--> $DIR/recover-range-pats.rs:112:12
|
LL | if let ...3 = 0 {}
| ^^^^ help: try using the minimum value for the type: `MIN...3`
error: `...X` range patterns are not supported
--> $DIR/recover-range-pats.rs:114:12
|
LL | if let ...Y = 0 {}
| ^^^^ help: try using the minimum value for the type: `MIN...Y`
error: `...X` range patterns are not supported
--> $DIR/recover-range-pats.rs:116:12
|
LL | if let ...true = 0 {}
| ^^^^^^^ help: try using the minimum value for the type: `MIN...true`
error: float literals must have an integer part
--> $DIR/recover-range-pats.rs:119:15
|
LL | if let ....3 = 0 {}
| ^^ help: must have an integer part: `0.3`
error: `...X` range patterns are not supported
--> $DIR/recover-range-pats.rs:119:12
|
LL | if let ....3 = 0 {}
| ^^^^^ help: try using the minimum value for the type: `MIN...0.3`
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:41:13
|
LL | if let 0...3 = 0 {}
| ^^^ help: use `..=` for an inclusive range
|
note: lint level defined here
--> $DIR/recover-range-pats.rs:7:9
|
LL | #![deny(ellipsis_inclusive_range_patterns)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:42:13
|
LL | if let 0...Y = 0 {}
| ^^^ help: use `..=` for an inclusive range
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:43:13
|
LL | if let X...3 = 0 {}
| ^^^ help: use `..=` for an inclusive range
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:44:13
|
LL | if let X...Y = 0 {}
| ^^^ help: use `..=` for an inclusive range
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:45:16
|
LL | if let true...Y = 0 {}
| ^^^ help: use `..=` for an inclusive range
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:47:13
|
LL | if let X...true = 0 {}
| ^^^ help: use `..=` for an inclusive range
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:49:14
|
LL | if let .0...Y = 0 {}
| ^^^ help: use `..=` for an inclusive range
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:52:13
|
LL | if let X... .0 = 0 {}
| ^^^ help: use `..=` for an inclusive range
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:78:13
|
LL | if let 0... = 0 {}
| ^^^ help: use `..=` for an inclusive range
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:80:13
|
LL | if let X... = 0 {}
| ^^^ help: use `..=` for an inclusive range
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:82:16
|
LL | if let true... = 0 {}
| ^^^ help: use `..=` for an inclusive range
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:85:14
|
LL | if let .0... = 0 {}
| ^^^ help: use `..=` for an inclusive range
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:112:12
|
LL | if let ...3 = 0 {}
| ^^^ help: use `..=` for an inclusive range
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:114:12
|
LL | if let ...Y = 0 {}
| ^^^ help: use `..=` for an inclusive range
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:116:12
|
LL | if let ...true = 0 {}
| ^^^ help: use `..=` for an inclusive range
error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:119:12
|
LL | if let ....3 = 0 {}
| ^^^ help: use `..=` for an inclusive range
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:19:12
|
LL | if let true..Y = 0 {}
| ^^^^ ranges require char or numeric types
|
= note: start type: bool
= note: end type: u8
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:20:15
|
LL | if let X..true = 0 {}
| ^^^^ ranges require char or numeric types
|
= note: start type: u8
= note: end type: bool
error[E0308]: mismatched types
--> $DIR/recover-range-pats.rs:21:12
|
LL | if let .0..Y = 0 {}
| ^^^^^ expected integer, found floating-point number
|
= note: expected type `{integer}`
found type `{float}`
error[E0308]: mismatched types
--> $DIR/recover-range-pats.rs:23:12
|
LL | if let X.. .0 = 0 {}
| ^^^^^^ expected integer, found floating-point number
|
= note: expected type `u8`
found type `{float}`
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:32:12
|
LL | if let true..=Y = 0 {}
| ^^^^ ranges require char or numeric types
|
= note: start type: bool
= note: end type: u8
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:33:16
|
LL | if let X..=true = 0 {}
| ^^^^ ranges require char or numeric types
|
= note: start type: u8
= note: end type: bool
error[E0308]: mismatched types
--> $DIR/recover-range-pats.rs:34:12
|
LL | if let .0..=Y = 0 {}
| ^^^^^^ expected integer, found floating-point number
|
= note: expected type `{integer}`
found type `{float}`
error[E0308]: mismatched types
--> $DIR/recover-range-pats.rs:36:12
|
LL | if let X..=.0 = 0 {}
| ^^^^^^ expected integer, found floating-point number
|
= note: expected type `u8`
found type `{float}`
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:45:12
|
LL | if let true...Y = 0 {}
| ^^^^ ranges require char or numeric types
|
= note: start type: bool
= note: end type: u8
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:47:16
|
LL | if let X...true = 0 {}
| ^^^^ ranges require char or numeric types
|
= note: start type: u8
= note: end type: bool
error[E0308]: mismatched types
--> $DIR/recover-range-pats.rs:49:12
|
LL | if let .0...Y = 0 {}
| ^^^^^^ expected integer, found floating-point number
|
= note: expected type `{integer}`
found type `{float}`
error[E0308]: mismatched types
--> $DIR/recover-range-pats.rs:52:12
|
LL | if let X... .0 = 0 {}
| ^^^^^^^ expected integer, found floating-point number
|
= note: expected type `u8`
found type `{float}`
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:60:12
|
LL | if let true.. = 0 {}
| ^^^^ ranges require char or numeric types
|
= note: start type: bool
= note: end type: [type error]
error[E0308]: mismatched types
--> $DIR/recover-range-pats.rs:62:12
|
LL | if let .0.. = 0 {}
| ^^^^ expected integer, found floating-point number
|
= note: expected type `{integer}`
found type `{float}`
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:70:12
|
LL | if let true..= = 0 {}
| ^^^^ ranges require char or numeric types
|
= note: start type: bool
= note: end type: [type error]
error[E0308]: mismatched types
--> $DIR/recover-range-pats.rs:72:12
|
LL | if let .0..= = 0 {}
| ^^^^^ expected integer, found floating-point number
|
= note: expected type `{integer}`
found type `{float}`
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:82:12
|
LL | if let true... = 0 {}
| ^^^^ ranges require char or numeric types
|
= note: start type: bool
= note: end type: [type error]
error[E0308]: mismatched types
--> $DIR/recover-range-pats.rs:85:12
|
LL | if let .0... = 0 {}
| ^^^^^ expected integer, found floating-point number
|
= note: expected type `{integer}`
found type `{float}`
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:94:14
|
LL | if let ..true = 0 {}
| ^^^^ ranges require char or numeric types
|
= note: start type: [type error]
= note: end type: bool
error[E0308]: mismatched types
--> $DIR/recover-range-pats.rs:96:12
|
LL | if let .. .0 = 0 {}
| ^^^^^ expected integer, found floating-point number
|
= note: expected type `{integer}`
found type `{float}`
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:104:15
|
LL | if let ..=true = 0 {}
| ^^^^ ranges require char or numeric types
|
= note: start type: [type error]
= note: end type: bool
error[E0308]: mismatched types
--> $DIR/recover-range-pats.rs:106:12
|
LL | if let ..=.0 = 0 {}
| ^^^^^ expected integer, found floating-point number
|
= note: expected type `{integer}`
found type `{float}`
error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:116:15
|
LL | if let ...true = 0 {}
| ^^^^ ranges require char or numeric types
|
= note: start type: [type error]
= note: end type: bool
error[E0308]: mismatched types
--> $DIR/recover-range-pats.rs:119:12
|
LL | if let ....3 = 0 {}
| ^^^^^ expected integer, found floating-point number
|
= note: expected type `{integer}`
found type `{float}`
error: aborting due to 76 previous errors
Some errors have detailed explanations: E0029, E0308.
For more information about an error, try `rustc --explain E0029`.

View file

@ -1,12 +1,12 @@
// NOTE: This doesn't recover anymore.
fn main() {
let x = (1, 2, 3, 4);
match x {
(1, .., 4) => {}
(1, .=., 4) => { let _: usize = ""; }
//~^ ERROR expected pattern, found `.`
//~| ERROR mismatched types
(.=., 4) => {}
//~^ ERROR expected pattern, found `.`
(1, 2, 3, 4) => {}
}
}

View file

@ -1,24 +1,8 @@
error: expected pattern, found `.`
--> $DIR/recover-tuple-pat.rs:5:13
--> $DIR/recover-tuple-pat.rs:7:13
|
LL | (1, .=., 4) => { let _: usize = ""; }
| ^ expected pattern
error: expected pattern, found `.`
--> $DIR/recover-tuple-pat.rs:8:10
|
LL | (.=., 4) => {}
| ^ expected pattern
error: aborting due to previous error
error[E0308]: mismatched types
--> $DIR/recover-tuple-pat.rs:5:41
|
LL | (1, .=., 4) => { let _: usize = ""; }
| ^^ expected usize, found reference
|
= note: expected type `usize`
found type `&'static str`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0308`.