-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #88088 - nbdd0121:const2, r=nagisa
Forbid inline const block referencing params from being used in patterns Fix #82518
- Loading branch information
Showing
3 changed files
with
31 additions
and
1 deletion.
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,16 @@ | ||
#![allow(incomplete_features)] | ||
#![feature(inline_const)] | ||
|
||
// rust-lang/rust#82518: ICE with inline-const in match referencing const-generic parameter | ||
|
||
fn foo<const V: usize>() { | ||
match 0 { | ||
const { V } => {}, | ||
//~^ ERROR const parameters cannot be referenced in patterns [E0158] | ||
_ => {}, | ||
} | ||
} | ||
|
||
fn main() { | ||
foo::<1>(); | ||
} |
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,9 @@ | ||
error[E0158]: const parameters cannot be referenced in patterns | ||
--> $DIR/const-match-pat-generic.rs:8:11 | ||
| | ||
LL | const { V } => {}, | ||
| ^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0158`. |