diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2023-05-10 17:29:02 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2023-05-10 19:22:57 +0000 |
| commit | aeac5555780cb11cf701a5fa69d66adcaa3e2f4a (patch) | |
| tree | 942d82c68db21bf66b60abb5d4a1cb8e3716adab /compiler/rustc_mir_transform | |
| parent | d0d4e0237ff708c4d41070ef946679819125a0d5 (diff) | |
| download | rust-aeac5555780cb11cf701a5fa69d66adcaa3e2f4a.tar.gz rust-aeac5555780cb11cf701a5fa69d66adcaa3e2f4a.zip | |
Do not see through copies of mutable pointers.
Diffstat (limited to 'compiler/rustc_mir_transform')
| -rw-r--r-- | compiler/rustc_mir_transform/src/ref_prop.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/rustc_mir_transform/src/ref_prop.rs b/compiler/rustc_mir_transform/src/ref_prop.rs index ac55ce3b316..38be7b3c7ea 100644 --- a/compiler/rustc_mir_transform/src/ref_prop.rs +++ b/compiler/rustc_mir_transform/src/ref_prop.rs @@ -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); } } } |
