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, 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