rust/compiler/rustc_mir_build/src/builder
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
..
coverageinfo Rename rustc_mir_build::build to builder 2024-12-17 11:41:11 +11:00
custom AsyncDrop implementation using shim codegen of async_drop_in_place::{closure}, scoped async drop added. 2025-04-28 16:23:13 +07:00
expr AsyncDrop implementation using shim codegen of async_drop_in_place::{closure}, scoped async drop added. 2025-04-28 16:23:13 +07:00
matches lower deref patterns on boxes using built-in derefs 2025-04-24 14:25:27 -07:00
block.rs Split visit_primary_bindings into two variants 2025-03-16 12:10:35 +11:00
cfg.rs Rustfmt 2025-02-08 22:12:13 +00:00
coverageinfo.rs Rename rustc_mir_build::build to builder 2024-12-17 11:41:11 +11:00
misc.rs Rustfmt 2025-02-08 22:12:13 +00:00
mod.rs Replace infallible name_or_empty methods with fallible name methods. 2025-04-17 09:50:52 +10:00
scope.rs AsyncDrop implementation using shim codegen of async_drop_in_place::{closure}, scoped async drop added. 2025-04-28 16:23:13 +07:00