Rollup merge of #143589 - RalfJung:const-pat, r=compiler-errors

const-block-as-pattern: do not refer to no-longer-existing nightly feature

Surely everyone who used this nightly feature has fixed their code by now. So let's not confused people on stable that try to use a const block as a pattern by referring to some dead nightly feature.
This commit is contained in:
Matthias Krüger 2025-07-08 03:09:58 +02:00 committed by GitHub
commit 65dded8387
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 5 deletions

View file

@ -1293,8 +1293,10 @@ impl<'a> Parser<'a> {
let kind = if pat {
let guar = self
.dcx()
.struct_span_err(blk_span, "`inline_const_pat` has been removed")
.with_help("use a named `const`-item or an `if`-guard instead")
.struct_span_err(blk_span, "const blocks cannot be used as patterns")
.with_help(
"use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead",
)
.emit();
ExprKind::Err(guar)
} else {

View file

@ -4,7 +4,7 @@
fn main() {
match 1 {
const { 1 + 7 } => {}
//~^ ERROR `inline_const_pat` has been removed
//~^ ERROR const blocks cannot be used as patterns
2 => {}
_ => {}
}

View file

@ -1,10 +1,10 @@
error: `inline_const_pat` has been removed
error: const blocks cannot be used as patterns
--> $DIR/in-pat-recovery.rs:6:15
|
LL | const { 1 + 7 } => {}
| ^^^^^^^^^
|
= help: use a named `const`-item or an `if`-guard instead
= help: use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead
error: aborting due to 1 previous error