1
Fork 0

Auto merge of #88327 - bonega:scalar_refactor, r=eddyb

`WrappingRange` (#88242) follow-up (`is_full_for`, `Scalar: Copy`, etc.)

Some changes related to feedback during #88242
r? `@RalfJung`
This commit is contained in:
bors 2021-09-11 10:18:05 +00:00
commit 641e02f388
36 changed files with 230 additions and 270 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_int_max(), param_ty);
self.literal_operand(span, literal)
}