Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions compiler/rustc_parse/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/inline-const/in-pat-recovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {}
_ => {}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/inline-const/in-pat-recovery.stderr
Original file line number Diff line number Diff line change
@@ -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

Loading