Skip to content

Commit fb2b003

Browse files
committed
GVN: add clarifying example to reference comment
1 parent bd16cd4 commit fb2b003

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

  • compiler/rustc_mir_transform/src

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,15 @@
4848
//! # Handling of references
4949
//!
5050
//! We handle references by assigning a different "provenance" index to each Ref/RawPtr rvalue.
51-
//! This ensure that we do not spuriously merge borrows that should not be merged. Meanwhile, we
52-
//! consider all the derefs of an immutable reference to a freeze type to give the same value:
51+
//! This ensure that we do not spuriously merge borrows that should not be merged. For instance:
52+
//! ```ignore (MIR)
53+
//! _x = &_a;
54+
//! _a = 0;
55+
//! _y = &_a; // cannot be turned into `_y = _x`!
56+
//! ```
57+
//!
58+
//! On top of that, we consider all the derefs of an immutable reference to a freeze type to give
59+
//! the same value:
5360
//! ```ignore (MIR)
5461
//! _a = *_b // _b is &Freeze
5562
//! _c = *_b // replaced by _c = _a

0 commit comments

Comments
 (0)