1
Fork 0

simplify some code that depend on Deref

This commit is contained in:
ouz-a 2022-05-12 00:27:06 +03:00
parent 41419e7036
commit c0e4230bf5
3 changed files with 32 additions and 28 deletions

View file

@ -435,16 +435,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
LocalRef::Place(place) => place,
LocalRef::UnsizedPlace(place) => bx.load_operand(place).deref(cx),
LocalRef::Operand(..) => {
if let Some(elem) = place_ref
.projection
.iter()
.enumerate()
.find(|elem| matches!(elem.1, mir::ProjectionElem::Deref))
{
base = elem.0 + 1;
if place_ref.ret_deref().is_some() {
base = 1;
let cg_base = self.codegen_consume(
bx,
mir::PlaceRef { projection: &place_ref.projection[..elem.0], ..place_ref },
mir::PlaceRef { projection: &place_ref.projection[..0], ..place_ref },
);
cg_base.deref(bx.cx())