Auto merge of #92167 - pierwill:chalk-update, r=jackh726
Update chalk to 0.75.0 - Compute flags in `intern_ty` - Remove `tracing-serde` from `PERMITTED_DEPENDENCIES` - Bump `tracing-tree` to 0.2.0 - Bump `tracing-subscriber` to 0.3.3
This commit is contained in:
commit
c1d301bb29
11 changed files with 140 additions and 154 deletions
|
@ -46,7 +46,9 @@ impl<'tcx> RustIrDatabase<'tcx> {
|
|||
.iter()
|
||||
.map(|(wc, _)| wc.subst(self.interner.tcx, bound_vars))
|
||||
.map(|wc| wc.fold_with(&mut regions_substitutor))
|
||||
.filter_map(|wc| LowerInto::<Option<chalk_ir::QuantifiedWhereClause<RustInterner<'tcx>>>>::lower_into(wc, &self.interner)).collect()
|
||||
.filter_map(|wc| LowerInto::<
|
||||
Option<chalk_ir::QuantifiedWhereClause<RustInterner<'tcx>>>
|
||||
>::lower_into(wc, self.interner)).collect()
|
||||
}
|
||||
|
||||
fn bounds_for<T>(&self, def_id: DefId, bound_vars: SubstsRef<'tcx>) -> Vec<T>
|
||||
|
@ -58,14 +60,14 @@ impl<'tcx> RustIrDatabase<'tcx> {
|
|||
.explicit_item_bounds(def_id)
|
||||
.iter()
|
||||
.map(|(bound, _)| bound.subst(self.interner.tcx, &bound_vars))
|
||||
.filter_map(|bound| LowerInto::<Option<_>>::lower_into(bound, &self.interner))
|
||||
.filter_map(|bound| LowerInto::<Option<_>>::lower_into(bound, self.interner))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'tcx> {
|
||||
fn interner(&self) -> &RustInterner<'tcx> {
|
||||
&self.interner
|
||||
fn interner(&self) -> RustInterner<'tcx> {
|
||||
self.interner
|
||||
}
|
||||
|
||||
fn associated_ty_data(
|
||||
|
@ -83,7 +85,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
_ => unimplemented!("Not possible??"),
|
||||
}
|
||||
let bound_vars = bound_vars_for_item(self.interner.tcx, def_id);
|
||||
let binders = binders_for(&self.interner, bound_vars);
|
||||
let binders = binders_for(self.interner, bound_vars);
|
||||
|
||||
let where_clauses = self.where_clauses_for(def_id, bound_vars);
|
||||
let bounds = self.bounds_for(def_id, bound_vars);
|
||||
|
@ -107,7 +109,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
let trait_def = self.interner.tcx.trait_def(def_id);
|
||||
|
||||
let bound_vars = bound_vars_for_item(self.interner.tcx, def_id);
|
||||
let binders = binders_for(&self.interner, bound_vars);
|
||||
let binders = binders_for(self.interner, bound_vars);
|
||||
|
||||
let where_clauses = self.where_clauses_for(def_id, bound_vars);
|
||||
|
||||
|
@ -170,7 +172,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
let adt_def = adt_id.0;
|
||||
|
||||
let bound_vars = bound_vars_for_item(self.interner.tcx, adt_def.did);
|
||||
let binders = binders_for(&self.interner, bound_vars);
|
||||
let binders = binders_for(self.interner, bound_vars);
|
||||
|
||||
let where_clauses = self.where_clauses_for(adt_def.did, bound_vars);
|
||||
|
||||
|
@ -181,7 +183,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
fields: variant
|
||||
.fields
|
||||
.iter()
|
||||
.map(|field| field.ty(self.interner.tcx, bound_vars).lower_into(&self.interner))
|
||||
.map(|field| field.ty(self.interner.tcx, bound_vars).lower_into(self.interner))
|
||||
.collect(),
|
||||
})
|
||||
.collect();
|
||||
|
@ -209,8 +211,8 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
adt_id: chalk_ir::AdtId<RustInterner<'tcx>>,
|
||||
) -> Arc<chalk_solve::rust_ir::AdtRepr<RustInterner<'tcx>>> {
|
||||
let adt_def = adt_id.0;
|
||||
let int = |i| chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Int(i)).intern(&self.interner);
|
||||
let uint = |i| chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Uint(i)).intern(&self.interner);
|
||||
let int = |i| chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Int(i)).intern(self.interner);
|
||||
let uint = |i| chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Uint(i)).intern(self.interner);
|
||||
Arc::new(chalk_solve::rust_ir::AdtRepr {
|
||||
c: adt_def.repr.c(),
|
||||
packed: adt_def.repr.packed(),
|
||||
|
@ -241,25 +243,25 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
) -> Arc<chalk_solve::rust_ir::FnDefDatum<RustInterner<'tcx>>> {
|
||||
let def_id = fn_def_id.0;
|
||||
let bound_vars = bound_vars_for_item(self.interner.tcx, def_id);
|
||||
let binders = binders_for(&self.interner, bound_vars);
|
||||
let binders = binders_for(self.interner, bound_vars);
|
||||
|
||||
let where_clauses = self.where_clauses_for(def_id, bound_vars);
|
||||
|
||||
let sig = self.interner.tcx.fn_sig(def_id);
|
||||
let (inputs_and_output, iobinders, _) = crate::chalk::lowering::collect_bound_vars(
|
||||
&self.interner,
|
||||
self.interner,
|
||||
self.interner.tcx,
|
||||
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| t.subst(self.interner.tcx, &bound_vars).lower_into(self.interner))
|
||||
.collect();
|
||||
|
||||
let return_type = inputs_and_output[inputs_and_output.len() - 1]
|
||||
.subst(self.interner.tcx, &bound_vars)
|
||||
.lower_into(&self.interner);
|
||||
.lower_into(self.interner);
|
||||
|
||||
let bound = chalk_solve::rust_ir::FnDefDatumBound {
|
||||
inputs_and_output: chalk_ir::Binders::new(
|
||||
|
@ -270,7 +272,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
};
|
||||
Arc::new(chalk_solve::rust_ir::FnDefDatum {
|
||||
id: fn_def_id,
|
||||
sig: sig.lower_into(&self.interner),
|
||||
sig: sig.lower_into(self.interner),
|
||||
binders: chalk_ir::Binders::new(binders, bound),
|
||||
})
|
||||
}
|
||||
|
@ -281,7 +283,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
) -> Arc<chalk_solve::rust_ir::ImplDatum<RustInterner<'tcx>>> {
|
||||
let def_id = impl_id.0;
|
||||
let bound_vars = bound_vars_for_item(self.interner.tcx, def_id);
|
||||
let binders = binders_for(&self.interner, bound_vars);
|
||||
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);
|
||||
|
@ -292,7 +294,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
let where_clauses = self.where_clauses_for(def_id, bound_vars);
|
||||
|
||||
let value = chalk_solve::rust_ir::ImplDatumBound {
|
||||
trait_ref: trait_ref.lower_into(&self.interner),
|
||||
trait_ref: trait_ref.lower_into(self.interner),
|
||||
where_clauses,
|
||||
};
|
||||
|
||||
|
@ -306,7 +308,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
.collect();
|
||||
|
||||
Arc::new(chalk_solve::rust_ir::ImplDatum {
|
||||
polarity: self.interner.tcx.impl_polarity(def_id).lower_into(&self.interner),
|
||||
polarity: self.interner.tcx.impl_polarity(def_id).lower_into(self.interner),
|
||||
binders: chalk_ir::Binders::new(binders, value),
|
||||
impl_type: chalk_solve::rust_ir::ImplType::Local,
|
||||
associated_ty_value_ids,
|
||||
|
@ -336,10 +338,10 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
let mut regions_substitutor =
|
||||
lowering::RegionsSubstitutor::new(self.interner.tcx, self.reempty_placeholder);
|
||||
let self_ty = self_ty.fold_with(&mut regions_substitutor);
|
||||
let lowered_ty = self_ty.lower_into(&self.interner);
|
||||
let lowered_ty = self_ty.lower_into(self.interner);
|
||||
|
||||
parameters[0].assert_ty_ref(&self.interner).could_match(
|
||||
&self.interner,
|
||||
parameters[0].assert_ty_ref(self.interner).could_match(
|
||||
self.interner,
|
||||
self.unification_database(),
|
||||
&lowered_ty,
|
||||
)
|
||||
|
@ -452,13 +454,13 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
.find_by_name_and_kind(self.interner.tcx, assoc_item.ident, assoc_item.kind, trait_id)
|
||||
.unwrap();
|
||||
let bound_vars = bound_vars_for_item(self.interner.tcx, def_id);
|
||||
let binders = binders_for(&self.interner, bound_vars);
|
||||
let binders = binders_for(self.interner, bound_vars);
|
||||
let ty = self
|
||||
.interner
|
||||
.tcx
|
||||
.type_of(def_id)
|
||||
.subst(self.interner.tcx, bound_vars)
|
||||
.lower_into(&self.interner);
|
||||
.lower_into(self.interner);
|
||||
|
||||
Arc::new(chalk_solve::rust_ir::AssociatedTyValue {
|
||||
impl_id: chalk_ir::ImplId(impl_id),
|
||||
|
@ -521,13 +523,13 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
.filter_map(|bound| {
|
||||
LowerInto::<
|
||||
Option<chalk_ir::QuantifiedWhereClause<RustInterner<'tcx>>>
|
||||
>::lower_into(bound, &self.interner)
|
||||
>::lower_into(bound, self.interner)
|
||||
})
|
||||
.collect();
|
||||
|
||||
// Binder for the bound variable representing the concrete impl Trait type.
|
||||
let existential_binder = chalk_ir::VariableKinds::from1(
|
||||
&self.interner,
|
||||
self.interner,
|
||||
chalk_ir::VariableKind::Ty(chalk_ir::TyVariableKind::General),
|
||||
);
|
||||
|
||||
|
@ -536,7 +538,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
where_clauses: chalk_ir::Binders::new(existential_binder, where_clauses),
|
||||
};
|
||||
|
||||
let binders = binders_for(&self.interner, bound_vars);
|
||||
let binders = binders_for(self.interner, bound_vars);
|
||||
Arc::new(chalk_solve::rust_ir::OpaqueTyDatum {
|
||||
opaque_ty_id,
|
||||
bound: chalk_ir::Binders::new(binders, value),
|
||||
|
@ -568,6 +570,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
Unpin => lang_items.unpin_trait(),
|
||||
CoerceUnsized => lang_items.coerce_unsized_trait(),
|
||||
DiscriminantKind => lang_items.discriminant_kind_trait(),
|
||||
Generator => lang_items.generator_return(),
|
||||
};
|
||||
def_id.map(chalk_ir::TraitId)
|
||||
}
|
||||
|
@ -584,7 +587,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
self.interner
|
||||
.tcx
|
||||
.mk_ty(ty::Tuple(self.interner.tcx.intern_substs(&[])))
|
||||
.lower_into(&self.interner)
|
||||
.lower_into(self.interner)
|
||||
}
|
||||
|
||||
fn closure_kind(
|
||||
|
@ -592,8 +595,8 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
_closure_id: chalk_ir::ClosureId<RustInterner<'tcx>>,
|
||||
substs: &chalk_ir::Substitution<RustInterner<'tcx>>,
|
||||
) -> chalk_solve::rust_ir::ClosureKind {
|
||||
let kind = &substs.as_slice(&self.interner)[substs.len(&self.interner) - 3];
|
||||
match kind.assert_ty_ref(&self.interner).kind(&self.interner) {
|
||||
let kind = &substs.as_slice(self.interner)[substs.len(self.interner) - 3];
|
||||
match kind.assert_ty_ref(self.interner).kind(self.interner) {
|
||||
chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Int(int_ty)) => match int_ty {
|
||||
chalk_ir::IntTy::I8 => chalk_solve::rust_ir::ClosureKind::Fn,
|
||||
chalk_ir::IntTy::I16 => chalk_solve::rust_ir::ClosureKind::FnMut,
|
||||
|
@ -610,18 +613,17 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
substs: &chalk_ir::Substitution<RustInterner<'tcx>>,
|
||||
) -> chalk_ir::Binders<chalk_solve::rust_ir::FnDefInputsAndOutputDatum<RustInterner<'tcx>>>
|
||||
{
|
||||
let sig = &substs.as_slice(&self.interner)[substs.len(&self.interner) - 2];
|
||||
match sig.assert_ty_ref(&self.interner).kind(&self.interner) {
|
||||
let sig = &substs.as_slice(self.interner)[substs.len(self.interner) - 2];
|
||||
match sig.assert_ty_ref(self.interner).kind(self.interner) {
|
||||
chalk_ir::TyKind::Function(f) => {
|
||||
let substitution = f.substitution.0.as_slice(&self.interner);
|
||||
let return_type =
|
||||
substitution.last().unwrap().assert_ty_ref(&self.interner).clone();
|
||||
let substitution = f.substitution.0.as_slice(self.interner);
|
||||
let return_type = substitution.last().unwrap().assert_ty_ref(self.interner).clone();
|
||||
// Closure arguments are tupled
|
||||
let argument_tuple = substitution[0].assert_ty_ref(&self.interner);
|
||||
let argument_types = match argument_tuple.kind(&self.interner) {
|
||||
let argument_tuple = substitution[0].assert_ty_ref(self.interner);
|
||||
let argument_types = match argument_tuple.kind(self.interner) {
|
||||
chalk_ir::TyKind::Tuple(_len, substitution) => substitution
|
||||
.iter(&self.interner)
|
||||
.map(|arg| arg.assert_ty_ref(&self.interner))
|
||||
.iter(self.interner)
|
||||
.map(|arg| arg.assert_ty_ref(self.interner))
|
||||
.cloned()
|
||||
.collect(),
|
||||
_ => bug!("Expecting closure FnSig args to be tupled."),
|
||||
|
@ -629,7 +631,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
|
||||
chalk_ir::Binders::new(
|
||||
chalk_ir::VariableKinds::from_iter(
|
||||
&self.interner,
|
||||
self.interner,
|
||||
(0..f.num_binders).map(|_| chalk_ir::VariableKind::Lifetime),
|
||||
),
|
||||
chalk_solve::rust_ir::FnDefInputsAndOutputDatum { argument_types, return_type },
|
||||
|
@ -645,7 +647,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
substs: &chalk_ir::Substitution<RustInterner<'tcx>>,
|
||||
) -> chalk_ir::Binders<chalk_ir::Ty<RustInterner<'tcx>>> {
|
||||
let inputs_and_output = self.closure_inputs_and_output(_closure_id, substs);
|
||||
let tuple = substs.as_slice(&self.interner).last().unwrap().assert_ty_ref(&self.interner);
|
||||
let tuple = substs.as_slice(self.interner).last().unwrap().assert_ty_ref(self.interner);
|
||||
inputs_and_output.map_ref(|_| tuple.clone())
|
||||
}
|
||||
|
||||
|
@ -654,8 +656,8 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||
_closure_id: chalk_ir::ClosureId<RustInterner<'tcx>>,
|
||||
substs: &chalk_ir::Substitution<RustInterner<'tcx>>,
|
||||
) -> chalk_ir::Substitution<RustInterner<'tcx>> {
|
||||
let substitution = &substs.as_slice(&self.interner)[0..substs.len(&self.interner) - 3];
|
||||
chalk_ir::Substitution::from_iter(&self.interner, substitution)
|
||||
let substitution = &substs.as_slice(self.interner)[0..substs.len(self.interner) - 3];
|
||||
chalk_ir::Substitution::from_iter(self.interner, substitution)
|
||||
}
|
||||
|
||||
fn generator_datum(
|
||||
|
@ -691,7 +693,7 @@ impl<'tcx> chalk_ir::UnificationDatabase<RustInterner<'tcx>> for RustIrDatabase<
|
|||
) -> chalk_ir::Variances<RustInterner<'tcx>> {
|
||||
let variances = self.interner.tcx.variances_of(def_id.0);
|
||||
chalk_ir::Variances::from_iter(
|
||||
&self.interner,
|
||||
self.interner,
|
||||
variances.iter().map(|v| match v {
|
||||
ty::Variance::Invariant => chalk_ir::Variance::Invariant,
|
||||
ty::Variance::Covariant => chalk_ir::Variance::Covariant,
|
||||
|
@ -707,7 +709,7 @@ impl<'tcx> chalk_ir::UnificationDatabase<RustInterner<'tcx>> for RustIrDatabase<
|
|||
) -> chalk_ir::Variances<RustInterner<'tcx>> {
|
||||
let variances = self.interner.tcx.variances_of(def_id.0.did);
|
||||
chalk_ir::Variances::from_iter(
|
||||
&self.interner,
|
||||
self.interner,
|
||||
variances.iter().map(|v| match v {
|
||||
ty::Variance::Invariant => chalk_ir::Variance::Invariant,
|
||||
ty::Variance::Covariant => chalk_ir::Variance::Covariant,
|
||||
|
@ -752,7 +754,7 @@ fn bound_vars_for_item(tcx: TyCtxt<'tcx>, def_id: DefId) -> SubstsRef<'tcx> {
|
|||
}
|
||||
|
||||
fn binders_for<'tcx>(
|
||||
interner: &RustInterner<'tcx>,
|
||||
interner: RustInterner<'tcx>,
|
||||
bound_vars: SubstsRef<'tcx>,
|
||||
) -> chalk_ir::VariableKinds<RustInterner<'tcx>> {
|
||||
chalk_ir::VariableKinds::from_iter(
|
||||
|
|
|
@ -46,26 +46,26 @@ use std::ops::ControlFlow;
|
|||
/// Essentially an `Into` with a `&RustInterner` parameter
|
||||
crate trait LowerInto<'tcx, T> {
|
||||
/// Lower a rustc construct (e.g., `ty::TraitPredicate`) to a chalk type, consuming `self`.
|
||||
fn lower_into(self, interner: &RustInterner<'tcx>) -> T;
|
||||
fn lower_into(self, interner: RustInterner<'tcx>) -> T;
|
||||
}
|
||||
|
||||
impl<'tcx> LowerInto<'tcx, chalk_ir::Substitution<RustInterner<'tcx>>> for SubstsRef<'tcx> {
|
||||
fn lower_into(
|
||||
self,
|
||||
interner: &RustInterner<'tcx>,
|
||||
interner: RustInterner<'tcx>,
|
||||
) -> chalk_ir::Substitution<RustInterner<'tcx>> {
|
||||
chalk_ir::Substitution::from_iter(interner, self.iter().map(|s| s.lower_into(interner)))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> LowerInto<'tcx, SubstsRef<'tcx>> for &chalk_ir::Substitution<RustInterner<'tcx>> {
|
||||
fn lower_into(self, interner: &RustInterner<'tcx>) -> SubstsRef<'tcx> {
|
||||
fn lower_into(self, interner: RustInterner<'tcx>) -> SubstsRef<'tcx> {
|
||||
interner.tcx.mk_substs(self.iter(interner).map(|subst| subst.lower_into(interner)))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> LowerInto<'tcx, chalk_ir::AliasTy<RustInterner<'tcx>>> for ty::ProjectionTy<'tcx> {
|
||||
fn lower_into(self, interner: &RustInterner<'tcx>) -> chalk_ir::AliasTy<RustInterner<'tcx>> {
|
||||
fn lower_into(self, interner: RustInterner<'tcx>) -> chalk_ir::AliasTy<RustInterner<'tcx>> {
|
||||
chalk_ir::AliasTy::Projection(chalk_ir::ProjectionTy {
|
||||
associated_ty_id: chalk_ir::AssocTypeId(self.item_def_id),
|
||||
substitution: self.substs.lower_into(interner),
|
||||
|
@ -78,7 +78,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'
|
|||
{
|
||||
fn lower_into(
|
||||
self,
|
||||
interner: &RustInterner<'tcx>,
|
||||
interner: RustInterner<'tcx>,
|
||||
) -> chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'tcx>>> {
|
||||
let clauses = self.environment.into_iter().map(|predicate| {
|
||||
let (predicate, binders, _named_regions) =
|
||||
|
@ -122,18 +122,18 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::InEnvironment<chalk_ir::Goal<RustInterner<'
|
|||
chalk_ir::ProgramClauseData(chalk_ir::Binders::new(binders, value)).intern(interner)
|
||||
});
|
||||
|
||||
let goal: chalk_ir::GoalData<RustInterner<'tcx>> = self.goal.lower_into(&interner);
|
||||
let goal: chalk_ir::GoalData<RustInterner<'tcx>> = self.goal.lower_into(interner);
|
||||
chalk_ir::InEnvironment {
|
||||
environment: chalk_ir::Environment {
|
||||
clauses: chalk_ir::ProgramClauses::from_iter(&interner, clauses),
|
||||
clauses: chalk_ir::ProgramClauses::from_iter(interner, clauses),
|
||||
},
|
||||
goal: goal.intern(&interner),
|
||||
goal: goal.intern(interner),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predicate<'tcx> {
|
||||
fn lower_into(self, interner: &RustInterner<'tcx>) -> chalk_ir::GoalData<RustInterner<'tcx>> {
|
||||
fn lower_into(self, interner: RustInterner<'tcx>) -> chalk_ir::GoalData<RustInterner<'tcx>> {
|
||||
let (predicate, binders, _named_regions) =
|
||||
collect_bound_vars(interner, interner.tcx, self.kind());
|
||||
|
||||
|
@ -214,7 +214,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GoalData<RustInterner<'tcx>>> for ty::Predi
|
|||
impl<'tcx> LowerInto<'tcx, chalk_ir::TraitRef<RustInterner<'tcx>>>
|
||||
for rustc_middle::ty::TraitRef<'tcx>
|
||||
{
|
||||
fn lower_into(self, interner: &RustInterner<'tcx>) -> chalk_ir::TraitRef<RustInterner<'tcx>> {
|
||||
fn lower_into(self, interner: RustInterner<'tcx>) -> chalk_ir::TraitRef<RustInterner<'tcx>> {
|
||||
chalk_ir::TraitRef {
|
||||
trait_id: chalk_ir::TraitId(self.def_id),
|
||||
substitution: self.substs.lower_into(interner),
|
||||
|
@ -225,7 +225,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::TraitRef<RustInterner<'tcx>>>
|
|||
impl<'tcx> LowerInto<'tcx, chalk_ir::AliasEq<RustInterner<'tcx>>>
|
||||
for rustc_middle::ty::ProjectionPredicate<'tcx>
|
||||
{
|
||||
fn lower_into(self, interner: &RustInterner<'tcx>) -> chalk_ir::AliasEq<RustInterner<'tcx>> {
|
||||
fn lower_into(self, interner: RustInterner<'tcx>) -> chalk_ir::AliasEq<RustInterner<'tcx>> {
|
||||
chalk_ir::AliasEq {
|
||||
ty: self.ty.lower_into(interner),
|
||||
alias: self.projection_ty.lower_into(interner),
|
||||
|
@ -234,7 +234,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::AliasEq<RustInterner<'tcx>>>
|
|||
}
|
||||
|
||||
impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
|
||||
fn lower_into(self, interner: &RustInterner<'tcx>) -> chalk_ir::Ty<RustInterner<'tcx>> {
|
||||
fn lower_into(self, interner: RustInterner<'tcx>) -> chalk_ir::Ty<RustInterner<'tcx>> {
|
||||
let int = |i| chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Int(i));
|
||||
let uint = |i| chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Uint(i));
|
||||
let float = |f| chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Float(f));
|
||||
|
@ -336,7 +336,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
|
||||
fn lower_into(self, interner: &RustInterner<'tcx>) -> Ty<'tcx> {
|
||||
fn lower_into(self, interner: RustInterner<'tcx>) -> Ty<'tcx> {
|
||||
use chalk_ir::TyKind;
|
||||
|
||||
let kind = match self.kind(interner) {
|
||||
|
@ -429,7 +429,7 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
|
|||
}
|
||||
|
||||
impl<'tcx> LowerInto<'tcx, chalk_ir::Lifetime<RustInterner<'tcx>>> for Region<'tcx> {
|
||||
fn lower_into(self, interner: &RustInterner<'tcx>) -> chalk_ir::Lifetime<RustInterner<'tcx>> {
|
||||
fn lower_into(self, interner: RustInterner<'tcx>) -> chalk_ir::Lifetime<RustInterner<'tcx>> {
|
||||
use rustc_middle::ty::RegionKind::*;
|
||||
|
||||
match self {
|
||||
|
@ -459,7 +459,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Lifetime<RustInterner<'tcx>>> for Region<'t
|
|||
}
|
||||
|
||||
impl<'tcx> LowerInto<'tcx, Region<'tcx>> for &chalk_ir::Lifetime<RustInterner<'tcx>> {
|
||||
fn lower_into(self, interner: &RustInterner<'tcx>) -> Region<'tcx> {
|
||||
fn lower_into(self, interner: RustInterner<'tcx>) -> Region<'tcx> {
|
||||
let kind = match self.data(interner) {
|
||||
chalk_ir::LifetimeData::BoundVar(var) => ty::RegionKind::ReLateBound(
|
||||
ty::DebruijnIndex::from_u32(var.debruijn.depth()),
|
||||
|
@ -487,7 +487,7 @@ impl<'tcx> LowerInto<'tcx, Region<'tcx>> for &chalk_ir::Lifetime<RustInterner<'t
|
|||
}
|
||||
|
||||
impl<'tcx> LowerInto<'tcx, chalk_ir::Const<RustInterner<'tcx>>> for ty::Const<'tcx> {
|
||||
fn lower_into(self, interner: &RustInterner<'tcx>) -> chalk_ir::Const<RustInterner<'tcx>> {
|
||||
fn lower_into(self, interner: RustInterner<'tcx>) -> chalk_ir::Const<RustInterner<'tcx>> {
|
||||
let ty = self.ty.lower_into(interner);
|
||||
let value = match self.val {
|
||||
ty::ConstKind::Value(val) => {
|
||||
|
@ -503,7 +503,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Const<RustInterner<'tcx>>> for ty::Const<'t
|
|||
}
|
||||
|
||||
impl<'tcx> LowerInto<'tcx, ty::Const<'tcx>> for &chalk_ir::Const<RustInterner<'tcx>> {
|
||||
fn lower_into(self, interner: &RustInterner<'tcx>) -> ty::Const<'tcx> {
|
||||
fn lower_into(self, interner: RustInterner<'tcx>) -> ty::Const<'tcx> {
|
||||
let data = self.data(interner);
|
||||
let ty = data.ty.lower_into(interner);
|
||||
let val = match data.value {
|
||||
|
@ -520,7 +520,7 @@ impl<'tcx> LowerInto<'tcx, ty::Const<'tcx>> for &chalk_ir::Const<RustInterner<'t
|
|||
}
|
||||
|
||||
impl<'tcx> LowerInto<'tcx, chalk_ir::GenericArg<RustInterner<'tcx>>> for GenericArg<'tcx> {
|
||||
fn lower_into(self, interner: &RustInterner<'tcx>) -> chalk_ir::GenericArg<RustInterner<'tcx>> {
|
||||
fn lower_into(self, interner: RustInterner<'tcx>) -> chalk_ir::GenericArg<RustInterner<'tcx>> {
|
||||
match self.unpack() {
|
||||
ty::subst::GenericArgKind::Type(ty) => {
|
||||
chalk_ir::GenericArgData::Ty(ty.lower_into(interner))
|
||||
|
@ -539,7 +539,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::GenericArg<RustInterner<'tcx>>> for Generic
|
|||
impl<'tcx> LowerInto<'tcx, ty::subst::GenericArg<'tcx>>
|
||||
for &chalk_ir::GenericArg<RustInterner<'tcx>>
|
||||
{
|
||||
fn lower_into(self, interner: &RustInterner<'tcx>) -> ty::subst::GenericArg<'tcx> {
|
||||
fn lower_into(self, interner: RustInterner<'tcx>) -> ty::subst::GenericArg<'tcx> {
|
||||
match self.data(interner) {
|
||||
chalk_ir::GenericArgData::Ty(ty) => {
|
||||
let t: Ty<'tcx> = ty.lower_into(interner);
|
||||
|
@ -566,7 +566,7 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_ir::QuantifiedWhereClause<RustInterner<'
|
|||
{
|
||||
fn lower_into(
|
||||
self,
|
||||
interner: &RustInterner<'tcx>,
|
||||
interner: RustInterner<'tcx>,
|
||||
) -> Option<chalk_ir::QuantifiedWhereClause<RustInterner<'tcx>>> {
|
||||
let (predicate, binders, _named_regions) =
|
||||
collect_bound_vars(interner, interner.tcx, self.kind());
|
||||
|
@ -610,7 +610,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Binders<chalk_ir::QuantifiedWhereClauses<Ru
|
|||
{
|
||||
fn lower_into(
|
||||
self,
|
||||
interner: &RustInterner<'tcx>,
|
||||
interner: RustInterner<'tcx>,
|
||||
) -> chalk_ir::Binders<chalk_ir::QuantifiedWhereClauses<RustInterner<'tcx>>> {
|
||||
// `Self` has one binder:
|
||||
// Binder<&'tcx ty::List<ty::ExistentialPredicate<'tcx>>>
|
||||
|
@ -680,7 +680,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Binders<chalk_ir::QuantifiedWhereClauses<Ru
|
|||
impl<'tcx> LowerInto<'tcx, chalk_ir::FnSig<RustInterner<'tcx>>>
|
||||
for ty::Binder<'tcx, ty::FnSig<'tcx>>
|
||||
{
|
||||
fn lower_into(self, _interner: &RustInterner<'_>) -> FnSig<RustInterner<'tcx>> {
|
||||
fn lower_into(self, _interner: RustInterner<'_>) -> FnSig<RustInterner<'tcx>> {
|
||||
chalk_ir::FnSig {
|
||||
abi: self.abi(),
|
||||
safety: match self.unsafety() {
|
||||
|
@ -700,7 +700,7 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_solve::rust_ir::QuantifiedInlineBound<Ru
|
|||
{
|
||||
fn lower_into(
|
||||
self,
|
||||
interner: &RustInterner<'tcx>,
|
||||
interner: RustInterner<'tcx>,
|
||||
) -> Option<chalk_solve::rust_ir::QuantifiedInlineBound<RustInterner<'tcx>>> {
|
||||
let (predicate, binders, _named_regions) =
|
||||
collect_bound_vars(interner, interner.tcx, self.kind());
|
||||
|
@ -737,7 +737,7 @@ impl<'tcx> LowerInto<'tcx, chalk_solve::rust_ir::TraitBound<RustInterner<'tcx>>>
|
|||
{
|
||||
fn lower_into(
|
||||
self,
|
||||
interner: &RustInterner<'tcx>,
|
||||
interner: RustInterner<'tcx>,
|
||||
) -> chalk_solve::rust_ir::TraitBound<RustInterner<'tcx>> {
|
||||
chalk_solve::rust_ir::TraitBound {
|
||||
trait_id: chalk_ir::TraitId(self.def_id),
|
||||
|
@ -747,7 +747,7 @@ impl<'tcx> LowerInto<'tcx, chalk_solve::rust_ir::TraitBound<RustInterner<'tcx>>>
|
|||
}
|
||||
|
||||
impl<'tcx> LowerInto<'tcx, chalk_ir::Mutability> for ast::Mutability {
|
||||
fn lower_into(self, _interner: &RustInterner<'tcx>) -> chalk_ir::Mutability {
|
||||
fn lower_into(self, _interner: RustInterner<'tcx>) -> chalk_ir::Mutability {
|
||||
match self {
|
||||
rustc_ast::Mutability::Mut => chalk_ir::Mutability::Mut,
|
||||
rustc_ast::Mutability::Not => chalk_ir::Mutability::Not,
|
||||
|
@ -756,7 +756,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Mutability> for ast::Mutability {
|
|||
}
|
||||
|
||||
impl<'tcx> LowerInto<'tcx, ast::Mutability> for chalk_ir::Mutability {
|
||||
fn lower_into(self, _interner: &RustInterner<'tcx>) -> ast::Mutability {
|
||||
fn lower_into(self, _interner: RustInterner<'tcx>) -> ast::Mutability {
|
||||
match self {
|
||||
chalk_ir::Mutability::Mut => ast::Mutability::Mut,
|
||||
chalk_ir::Mutability::Not => ast::Mutability::Not,
|
||||
|
@ -765,7 +765,7 @@ impl<'tcx> LowerInto<'tcx, ast::Mutability> for chalk_ir::Mutability {
|
|||
}
|
||||
|
||||
impl<'tcx> LowerInto<'tcx, chalk_solve::rust_ir::Polarity> for ty::ImplPolarity {
|
||||
fn lower_into(self, _interner: &RustInterner<'tcx>) -> chalk_solve::rust_ir::Polarity {
|
||||
fn lower_into(self, _interner: RustInterner<'tcx>) -> chalk_solve::rust_ir::Polarity {
|
||||
match self {
|
||||
ty::ImplPolarity::Positive => chalk_solve::rust_ir::Polarity::Positive,
|
||||
ty::ImplPolarity::Negative => chalk_solve::rust_ir::Polarity::Negative,
|
||||
|
@ -780,7 +780,7 @@ impl<'tcx> LowerInto<'tcx, chalk_solve::rust_ir::AliasEqBound<RustInterner<'tcx>
|
|||
{
|
||||
fn lower_into(
|
||||
self,
|
||||
interner: &RustInterner<'tcx>,
|
||||
interner: RustInterner<'tcx>,
|
||||
) -> chalk_solve::rust_ir::AliasEqBound<RustInterner<'tcx>> {
|
||||
let (trait_ref, own_substs) = self.projection_ty.trait_ref_and_own_substs(interner.tcx);
|
||||
chalk_solve::rust_ir::AliasEqBound {
|
||||
|
@ -802,7 +802,7 @@ impl<'tcx> LowerInto<'tcx, chalk_solve::rust_ir::AliasEqBound<RustInterner<'tcx>
|
|||
/// late-bound regions, even outside of fn contexts, since this is the best way
|
||||
/// to prep types for chalk lowering.
|
||||
crate fn collect_bound_vars<'tcx, T: TypeFoldable<'tcx>>(
|
||||
interner: &RustInterner<'tcx>,
|
||||
interner: RustInterner<'tcx>,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
ty: Binder<'tcx, T>,
|
||||
) -> (T, chalk_ir::VariableKinds<RustInterner<'tcx>>, BTreeMap<DefId, u32>) {
|
||||
|
|
|
@ -63,7 +63,7 @@ crate fn evaluate_goal<'tcx>(
|
|||
> = chalk_ir::UCanonical {
|
||||
canonical: chalk_ir::Canonical {
|
||||
binders: chalk_ir::CanonicalVarKinds::from_iter(
|
||||
&interner,
|
||||
interner,
|
||||
obligation.variables.iter().map(|v| match v.kind {
|
||||
CanonicalVarKind::PlaceholderTy(_ty) => unimplemented!(),
|
||||
CanonicalVarKind::PlaceholderRegion(_ui) => unimplemented!(),
|
||||
|
@ -89,7 +89,7 @@ crate fn evaluate_goal<'tcx>(
|
|||
CanonicalVarKind::PlaceholderConst(_pc) => unimplemented!(),
|
||||
}),
|
||||
),
|
||||
value: obligation.value.lower_into(&interner),
|
||||
value: obligation.value.lower_into(interner),
|
||||
},
|
||||
universes: max_universe + 1,
|
||||
};
|
||||
|
@ -110,11 +110,11 @@ crate fn evaluate_goal<'tcx>(
|
|||
use rustc_middle::infer::canonical::CanonicalVarInfo;
|
||||
|
||||
let mut var_values: IndexVec<BoundVar, GenericArg<'tcx>> = IndexVec::new();
|
||||
subst.as_slice(&interner).iter().for_each(|p| {
|
||||
var_values.push(p.lower_into(&interner));
|
||||
subst.as_slice(interner).iter().for_each(|p| {
|
||||
var_values.push(p.lower_into(interner));
|
||||
});
|
||||
let variables: Vec<_> = binders
|
||||
.iter(&interner)
|
||||
.iter(interner)
|
||||
.map(|var| {
|
||||
let kind = match var.kind {
|
||||
chalk_ir::VariableKind::Ty(ty_kind) => CanonicalVarKind::Ty(match ty_kind {
|
||||
|
@ -134,8 +134,7 @@ crate fn evaluate_goal<'tcx>(
|
|||
CanonicalVarInfo { kind }
|
||||
})
|
||||
.collect();
|
||||
let max_universe =
|
||||
binders.iter(&interner).map(|v| v.skip_kind().counter).max().unwrap_or(0);
|
||||
let max_universe = binders.iter(interner).map(|v| v.skip_kind().counter).max().unwrap_or(0);
|
||||
let sol = Canonical {
|
||||
max_universe: ty::UniverseIndex::from_usize(max_universe),
|
||||
variables: tcx.intern_canonical_var_infos(&variables),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue