2019-07-09 23:50:54 +00:00
|
|
|
// 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() {
|
2019-07-24 02:01:38 +00:00
|
|
|
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
|
2019-07-09 23:50:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn inclusive_from() {
|
2019-07-24 02:01:38 +00:00
|
|
|
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
|
2019-07-09 23:50:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn inclusive2_from() {
|
2019-07-24 02:01:38 +00:00
|
|
|
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
|
2019-07-09 23:50:54 +00:00
|
|
|
//~| ERROR `...` range patterns are deprecated
|
2019-07-24 02:01:38 +00:00
|
|
|
//~| ERROR mismatched types
|
2019-07-09 23:50:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn exclusive_to() {
|
2019-07-24 02:01:38 +00:00
|
|
|
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
|
2019-07-09 23:50:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn inclusive_to() {
|
2019-07-24 02:01:38 +00:00
|
|
|
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
|
2019-07-09 23:50:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn inclusive2_to() {
|
2019-07-24 02:01:38 +00:00
|
|
|
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
|
2019-07-09 23:50:54 +00:00
|
|
|
//~| ERROR `...` range patterns are deprecated
|
2019-07-24 02:01:38 +00:00
|
|
|
//~| ERROR mismatched types
|
2019-07-09 23:50:54 +00:00
|
|
|
}
|
2019-07-30 02:22:09 +00:00
|
|
|
|
|
|
|
fn with_macro_expr_var() {
|
|
|
|
macro_rules! mac2 {
|
|
|
|
($e1:expr, $e2:expr) => {
|
|
|
|
let $e1..$e2;
|
|
|
|
let $e1...$e2;
|
|
|
|
//~^ ERROR `...` range patterns are deprecated
|
|
|
|
let $e1..=$e2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mac2!(0, 1);
|
|
|
|
|
|
|
|
macro_rules! mac {
|
|
|
|
($e:expr) => {
|
|
|
|
let ..$e; //~ ERROR `..X` range patterns are not supported
|
|
|
|
let ...$e; //~ ERROR `...X` range patterns are not supported
|
|
|
|
//~^ ERROR `...` range patterns are deprecated
|
|
|
|
let ..=$e; //~ ERROR `..=X` range patterns are not supported
|
|
|
|
let $e..; //~ ERROR `X..` range patterns are not supported
|
|
|
|
let $e...; //~ ERROR `X...` range patterns are not supported
|
|
|
|
//~^ ERROR `...` range patterns are deprecated
|
|
|
|
let $e..=; //~ ERROR `X..=` range patterns are not supported
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mac!(0);
|
|
|
|
}
|