From bd16cd4fb54a1f54317d2cb9a7b623c32d081ce3 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 24 Mar 2026 08:12:17 +0100 Subject: [PATCH 1/2] CopyProp: fix outdated comment --- compiler/rustc_mir_transform/src/copy_prop.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_mir_transform/src/copy_prop.rs b/compiler/rustc_mir_transform/src/copy_prop.rs index 89ee96317ac93..e04cb26e89902 100644 --- a/compiler/rustc_mir_transform/src/copy_prop.rs +++ b/compiler/rustc_mir_transform/src/copy_prop.rs @@ -58,7 +58,8 @@ impl<'tcx> crate::MirPass<'tcx> for CopyProp { } } -/// Utility to help performing substitution of `*pattern` by `target`. +/// Utility to help performing substitution: for all key-value pairs in `copy_classes`, +/// all occurrences of the key get replaced by the value. struct Replacer<'a, 'tcx> { tcx: TyCtxt<'tcx>, unified: DenseBitSet, From fb2b0031d0503e77a33d551ddef409b6834afb05 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 24 Mar 2026 08:59:29 +0100 Subject: [PATCH 2/2] GVN: add clarifying example to reference comment --- compiler/rustc_mir_transform/src/gvn.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index 245ee6ec1cb75..e9a20aa016550 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -48,8 +48,15 @@ //! # Handling of references //! //! We handle references by assigning a different "provenance" index to each Ref/RawPtr rvalue. -//! This ensure that we do not spuriously merge borrows that should not be merged. Meanwhile, we -//! consider all the derefs of an immutable reference to a freeze type to give the same value: +//! This ensure that we do not spuriously merge borrows that should not be merged. For instance: +//! ```ignore (MIR) +//! _x = &_a; +//! _a = 0; +//! _y = &_a; // cannot be turned into `_y = _x`! +//! ``` +//! +//! On top of that, we consider all the derefs of an immutable reference to a freeze type to give +//! the same value: //! ```ignore (MIR) //! _a = *_b // _b is &Freeze //! _c = *_b // replaced by _c = _a