Skip to content

Commit 65dded8

Browse files
authored
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.
2 parents 1a45ab1 + 1a6eff7 commit 65dded8

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

compiler/rustc_parse/src/parser/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,8 +1293,10 @@ impl<'a> Parser<'a> {
12931293
let kind = if pat {
12941294
let guar = self
12951295
.dcx()
1296-
.struct_span_err(blk_span, "`inline_const_pat` has been removed")
1297-
.with_help("use a named `const`-item or an `if`-guard instead")
1296+
.struct_span_err(blk_span, "const blocks cannot be used as patterns")
1297+
.with_help(
1298+
"use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead",
1299+
)
12981300
.emit();
12991301
ExprKind::Err(guar)
13001302
} else {

tests/ui/inline-const/in-pat-recovery.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
fn main() {
55
match 1 {
66
const { 1 + 7 } => {}
7-
//~^ ERROR `inline_const_pat` has been removed
7+
//~^ ERROR const blocks cannot be used as patterns
88
2 => {}
99
_ => {}
1010
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error: `inline_const_pat` has been removed
1+
error: const blocks cannot be used as patterns
22
--> $DIR/in-pat-recovery.rs:6:15
33
|
44
LL | const { 1 + 7 } => {}
55
| ^^^^^^^^^
66
|
7-
= help: use a named `const`-item or an `if`-guard instead
7+
= help: use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead
88

99
error: aborting due to 1 previous error
1010

0 commit comments

Comments
 (0)