Do not do if ! else, use unnegated cond and swap the branches instead

This commit is contained in:
Santiago Pastorino 2024-12-11 18:01:19 -03:00 committed by 许杰友 Jieyou Xu (Joe)
parent 37e74596c0
commit 3218476c12

View file

@ -56,10 +56,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
pub(crate) fn consume_by_copy_or_move(&self, place: Place<'tcx>) -> Operand<'tcx> { pub(crate) fn consume_by_copy_or_move(&self, place: Place<'tcx>) -> Operand<'tcx> {
let tcx = self.tcx; let tcx = self.tcx;
let ty = place.ty(&self.local_decls, tcx).ty; let ty = place.ty(&self.local_decls, tcx).ty;
if !self.infcx.type_is_copy_modulo_regions(self.param_env, ty) { if self.infcx.type_is_copy_modulo_regions(self.param_env, ty) {
Operand::Move(place)
} else {
Operand::Copy(place) Operand::Copy(place)
} else {
Operand::Move(place)
} }
} }
} }