1
Fork 0

consistently treat None-tagged pointers as ints; get rid of some deprecated Scalar methods

This commit is contained in:
Ralf Jung 2021-07-12 20:29:05 +02:00
parent d4f7dd6702
commit 626605cea0
29 changed files with 145 additions and 139 deletions

View file

@ -38,7 +38,7 @@ crate fn lit_to_const<'tcx>(
}
(ast::LitKind::ByteStr(data), ty::Ref(_, inner_ty, _)) if inner_ty.is_array() => {
let id = tcx.allocate_bytes(data);
ConstValue::Scalar(Scalar::Ptr(id.into()))
ConstValue::Scalar(Scalar::from_pointer(id.into(), &tcx))
}
(ast::LitKind::Byte(n), ty::Uint(ty::UintTy::U8)) => {
ConstValue::Scalar(Scalar::from_uint(*n, Size::from_bytes(1)))

View file

@ -928,7 +928,11 @@ impl<'tcx> Cx<'tcx> {
} else {
let ptr = self.tcx.create_static_alloc(id);
ExprKind::StaticRef {
literal: ty::Const::from_scalar(self.tcx, Scalar::Ptr(ptr.into()), ty),
literal: ty::Const::from_scalar(
self.tcx,
Scalar::from_pointer(ptr.into(), &self.tcx),
ty,
),
def_id: id,
}
};

View file

@ -123,7 +123,7 @@ impl IntRange {
// straight to the result, after doing a bit of checking. (We
// could remove this branch and just fall through, which
// is more general but much slower.)
if let Ok(bits) = scalar.to_bits_or_ptr(target_size, &tcx) {
if let Ok(bits) = scalar.to_bits_or_ptr(target_size) {
return Some(bits);
}
}