1
Fork 0

Unwrap the results of type folders

Co-authored-by: Alan Egerton <eggyal@gmail.com>
This commit is contained in:
LeSeulArtichaut 2021-05-19 15:03:43 +02:00 committed by Alan Egerton
parent 6dc3dae46f
commit 30bf20a692
No known key found for this signature in database
GPG key ID: 07CAC3CCA7E0643F
34 changed files with 191 additions and 167 deletions

View file

@ -45,7 +45,7 @@ impl<'tcx> RustIrDatabase<'tcx> {
predicates
.iter()
.map(|(wc, _)| wc.subst(self.interner.tcx, bound_vars))
.map(|wc| wc.fold_with(&mut regions_substitutor))
.map(|wc| wc.fold_with(&mut regions_substitutor).into_ok())
.filter_map(|wc| LowerInto::<Option<chalk_ir::QuantifiedWhereClause<RustInterner<'tcx>>>>::lower_into(wc, &self.interner)).collect()
}
@ -287,7 +287,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
let trait_ref = trait_ref.subst(self.interner.tcx, bound_vars);
let mut regions_substitutor =
lowering::RegionsSubstitutor::new(self.interner.tcx, self.reempty_placeholder);
let trait_ref = trait_ref.fold_with(&mut regions_substitutor);
let trait_ref = trait_ref.fold_with(&mut regions_substitutor).into_ok();
let where_clauses = self.where_clauses_for(def_id, bound_vars);
@ -335,7 +335,7 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
let self_ty = self_ty.subst(self.interner.tcx, bound_vars);
let mut regions_substitutor =
lowering::RegionsSubstitutor::new(self.interner.tcx, self.reempty_placeholder);
let self_ty = self_ty.fold_with(&mut regions_substitutor);
let self_ty = self_ty.fold_with(&mut regions_substitutor).into_ok();
let lowered_ty = self_ty.lower_into(&self.interner);
parameters[0].assert_ty_ref(&self.interner).could_match(
@ -501,22 +501,24 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
.iter()
.map(|(bound, _)| bound.subst(self.interner.tcx, &bound_vars))
.map(|bound| {
bound.fold_with(&mut ty::fold::BottomUpFolder {
tcx: self.interner.tcx,
ty_op: |ty| {
if let ty::Opaque(def_id, substs) = *ty.kind() {
if def_id == opaque_ty_id.0 && substs == identity_substs {
return self.interner.tcx.mk_ty(ty::Bound(
ty::INNERMOST,
ty::BoundTy::from(ty::BoundVar::from_u32(0)),
));
bound
.fold_with(&mut ty::fold::BottomUpFolder {
tcx: self.interner.tcx,
ty_op: |ty| {
if let ty::Opaque(def_id, substs) = *ty.kind() {
if def_id == opaque_ty_id.0 && substs == identity_substs {
return self.interner.tcx.mk_ty(ty::Bound(
ty::INNERMOST,
ty::BoundTy::from(ty::BoundVar::from_u32(0)),
));
}
}
}
ty
},
lt_op: |lt| lt,
ct_op: |ct| ct,
})
ty
},
lt_op: |lt| lt,
ct_op: |ct| ct,
})
.into_ok()
})
.filter_map(|bound| {
LowerInto::<

View file

@ -817,7 +817,7 @@ crate fn collect_bound_vars<'tcx, T: TypeFoldable<'tcx>>(
.collect();
let mut bound_var_substitutor = NamedBoundVarSubstitutor::new(tcx, &named_parameters);
let new_ty = ty.skip_binder().fold_with(&mut bound_var_substitutor);
let new_ty = ty.skip_binder().fold_with(&mut bound_var_substitutor).into_ok();
for var in named_parameters.values() {
parameters.insert(*var, chalk_ir::VariableKind::Lifetime);

View file

@ -49,12 +49,12 @@ crate fn evaluate_goal<'tcx>(
let mut params_substitutor =
ParamsSubstitutor::new(tcx, placeholders_collector.next_ty_placeholder);
let obligation = obligation.fold_with(&mut params_substitutor);
let obligation = obligation.fold_with(&mut params_substitutor).into_ok();
// FIXME(chalk): we really should be substituting these back in the solution
let _params: FxHashMap<usize, ParamTy> = params_substitutor.params;
let mut regions_substitutor = RegionsSubstitutor::new(tcx, reempty_placeholder);
let obligation = obligation.fold_with(&mut regions_substitutor);
let obligation = obligation.fold_with(&mut regions_substitutor).into_ok();
let max_universe = obligation.max_universe.index();

View file

@ -4,6 +4,7 @@
#![feature(crate_visibility_modifier)]
#![feature(in_band_lifetimes)]
#![feature(nll)]
#![feature(unwrap_infallible)]
#![recursion_limit = "256"]
#[macro_use]