Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature gate or patterns in const contexts
- Loading branch information
1 parent
58a6a20
commit f1758a0
Showing
3 changed files
with
110 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#![feature(or_patterns)] | ||
#![allow(incomplete_features)] | ||
|
||
const fn foo((Ok(a) | Err(a)): Result<i32, i32>) { | ||
//~^ ERROR or-pattern is not allowed in a `const fn` | ||
let x = Ok(3); | ||
let Ok(y) | Err(y) = x; | ||
//~^ ERROR or-pattern is not allowed in a `const fn` | ||
} | ||
|
||
const X: () = { | ||
let x = Ok(3); | ||
let Ok(y) | Err(y) = x; | ||
//~^ ERROR or-pattern is not allowed in a `const` | ||
}; | ||
|
||
static Y: () = { | ||
let x = Ok(3); | ||
let Ok(y) | Err(y) = x; | ||
//~^ ERROR or-pattern is not allowed in a `static` | ||
}; | ||
|
||
static mut Z: () = { | ||
let x = Ok(3); | ||
let Ok(y) | Err(y) = x; | ||
//~^ ERROR or-pattern is not allowed in a `static mut` | ||
}; | ||
|
||
fn main() { | ||
let _: [(); { | ||
let x = Ok(3); | ||
let Ok(y) | Err(y) = x; | ||
//~^ ERROR or-pattern is not allowed in a `const` | ||
2 | ||
}]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
error[E0658]: or-pattern is not allowed in a `const fn` | ||
--> $DIR/feature-gate-const-fn.rs:4:15 | ||
| | ||
LL | const fn foo((Ok(a) | Err(a)): Result<i32, i32>) { | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/49146 | ||
= help: add `#![feature(const_if_match)]` to the crate attributes to enable | ||
|
||
error[E0658]: or-pattern is not allowed in a `const fn` | ||
--> $DIR/feature-gate-const-fn.rs:7:9 | ||
| | ||
LL | let Ok(y) | Err(y) = x; | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/49146 | ||
= help: add `#![feature(const_if_match)]` to the crate attributes to enable | ||
|
||
error[E0658]: or-pattern is not allowed in a `const` | ||
--> $DIR/feature-gate-const-fn.rs:13:9 | ||
| | ||
LL | let Ok(y) | Err(y) = x; | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/49146 | ||
= help: add `#![feature(const_if_match)]` to the crate attributes to enable | ||
|
||
error[E0658]: or-pattern is not allowed in a `static` | ||
--> $DIR/feature-gate-const-fn.rs:19:9 | ||
| | ||
LL | let Ok(y) | Err(y) = x; | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/49146 | ||
= help: add `#![feature(const_if_match)]` to the crate attributes to enable | ||
|
||
error[E0658]: or-pattern is not allowed in a `static mut` | ||
--> $DIR/feature-gate-const-fn.rs:25:9 | ||
| | ||
LL | let Ok(y) | Err(y) = x; | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/49146 | ||
= help: add `#![feature(const_if_match)]` to the crate attributes to enable | ||
|
||
error[E0658]: or-pattern is not allowed in a `const` | ||
--> $DIR/feature-gate-const-fn.rs:32:13 | ||
| | ||
LL | let Ok(y) | Err(y) = x; | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: for more information, see https://github.com/rust-lang/rust/issues/49146 | ||
= help: add `#![feature(const_if_match)]` to the crate attributes to enable | ||
|
||
error: aborting due to 6 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. |