1
Fork 0

Enable instcombine for mutable reborrows

This commit is contained in:
Ben Kimock 2022-12-03 00:57:33 -05:00
parent 4b34c7b766
commit 1409cb59b2
4 changed files with 9 additions and 31 deletions

View file

@ -110,11 +110,7 @@ impl<'tcx> InstCombineContext<'tcx, '_> {
fn combine_ref_deref(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
if let Rvalue::Ref(_, _, place) = rvalue {
if let Some((base, ProjectionElem::Deref)) = place.as_ref().last_projection() {
if let ty::Ref(_, _, Mutability::Not) =
base.ty(self.local_decls, self.tcx).ty.kind()
{
// The dereferenced place must have type `&_`, so that we don't copy `&mut _`.
} else {
if rvalue.ty(self.local_decls, self.tcx) != base.ty(self.local_decls, self.tcx).ty {
return;
}