mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Do not see through copies of mutable pointers.
This commit is contained in:
parent
d0d4e0237f
commit
aeac555578
@ -208,13 +208,14 @@ fn compute_replacement<'tcx>(
|
||||
// have been visited before.
|
||||
Rvalue::Use(Operand::Copy(place) | Operand::Move(place))
|
||||
| Rvalue::CopyForDeref(place) => {
|
||||
if let Some(rhs) = place.as_local() {
|
||||
if let Some(rhs) = place.as_local() && ssa.is_ssa(rhs) {
|
||||
let target = targets[rhs];
|
||||
if matches!(target, Value::Pointer(..)) {
|
||||
// Only see through immutable reference and pointers, as we do not know yet if
|
||||
// mutable references are fully replaced.
|
||||
if !needs_unique && matches!(target, Value::Pointer(..)) {
|
||||
targets[local] = target;
|
||||
} else if ssa.is_ssa(rhs) {
|
||||
let refmut = body.local_decls[rhs].ty.is_mutable_ptr();
|
||||
targets[local] = Value::Pointer(tcx.mk_place_deref(rhs.into()), refmut);
|
||||
} else {
|
||||
targets[local] = Value::Pointer(tcx.mk_place_deref(rhs.into()), needs_unique);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,14 +37,14 @@
|
||||
- StorageLive(_2); // scope 1 at $DIR/reference_prop.rs:+2:9: +2:13
|
||||
_2 = &mut _1; // scope 1 at $DIR/reference_prop.rs:+2:16: +2:22
|
||||
StorageLive(_3); // scope 2 at $DIR/reference_prop.rs:+3:9: +3:13
|
||||
StorageLive(_4); // scope 2 at $DIR/reference_prop.rs:+3:16: +3:36
|
||||
- StorageLive(_4); // scope 2 at $DIR/reference_prop.rs:+3:16: +3:36
|
||||
- StorageLive(_5); // scope 2 at $DIR/reference_prop.rs:+3:16: +3:26
|
||||
- _5 = &mut (*_2); // scope 2 at $DIR/reference_prop.rs:+3:16: +3:26
|
||||
- _4 = &raw mut (*_5); // scope 2 at $DIR/reference_prop.rs:+3:16: +3:26
|
||||
+ _4 = &raw mut _1; // scope 2 at $DIR/reference_prop.rs:+3:16: +3:26
|
||||
_3 = _4; // scope 2 at $DIR/reference_prop.rs:+3:16: +3:36
|
||||
- StorageDead(_5); // scope 2 at $DIR/reference_prop.rs:+3:36: +3:37
|
||||
StorageDead(_4); // scope 2 at $DIR/reference_prop.rs:+3:36: +3:37
|
||||
- StorageDead(_4); // scope 2 at $DIR/reference_prop.rs:+3:36: +3:37
|
||||
StorageLive(_6); // scope 3 at $DIR/reference_prop.rs:+4:9: +4:13
|
||||
- _6 = &(*_2); // scope 3 at $DIR/reference_prop.rs:+4:16: +4:22
|
||||
+ _6 = &_1; // scope 3 at $DIR/reference_prop.rs:+4:16: +4:22
|
||||
|
@ -28,12 +28,11 @@
|
||||
StorageLive(_1); // scope 0 at $DIR/reference_prop.rs:+1:9: +1:10
|
||||
StorageLive(_2); // scope 0 at $DIR/reference_prop.rs:+2:13: +2:18
|
||||
_2 = const 0_i32; // scope 0 at $DIR/reference_prop.rs:+2:21: +2:22
|
||||
StorageLive(_3); // scope 2 at $DIR/reference_prop.rs:+3:13: +3:14
|
||||
- StorageLive(_3); // scope 2 at $DIR/reference_prop.rs:+3:13: +3:14
|
||||
_3 = &raw mut _2; // scope 2 at $DIR/reference_prop.rs:+3:17: +3:27
|
||||
StorageLive(_4); // scope 3 at $DIR/reference_prop.rs:+5:9: +5:30
|
||||
StorageLive(_5); // scope 4 at $DIR/reference_prop.rs:+5:25: +5:27
|
||||
- _5 = (*_3); // scope 4 at $DIR/reference_prop.rs:+5:25: +5:27
|
||||
+ _5 = _2; // scope 4 at $DIR/reference_prop.rs:+5:25: +5:27
|
||||
_5 = (*_3); // scope 4 at $DIR/reference_prop.rs:+5:25: +5:27
|
||||
_4 = opaque::<i32>(move _5) -> bb1; // scope 4 at $DIR/reference_prop.rs:+5:18: +5:28
|
||||
// mir::Constant
|
||||
// + span: $DIR/reference_prop.rs:452:18: 452:24
|
||||
@ -44,11 +43,12 @@
|
||||
StorageDead(_5); // scope 4 at $DIR/reference_prop.rs:+5:27: +5:28
|
||||
StorageDead(_4); // scope 3 at $DIR/reference_prop.rs:+5:30: +5:31
|
||||
_1 = _3; // scope 3 at $DIR/reference_prop.rs:+6:9: +6:10
|
||||
StorageDead(_3); // scope 2 at $DIR/reference_prop.rs:+7:5: +7:6
|
||||
- StorageDead(_3); // scope 2 at $DIR/reference_prop.rs:+7:5: +7:6
|
||||
StorageDead(_2); // scope 0 at $DIR/reference_prop.rs:+7:5: +7:6
|
||||
StorageLive(_6); // scope 1 at $DIR/reference_prop.rs:+9:5: +9:26
|
||||
StorageLive(_7); // scope 5 at $DIR/reference_prop.rs:+9:21: +9:23
|
||||
_7 = (*_1); // scope 5 at $DIR/reference_prop.rs:+9:21: +9:23
|
||||
- _7 = (*_1); // scope 5 at $DIR/reference_prop.rs:+9:21: +9:23
|
||||
+ _7 = (*_3); // scope 5 at $DIR/reference_prop.rs:+9:21: +9:23
|
||||
_6 = opaque::<i32>(move _7) -> bb2; // scope 5 at $DIR/reference_prop.rs:+9:14: +9:24
|
||||
// mir::Constant
|
||||
// + span: $DIR/reference_prop.rs:456:14: 456:20
|
||||
|
Loading…
Reference in New Issue
Block a user