Skip to content

Commit 4304fa2

Browse files
committed
Auto merge of rust-lang#138492 - lcnr:rm-inline_const_pat, r=oli-obk
remove `feature(inline_const_pat)` Summarizing https://rust-lang.zulipchat.com/#narrow/channel/144729-t-types/topic/remove.20feature.28inline_const_pat.29.20and.20shared.20borrowck. With rust-lang/types-team#129 we will start to borrowck items together with their typeck parent. This is necessary to correctly support opaque types, blocking the new solver and TAIT/ATPIT stabilization with the old one. This means that we cannot really support `inline_const_pat` as they are implemented right now: - we want to typeck inline consts together with their parent body to allow inference to flow both ways and to allow the const to refer to local regions of its parent.This means we also need to borrowck the inline const together with its parent as that's necessary to properly support opaque types - we want the inline const pattern to participate in exhaustiveness checking - to participate in exhaustiveness checking we need to evaluate it, which requires borrowck, which now relies on borrowck of the typeck root, which ends up checking exhaustiveness again. **This is a query cycle**. There are 4 possible ways to handle this: - stop typechecking inline const patterns together with their parent - causes inline const patterns to be different than inline const exprs - prevents bidirectional inference, we need to either fail to compile `if let const { 1 } = 1u32` or `if let const { 1u32 } = 1` - region inference for inline consts will be harder, it feels non-trivial to support inline consts referencing local regions from the parent fn - inline consts no longer participate in exhaustiveness checking. Treat them like `pat if pat == const { .. }` instead. We then only evaluate them after borrowck - difference between `const { 1 }` and `const FOO: usize = 1; match x { FOO => () }`. This is confusing - do they carry their weight if they are now just equivalent to using an if-guard - delay exhaustiveness checking until after borrowck - should be possible in theory, but is a quite involved change and may have some unexpected challenges - remove this feature for now I believe we should either delay exhaustiveness checking or remove the feature entirely. As moving exhaustiveness checking to after borrow checking is quite complex I think the right course of action is to fully remove the feature for now and to add it again once/if we've got that implementation figured out. `const { .. }`-expressions remain stable. These seem to have been the main motivation for rust-lang/rfcs#2920. r? types cc `@rust-lang/types` `@rust-lang/lang` rust-lang#76001
2 parents 93d0885 + 6c8400e commit 4304fa2

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

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(..), ..))

0 commit comments

Comments
 (0)