Introduce EarlyBinder
This commit is contained in:
parent
ecd44958e0
commit
319575ae8c
66 changed files with 339 additions and 234 deletions
|
@ -8,7 +8,9 @@
|
|||
|
||||
use rustc_middle::traits::ChalkRustInterner as RustInterner;
|
||||
use rustc_middle::ty::subst::{InternalSubsts, Subst, SubstsRef};
|
||||
use rustc_middle::ty::{self, AssocItemContainer, AssocKind, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc_middle::ty::{
|
||||
self, AssocItemContainer, AssocKind, EarlyBinder, Ty, TyCtxt, TypeFoldable,
|
||||
};
|
||||
|
||||
use rustc_ast::ast;
|
||||
use rustc_attr as attr;
|
||||
|
@ -41,7 +43,7 @@ impl<'tcx> RustIrDatabase<'tcx> {
|
|||
let predicates = self.interner.tcx.predicates_defined_on(def_id).predicates;
|
||||
predicates
|
||||
.iter()
|
||||
.map(|(wc, _)| wc.subst(self.interner.tcx, bound_vars))
|
||||
.map(|(wc, _)| EarlyBinder(*wc).subst(self.interner.tcx, bound_vars))
|
||||
.filter_map(|wc| LowerInto::<
|
||||
Option<chalk_ir::QuantifiedWhereClause<RustInterner<'tcx>>>
|
||||
>::lower_into(wc, self.interner)).collect()
|
||||
|
@ -55,7 +57,7 @@ impl<'tcx> RustIrDatabase<'tcx> {
|
|||
.tcx
|
||||
.explicit_item_bounds(def_id)
|
||||
.iter()
|
||||
.map(|(bound, _)| bound.subst(self.interner.tcx, &bound_vars))
|
||||
.map(|(bound, _)| EarlyBinder(*bound).subst(self.interner.tcx, &bound_vars))
|
||||
.filter_map(|bound| LowerInto::<Option<_>>::lower_into(bound, self.interner))
|
||||
.collect()
|
||||
}
|
||||
|
@ -272,15 +274,17 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
let (inputs_and_output, iobinders, _) = crate::chalk::lowering::collect_bound_vars(
|
||||
self.interner,
|
||||
self.interner.tcx,
|
||||
sig.inputs_and_output().subst(self.interner.tcx, bound_vars),
|
||||
EarlyBinder(sig.inputs_and_output()).subst(self.interner.tcx, bound_vars),
|
||||
);
|
||||
|
||||
let argument_types = inputs_and_output[..inputs_and_output.len() - 1]
|
||||
.iter()
|
||||
.map(|t| t.subst(self.interner.tcx, &bound_vars).lower_into(self.interner))
|
||||
.map(|t| {
|
||||
EarlyBinder(*t).subst(self.interner.tcx, &bound_vars).lower_into(self.interner)
|
||||
})
|
||||
.collect();
|
||||
|
||||
let return_type = inputs_and_output[inputs_and_output.len() - 1]
|
||||
let return_type = EarlyBinder(inputs_and_output[inputs_and_output.len() - 1])
|
||||
.subst(self.interner.tcx, &bound_vars)
|
||||
.lower_into(self.interner);
|
||||
|
||||
|
@ -307,7 +311,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
let binders = binders_for(self.interner, bound_vars);
|
||||
|
||||
let trait_ref = self.interner.tcx.impl_trait_ref(def_id).expect("not an impl");
|
||||
let trait_ref = trait_ref.subst(self.interner.tcx, bound_vars);
|
||||
let trait_ref = EarlyBinder(trait_ref).subst(self.interner.tcx, bound_vars);
|
||||
|
||||
let where_clauses = self.where_clauses_for(def_id, bound_vars);
|
||||
|
||||
|
@ -352,7 +356,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
let bound_vars = bound_vars_for_item(self.interner.tcx, *impl_def_id);
|
||||
|
||||
let self_ty = trait_ref.self_ty();
|
||||
let self_ty = self_ty.subst(self.interner.tcx, bound_vars);
|
||||
let self_ty = EarlyBinder(self_ty).subst(self.interner.tcx, bound_vars);
|
||||
let lowered_ty = self_ty.lower_into(self.interner);
|
||||
|
||||
parameters[0].assert_ty_ref(self.interner).could_match(
|
||||
|
@ -460,10 +464,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
let trait_item_id = assoc_item.trait_item_def_id.expect("assoc_ty with no trait version");
|
||||
let bound_vars = bound_vars_for_item(self.interner.tcx, def_id);
|
||||
let binders = binders_for(self.interner, bound_vars);
|
||||
let ty = self
|
||||
.interner
|
||||
.tcx
|
||||
.type_of(def_id)
|
||||
let ty = EarlyBinder(self.interner.tcx.type_of(def_id))
|
||||
.subst(self.interner.tcx, bound_vars)
|
||||
.lower_into(self.interner);
|
||||
|
||||
|
@ -506,7 +507,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
.tcx
|
||||
.explicit_item_bounds(opaque_ty_id.0)
|
||||
.iter()
|
||||
.map(|(bound, _)| bound.subst(self.interner.tcx, &bound_vars))
|
||||
.map(|(bound, _)| EarlyBinder(*bound).subst(self.interner.tcx, &bound_vars))
|
||||
.map(|bound| {
|
||||
bound.fold_with(&mut ReplaceOpaqueTyFolder {
|
||||
tcx: self.interner.tcx,
|
||||
|
|
|
@ -5,7 +5,7 @@ use rustc_infer::infer::TyCtxtInferExt;
|
|||
use rustc_infer::traits::TraitEngineExt as _;
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::subst::{InternalSubsts, Subst};
|
||||
use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{self, EarlyBinder, ParamEnvAnd, Ty, TyCtxt};
|
||||
use rustc_span::source_map::{Span, DUMMY_SP};
|
||||
use rustc_trait_selection::traits::query::dropck_outlives::trivial_dropck_outlives;
|
||||
use rustc_trait_selection::traits::query::dropck_outlives::{
|
||||
|
@ -271,9 +271,15 @@ fn dtorck_constraint_for_ty<'tcx>(
|
|||
tcx.at(span).adt_dtorck_constraint(def.did())?;
|
||||
// FIXME: we can try to recursively `dtorck_constraint_on_ty`
|
||||
// there, but that needs some way to handle cycles.
|
||||
constraints.dtorck_types.extend(dtorck_types.iter().map(|t| t.subst(tcx, substs)));
|
||||
constraints.outlives.extend(outlives.iter().map(|t| t.subst(tcx, substs)));
|
||||
constraints.overflows.extend(overflows.iter().map(|t| t.subst(tcx, substs)));
|
||||
constraints
|
||||
.dtorck_types
|
||||
.extend(dtorck_types.iter().map(|t| EarlyBinder(*t).subst(tcx, substs)));
|
||||
constraints
|
||||
.outlives
|
||||
.extend(outlives.iter().map(|t| EarlyBinder(*t).subst(tcx, substs)));
|
||||
constraints
|
||||
.overflows
|
||||
.extend(overflows.iter().map(|t| EarlyBinder(*t).subst(tcx, substs)));
|
||||
}
|
||||
|
||||
// Objects must be alive in order for their destructor
|
||||
|
|
|
@ -6,7 +6,9 @@ use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
|
|||
use rustc_infer::traits::TraitEngineExt as _;
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::subst::{GenericArg, Subst, UserSelfTy, UserSubsts};
|
||||
use rustc_middle::ty::{self, FnSig, Lift, PolyFnSig, Ty, TyCtxt, TypeFoldable, Variance};
|
||||
use rustc_middle::ty::{
|
||||
self, EarlyBinder, FnSig, Lift, PolyFnSig, Ty, TyCtxt, TypeFoldable, Variance,
|
||||
};
|
||||
use rustc_middle::ty::{ParamEnv, ParamEnvAnd, Predicate, ToPredicate};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_trait_selection::infer::InferCtxtBuilderExt;
|
||||
|
@ -115,7 +117,7 @@ impl<'me, 'tcx> AscribeUserTypeCx<'me, 'tcx> {
|
|||
where
|
||||
T: TypeFoldable<'tcx>,
|
||||
{
|
||||
value.subst(self.tcx(), substs)
|
||||
EarlyBinder(value).subst(self.tcx(), substs)
|
||||
}
|
||||
|
||||
fn relate_mir_and_user_ty(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue