1
Fork 0

Introduce EarlyBinder

This commit is contained in:
Jack Huey 2022-05-08 01:17:58 -04:00
parent ecd44958e0
commit 319575ae8c
66 changed files with 339 additions and 234 deletions

View file

@ -5,7 +5,7 @@ use rustc_hir::def_id::DefId;
use rustc_middle::ty::subst::Subst;
use rustc_middle::ty::subst::SubstsRef;
use rustc_middle::ty::util::{needs_drop_components, AlwaysRequiresDrop};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::ty::{self, EarlyBinder, Ty, TyCtxt};
use rustc_session::Limit;
use rustc_span::{sym, DUMMY_SP};
@ -204,7 +204,7 @@ fn drop_tys_helper<'tcx>(
match subty.kind() {
ty::Adt(adt_id, subst) => {
for subty in tcx.adt_drop_tys(adt_id.did())? {
vec.push(subty.subst(tcx, subst));
vec.push(EarlyBinder(subty).subst(tcx, subst));
}
}
_ => vec.push(subty),
@ -237,7 +237,7 @@ fn drop_tys_helper<'tcx>(
Ok(Vec::new())
} else {
let field_tys = adt_def.all_fields().map(|field| {
let r = tcx.type_of(field.did).subst(tcx, substs);
let r = EarlyBinder(tcx.type_of(field.did)).subst(tcx, substs);
debug!("drop_tys_helper: Subst into {:?} with {:?} gettng {:?}", field, substs, r);
r
});

View file

@ -2,7 +2,9 @@ use rustc_data_structures::fx::FxIndexSet;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_middle::ty::subst::Subst;
use rustc_middle::ty::{self, Binder, Predicate, PredicateKind, ToPredicate, Ty, TyCtxt};
use rustc_middle::ty::{
self, Binder, EarlyBinder, Predicate, PredicateKind, ToPredicate, Ty, TyCtxt,
};
use rustc_span::{sym, Span};
use rustc_trait_selection::traits;
@ -33,7 +35,7 @@ fn sized_constraint_for_ty<'tcx>(
debug!("sized_constraint_for_ty({:?}) intermediate = {:?}", ty, adt_tys);
adt_tys
.iter()
.map(|ty| ty.subst(tcx, substs))
.map(|ty| EarlyBinder(*ty).subst(tcx, substs))
.flat_map(|ty| sized_constraint_for_ty(tcx, adtdef, ty))
.collect()
}
@ -442,7 +444,7 @@ pub fn conservative_is_privately_uninhabited_raw<'tcx>(
// one uninhabited field.
def.variants().iter().all(|var| {
var.fields.iter().any(|field| {
let ty = tcx.type_of(field.did).subst(tcx, substs);
let ty = EarlyBinder(tcx.type_of(field.did)).subst(tcx, substs);
tcx.conservative_is_privately_uninhabited(param_env.and(ty))
})
})