1
Fork 0

Move unsigned_max etc into Size again

This commit is contained in:
Andreas Liljeqvist 2021-09-06 20:11:29 +02:00
parent 459c9108e4
commit 9129f4306f
6 changed files with 37 additions and 37 deletions

View file

@ -494,9 +494,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// Helper to get a `-1` value of the appropriate type
fn neg_1_literal(&mut self, span: Span, ty: Ty<'tcx>) -> Operand<'tcx> {
let param_ty = ty::ParamEnv::empty().and(ty);
let bits = self.tcx.layout_of(param_ty).unwrap().size.bits();
let n = (!0u128) >> (128 - bits);
let literal = ty::Const::from_bits(self.tcx, n, param_ty);
let size = self.tcx.layout_of(param_ty).unwrap().size;
let literal = ty::Const::from_bits(self.tcx, size.unsigned_max(), param_ty);
self.literal_operand(span, literal)
}