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

@ -781,7 +781,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
&& self.fallback_has_occurred
{
let predicate = trait_predicate.map_bound(|trait_pred| {
trait_pred.with_self_ty(self.tcx, Ty::new_unit(self.tcx))
trait_pred.with_self_ty(self.tcx, tcx.types.unit)
});
let unit_obligation = obligation.with(tcx, predicate);
if self.predicate_may_hold(&unit_obligation) {

View file

@ -519,7 +519,7 @@ fn virtual_call_violations_for_method<'tcx>(
// e.g., `Rc<()>`
let unit_receiver_ty =
receiver_for_self_ty(tcx, receiver_ty, Ty::new_unit(tcx), method.def_id);
receiver_for_self_ty(tcx, receiver_ty, tcx.types.unit, method.def_id);
match abi_of_ty(unit_receiver_ty) {
Some(Abi::Scalar(..)) => (),