1
Fork 0

Rollup merge of #124624 - WaffleLapkin:old_unit, r=fmease

Use `tcx.types.unit` instead of `Ty::new_unit(tcx)`

I don't think there is any need for the function, given that we can just access the `.types`, similarly to all other primitives?
This commit is contained in:
Matthias Krüger 2024-05-02 19:42:50 +02:00 committed by GitHub
commit d6940fb43d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 51 additions and 57 deletions

View file

@ -125,7 +125,7 @@ impl Primitive {
F64 => tcx.types.f64,
F128 => tcx.types.f128,
// FIXME(erikdesjardins): handle non-default addrspace ptr sizes
Pointer(_) => Ty::new_mut_ptr(tcx, Ty::new_unit(tcx)),
Pointer(_) => Ty::new_mut_ptr(tcx, tcx.types.unit),
}
}
@ -775,7 +775,7 @@ where
// (which may have no non-DST form), and will work as long
// as the `Abi` or `FieldsShape` is checked by users.
if i == 0 {
let nil = Ty::new_unit(tcx);
let nil = tcx.types.unit;
let unit_ptr_ty = if this.ty.is_unsafe_ptr() {
Ty::new_mut_ptr(tcx, nil)
} else {

View file

@ -1750,11 +1750,6 @@ impl<'tcx> Ty<'tcx> {
// misc
#[inline]
pub fn new_unit(tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
tcx.types.unit
}
#[inline]
pub fn new_static_str(tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
Ty::new_imm_ref(tcx, tcx.lifetimes.re_static, tcx.types.str_)