mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-11 16:15:03 +00:00
or-patterns: harden feature gating tests.
This commit is contained in:
parent
d3b3bceffb
commit
1ffea18ddb
@ -1,4 +1,4 @@
|
|||||||
#![crate_type="lib"]
|
fn main() {}
|
||||||
|
|
||||||
pub fn example(x: Option<usize>) {
|
pub fn example(x: Option<usize>) {
|
||||||
match x {
|
match x {
|
||||||
@ -7,3 +7,48 @@ pub fn example(x: Option<usize>) {
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test the `pat` macro fragment parser:
|
||||||
|
macro_rules! accept_pat {
|
||||||
|
($p:pat) => {}
|
||||||
|
}
|
||||||
|
|
||||||
|
accept_pat!((p | q)); //~ ERROR or-patterns syntax is experimental
|
||||||
|
accept_pat!((p | q,)); //~ ERROR or-patterns syntax is experimental
|
||||||
|
accept_pat!(TS(p | q)); //~ ERROR or-patterns syntax is experimental
|
||||||
|
accept_pat!(NS { f: p | q }); //~ ERROR or-patterns syntax is experimental
|
||||||
|
accept_pat!([p | q]); //~ ERROR or-patterns syntax is experimental
|
||||||
|
|
||||||
|
// Non-macro tests:
|
||||||
|
|
||||||
|
#[cfg(FALSE)]
|
||||||
|
fn or_patterns() {
|
||||||
|
// Gated:
|
||||||
|
|
||||||
|
let | A | B; //~ ERROR or-patterns syntax is experimental
|
||||||
|
//~^ ERROR or-patterns syntax is experimental
|
||||||
|
let A | B; //~ ERROR or-patterns syntax is experimental
|
||||||
|
for | A | B in 0 {} //~ ERROR or-patterns syntax is experimental
|
||||||
|
//~^ ERROR or-patterns syntax is experimental
|
||||||
|
for A | B in 0 {} //~ ERROR or-patterns syntax is experimental
|
||||||
|
fn fun((A | B): _) {} //~ ERROR or-patterns syntax is experimental
|
||||||
|
let _ = |(A | B): u8| (); //~ ERROR or-patterns syntax is experimental
|
||||||
|
let (A | B); //~ ERROR or-patterns syntax is experimental
|
||||||
|
let (A | B,); //~ ERROR or-patterns syntax is experimental
|
||||||
|
let A(B | C); //~ ERROR or-patterns syntax is experimental
|
||||||
|
let E::V(B | C); //~ ERROR or-patterns syntax is experimental
|
||||||
|
let S { f1: B | C, f2 }; //~ ERROR or-patterns syntax is experimental
|
||||||
|
let E::V { f1: B | C, f2 }; //~ ERROR or-patterns syntax is experimental
|
||||||
|
let [A | B]; //~ ERROR or-patterns syntax is experimental
|
||||||
|
|
||||||
|
// Top level of `while`, `if`, and `match` arms are allowed:
|
||||||
|
|
||||||
|
while let | A = 0 {}
|
||||||
|
while let A | B = 0 {}
|
||||||
|
if let | A = 0 {}
|
||||||
|
if let A | B = 0 {}
|
||||||
|
match 0 {
|
||||||
|
| A => {},
|
||||||
|
A | B => {},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -7,6 +7,186 @@ LL | Some(0 | 1 | 2) => {}
|
|||||||
= 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
|
||||||
|
|
||||||
error: aborting due to previous error
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:28:9
|
||||||
|
|
|
||||||
|
LL | let | A | B;
|
||||||
|
| ^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:28:11
|
||||||
|
|
|
||||||
|
LL | let | A | B;
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:30:9
|
||||||
|
|
|
||||||
|
LL | let A | B;
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:31:9
|
||||||
|
|
|
||||||
|
LL | for | A | B in 0 {}
|
||||||
|
| ^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:31:11
|
||||||
|
|
|
||||||
|
LL | for | A | B in 0 {}
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:33:9
|
||||||
|
|
|
||||||
|
LL | for A | B in 0 {}
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:34:13
|
||||||
|
|
|
||||||
|
LL | fn fun((A | B): _) {}
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:35:15
|
||||||
|
|
|
||||||
|
LL | let _ = |(A | B): u8| ();
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:36:10
|
||||||
|
|
|
||||||
|
LL | let (A | B);
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:37:10
|
||||||
|
|
|
||||||
|
LL | let (A | B,);
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:38:11
|
||||||
|
|
|
||||||
|
LL | let A(B | C);
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:39:14
|
||||||
|
|
|
||||||
|
LL | let E::V(B | C);
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:40:17
|
||||||
|
|
|
||||||
|
LL | let S { f1: B | C, f2 };
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:41:20
|
||||||
|
|
|
||||||
|
LL | let E::V { f1: B | C, f2 };
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:42:10
|
||||||
|
|
|
||||||
|
LL | let [A | B];
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:16:14
|
||||||
|
|
|
||||||
|
LL | accept_pat!((p | q));
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:17:14
|
||||||
|
|
|
||||||
|
LL | accept_pat!((p | q,));
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:18:16
|
||||||
|
|
|
||||||
|
LL | accept_pat!(TS(p | q));
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:19:21
|
||||||
|
|
|
||||||
|
LL | accept_pat!(NS { f: p | q });
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: or-patterns syntax is experimental
|
||||||
|
--> $DIR/feature-gate-or_patterns.rs:20:14
|
||||||
|
|
|
||||||
|
LL | accept_pat!([p | q]);
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
= note: for more information, see https://github.com/rust-lang/rust/issues/54883
|
||||||
|
= help: add `#![feature(or_patterns)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error: aborting due to 21 previous errors
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0658`.
|
For more information about this error, try `rustc --explain E0658`.
|
||||||
|
Loading…
Reference in New Issue
Block a user