Skip to content

Commit d4b8fa9

Browse files
committed
remove feature(inline_const_pat)
1 parent 5d85a71 commit d4b8fa9

File tree

53 files changed

+109
-886
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+109
-886
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
483483
half_open_range_patterns_in_slices,
484484
"half-open range patterns in slices are unstable"
485485
);
486-
gate_all!(inline_const_pat, "inline-const in pattern position is experimental");
487486
gate_all!(associated_const_equality, "associated const equality is incomplete");
488487
gate_all!(yeet_expr, "`do yeet` expression is experimental");
489488
gate_all!(dyn_star, "`dyn*` trait objects are experimental");

compiler/rustc_feature/src/removed.rs

+3
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ declare_features! (
142142
/// Allows inferring `'static` outlives requirements (RFC 2093).
143143
(removed, infer_static_outlives_requirements, "1.63.0", Some(54185),
144144
Some("removed as it caused some confusion and discussion was inactive for years")),
145+
/// Allow anonymous constants from an inline `const` block in pattern position
146+
(removed, inline_const_pat, "CURRENT_RUSTC_VERSION", Some(76001),
147+
Some("removed due to implementation concerns as it requires significant refactorings")),
145148
/// Lazily evaluate constants. This allows constants to depend on type parameters.
146149
(removed, lazy_normalization_consts, "1.46.0", Some(72219), Some("superseded by `generic_const_exprs`")),
147150
/// Changes `impl Trait` to capture all lifetimes in scope.

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,6 @@ declare_features! (
531531
(unstable, import_trait_associated_functions, "1.86.0", Some(134691)),
532532
/// Allows associated types in inherent impls.
533533
(incomplete, inherent_associated_types, "1.52.0", Some(8995)),
534-
/// Allow anonymous constants from an inline `const` block in pattern position
535-
(unstable, inline_const_pat, "1.58.0", Some(76001)),
536534
/// Allows using `pointer` and `reference` in intra-doc links
537535
(unstable, intra_doc_pointers, "1.51.0", Some(80896)),
538536
// Allows using the `kl` and `widekl` target features and the associated intrinsics

compiler/rustc_parse/messages.ftl

-2
Original file line numberDiff line numberDiff line change
@@ -842,8 +842,6 @@ parse_unexpected_expr_in_pat_const_sugg = consider extracting the expression int
842842
843843
parse_unexpected_expr_in_pat_create_guard_sugg = consider moving the expression to a match arm guard
844844
845-
parse_unexpected_expr_in_pat_inline_const_sugg = consider wrapping the expression in an inline `const` (requires `{"#"}![feature(inline_const_pat)]`)
846-
847845
parse_unexpected_expr_in_pat_update_guard_sugg = consider moving the expression to the match arm guard
848846
849847
parse_unexpected_if_with_if = unexpected `if` in the condition expression

compiler/rustc_parse/src/errors.rs

-11
Original file line numberDiff line numberDiff line change
@@ -2787,17 +2787,6 @@ pub(crate) enum UnexpectedExpressionInPatternSugg {
27872787
/// The statement's block's indentation.
27882788
indentation: String,
27892789
},
2790-
2791-
#[multipart_suggestion(
2792-
parse_unexpected_expr_in_pat_inline_const_sugg,
2793-
applicability = "maybe-incorrect"
2794-
)]
2795-
InlineConst {
2796-
#[suggestion_part(code = "const {{ ")]
2797-
start_span: Span,
2798-
#[suggestion_part(code = " }}")]
2799-
end_span: Span,
2800-
},
28012790
}
28022791

28032792
#[derive(Diagnostic)]

compiler/rustc_parse/src/parser/mod.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -1370,17 +1370,24 @@ impl<'a> Parser<'a> {
13701370

13711371
/// Parses inline const expressions.
13721372
fn parse_const_block(&mut self, span: Span, pat: bool) -> PResult<'a, P<Expr>> {
1373-
if pat {
1374-
self.psess.gated_spans.gate(sym::inline_const_pat, span);
1375-
}
13761373
self.expect_keyword(exp!(Const))?;
13771374
let (attrs, blk) = self.parse_inner_attrs_and_block(None)?;
13781375
let anon_const = AnonConst {
13791376
id: DUMMY_NODE_ID,
13801377
value: self.mk_expr(blk.span, ExprKind::Block(blk, None)),
13811378
};
13821379
let blk_span = anon_const.value.span;
1383-
Ok(self.mk_expr_with_attrs(span.to(blk_span), ExprKind::ConstBlock(anon_const), attrs))
1380+
let kind = if pat {
1381+
let guar = self
1382+
.dcx()
1383+
.struct_span_err(blk_span, "`inline_const_pat` has been removed")
1384+
.with_help("use a named `const`-item or an `if`-guard instead")
1385+
.emit();
1386+
ExprKind::Err(guar)
1387+
} else {
1388+
ExprKind::ConstBlock(anon_const)
1389+
};
1390+
Ok(self.mk_expr_with_attrs(span.to(blk_span), kind, attrs))
13841391
}
13851392

13861393
/// Parses mutability (`mut` or nothing).

compiler/rustc_parse/src/parser/pat.rs

-9
Original file line numberDiff line numberDiff line change
@@ -631,15 +631,6 @@ impl<'a> Parser<'a> {
631631
ident,
632632
indentation,
633633
});
634-
635-
// help: wrap the expr in a `const { expr }`
636-
// FIXME(inline_const_pat): once stabilized, remove this check and remove the `(requires #[feature(inline_const_pat)])` note from the message
637-
if self.parser.psess.unstable_features.is_nightly_build() {
638-
err.subdiagnostic(UnexpectedExpressionInPatternSugg::InlineConst {
639-
start_span: expr_span.shrink_to_lo(),
640-
end_span: expr_span.shrink_to_hi(),
641-
});
642-
}
643634
},
644635
);
645636
}

src/doc/unstable-book/src/language-features/inline-const-pat.md

-22
This file was deleted.

src/tools/clippy/clippy_lints/src/matches/redundant_guards.rs

-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ fn emit_redundant_guards<'tcx>(
246246
fn expr_can_be_pat(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
247247
for_each_expr_without_closures(expr, |expr| {
248248
if match expr.kind {
249-
ExprKind::ConstBlock(..) => cx.tcx.features().inline_const_pat(),
250249
ExprKind::Call(c, ..) if let ExprKind::Path(qpath) = c.kind => {
251250
// Allow ctors
252251
matches!(cx.qpath_res(&qpath, c.hir_id), Res::Def(DefKind::Ctor(..), ..))

src/tools/tidy/src/issues.txt

-1
Original file line numberDiff line numberDiff line change
@@ -2876,7 +2876,6 @@ ui/macros/rfc-3086-metavar-expr/issue-111904.rs
28762876
ui/malformed/issue-107423-unused-delim-only-one-no-pair.rs
28772877
ui/malformed/issue-69341-malformed-derive-inert.rs
28782878
ui/marker_trait_attr/issue-61651-type-mismatch.rs
2879-
ui/match/issue-112438.rs
28802879
ui/match/issue-113012.rs
28812880
ui/match/issue-11319.rs
28822881
ui/match/issue-114691.rs

tests/ui/consts/invalid-inline-const-in-match-arm.rs

-9
This file was deleted.

tests/ui/consts/invalid-inline-const-in-match-arm.stderr

-18
This file was deleted.

tests/ui/feature-gates/feature-gate-inline_const_pat.rs

-4
This file was deleted.

tests/ui/feature-gates/feature-gate-inline_const_pat.stderr

-13
This file was deleted.

tests/ui/half-open-range-patterns/range_pat_interactions0.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//@ run-pass
22
#![allow(non_contiguous_range_endpoints)]
3-
#![feature(inline_const_pat)]
4-
53
fn main() {
64
let mut if_lettable = vec![];
75
let mut first_or = vec![];
@@ -16,7 +14,6 @@ fn main() {
1614
match x {
1715
1 | -3..0 => first_or.push(x),
1816
y @ (0..5 | 6) => or_two.push(y),
19-
y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
2017
y @ -5.. => range_from.push(y),
2118
y @ ..-7 => assert_eq!(y, -8),
2219
y => bottom.push(y),
@@ -25,6 +22,6 @@ fn main() {
2522
assert_eq!(if_lettable, [-1, 0, 2, 4]);
2623
assert_eq!(first_or, [-3, -2, -1, 1]);
2724
assert_eq!(or_two, [0, 2, 3, 4, 6]);
28-
assert_eq!(range_from, [-5, -4, 7]);
25+
assert_eq!(range_from, [-5, -4, 5, 7]);
2926
assert_eq!(bottom, [-7, -6]);
3027
}

tests/ui/half-open-range-patterns/range_pat_interactions1.rs

-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ fn main() {
1818
//~^ error: expected a pattern range bound, found an expression
1919
1 | -3..0 => first_or.push(x),
2020
y @ (0..5 | 6) => or_two.push(y),
21-
y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
22-
//~^ error: inline-const in pattern position is experimental [E0658]
2321
y @ -5.. => range_from.push(y),
2422
y @ ..-7 => assert_eq!(y, -8),
2523
y => bottom.push(y),

tests/ui/half-open-range-patterns/range_pat_interactions1.stderr

+2-17
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ LL + const VAL: /* Type */ = 5+1;
1111
LL ~ match x as i32 {
1212
LL ~ 0..VAL => errors_only.push(x),
1313
|
14-
help: consider wrapping the expression in an inline `const` (requires `#![feature(inline_const_pat)]`)
15-
|
16-
LL | 0..const { 5+1 } => errors_only.push(x),
17-
| +++++++ +
1814

1915
error[E0408]: variable `n` is not bound in all patterns
2016
--> $DIR/range_pat_interactions1.rs:10:25
@@ -24,17 +20,6 @@ LL | if let n @ 2..3|4 = x {
2420
| |
2521
| variable not in all patterns
2622

27-
error[E0658]: inline-const in pattern position is experimental
28-
--> $DIR/range_pat_interactions1.rs:21:20
29-
|
30-
LL | y @ 0..const { 5 + 1 } => assert_eq!(y, 5),
31-
| ^^^^^
32-
|
33-
= note: see issue #76001 <https://github.com/rust-lang/rust/issues/76001> for more information
34-
= help: add `#![feature(inline_const_pat)]` to the crate attributes to enable
35-
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
36-
37-
error: aborting due to 3 previous errors
23+
error: aborting due to 2 previous errors
3824

39-
Some errors have detailed explanations: E0408, E0658.
40-
For more information about an error, try `rustc --explain E0408`.
25+
For more information about this error, try `rustc --explain E0408`.

tests/ui/half-open-range-patterns/range_pat_interactions2.rs

-22
This file was deleted.

tests/ui/half-open-range-patterns/range_pat_interactions2.stderr

-43
This file was deleted.

tests/ui/half-open-range-patterns/range_pat_interactions3.rs

-19
This file was deleted.

tests/ui/half-open-range-patterns/range_pat_interactions3.stderr

-13
This file was deleted.

tests/ui/inline-const/collect-scopes-in-pat.rs

-16
This file was deleted.

tests/ui/inline-const/const-block-pat-liveness.rs

-18
This file was deleted.

0 commit comments

Comments
 (0)