rust/compiler/rustc_middle/src
Chris Denton 8dd26cb195
Rollup merge of #140022 - dianne:box-deref-pats, r=Nadrieril
allow deref patterns to move out of boxes

This adds a case to lower deref patterns on boxes using a built-in deref instead of a `Deref::deref` or `DerefMut::deref_mut` call: if `deref!(inner): Box<T>` is matching on place `place`, the inner pattern `inner` now matches on `*place` rather than a temporary. No longer needing to call a method also means it won't borrow the scrutinee in match arms. This allows for bindings in `inner` to move out of `*place`.

For comparison with box patterns, this uses the same MIR lowering but different THIR. Consequently, deref patterns on boxes are treated the same as any other deref patterns in match exhaustiveness analysis. Box patterns can't quite be implemented in terms of deref patterns until exhaustiveness checking for deref patterns is implemented (I'll open a PR for exhaustiveness soon!).

Tracking issue: #87121

r? ``@Nadrieril``
2025-04-28 23:29:15 +00:00
..
dep_graph Add a dep kind for use of the anon node with zero dependencies 2025-04-02 07:35:05 +02:00
hir do not emit OpaqueCast projections with -Znext-solver 2025-04-17 12:15:04 +02:00
hooks Pretty print pattern type values with transmute if they don't satisfy their pattern 2025-02-05 14:56:41 +00:00
infer Split TypeFolder and FallibleTypeFolder 2025-04-15 18:30:35 +00:00
middle AsyncDrop implementation using shim codegen of async_drop_in_place::{closure}, scoped async drop added. 2025-04-28 16:23:13 +07:00
mir AsyncDrop implementation using shim codegen of async_drop_in_place::{closure}, scoped async drop added. 2025-04-28 16:23:13 +07:00
query Auto merge of #140388 - GuillaumeGomez:rollup-aj9o3ch, r=GuillaumeGomez 2025-04-28 17:22:11 +00:00
thir Add {ast,hir,thir}::PatKind::Missing variants. 2025-03-28 09:18:57 +11:00
traits Remove weak alias terminology 2025-04-24 11:59:20 +01:00
ty Rollup merge of #140022 - dianne:box-deref-pats, r=Nadrieril 2025-04-28 23:29:15 +00:00
util Remove attribute #[rustc_error] 2025-03-30 01:32:21 +03:00
arena.rs AsyncDrop implementation using shim codegen of async_drop_in_place::{closure}, scoped async drop added. 2025-04-28 16:23:13 +07:00
error.rs Teach structured errors to display short Ty 2025-02-25 16:56:03 +00:00
lib.rs Make #![feature(let_chains)] bootstrap conditional in compiler/ 2025-04-23 16:40:30 +02:00
lint.rs Remove LintExpectationId from Level variants 2025-04-03 09:22:21 +00:00
macros.rs Fold visit into ty 2025-03-15 06:34:36 +00:00
metadata.rs Re-export more rustc_span::symbol things from rustc_span. 2024-12-18 13:38:53 +11:00
tests.rs Give an item related to issue 27438 a more meaningful name 2024-04-30 22:27:19 +02:00
thir.rs lower deref patterns on boxes using built-in derefs 2025-04-24 14:25:27 -07:00
values.rs Use search_for_cycle_permutation to look for variances_of 2025-04-27 09:38:18 +02:00