Simplify shallow resolver to just fold ty/consts
This commit is contained in:
parent
3493a56529
commit
ecef296a03
13 changed files with 96 additions and 125 deletions
|
@ -203,7 +203,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for NormalizationFolder<'_, 'tcx> {
|
|||
#[instrument(level = "debug", skip(self), ret)]
|
||||
fn try_fold_const(&mut self, ct: ty::Const<'tcx>) -> Result<ty::Const<'tcx>, Self::Error> {
|
||||
let infcx = self.at.infcx;
|
||||
debug_assert_eq!(ct, infcx.shallow_resolve(ct));
|
||||
debug_assert_eq!(ct, infcx.shallow_resolve_const(ct));
|
||||
if !ct.has_aliases() {
|
||||
return Ok(ct);
|
||||
}
|
||||
|
|
|
@ -501,7 +501,7 @@ fn plug_infer_with_placeholders<'tcx>(
|
|||
}
|
||||
|
||||
fn visit_const(&mut self, ct: ty::Const<'tcx>) {
|
||||
let ct = self.infcx.shallow_resolve(ct);
|
||||
let ct = self.infcx.shallow_resolve_const(ct);
|
||||
if ct.is_ct_infer() {
|
||||
let Ok(InferOk { value: (), obligations }) =
|
||||
self.infcx.at(&ObligationCause::dummy(), ty::ParamEnv::empty()).eq(
|
||||
|
|
|
@ -162,7 +162,7 @@ fn pred_known_to_hold_modulo_regions<'tcx>(
|
|||
let errors = ocx.select_all_or_error();
|
||||
match errors.as_slice() {
|
||||
// Only known to hold if we did no inference.
|
||||
[] => infcx.shallow_resolve(goal) == goal,
|
||||
[] => infcx.resolve_vars_if_possible(goal) == goal,
|
||||
|
||||
errors => {
|
||||
debug!(?errors);
|
||||
|
|
|
@ -1165,8 +1165,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
return;
|
||||
}
|
||||
|
||||
let self_ty = self.infcx.shallow_resolve(obligation.self_ty());
|
||||
match self_ty.skip_binder().kind() {
|
||||
let self_ty = self.infcx.shallow_resolve(obligation.self_ty().skip_binder());
|
||||
match self_ty.kind() {
|
||||
ty::Alias(..)
|
||||
| ty::Dynamic(..)
|
||||
| ty::Error(_)
|
||||
|
@ -1317,7 +1317,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
obligation: &PolyTraitObligation<'tcx>,
|
||||
candidates: &mut SelectionCandidateSet<'tcx>,
|
||||
) {
|
||||
let self_ty = self.infcx.shallow_resolve(obligation.self_ty());
|
||||
let self_ty = self.infcx.resolve_vars_if_possible(obligation.self_ty());
|
||||
|
||||
match self_ty.skip_binder().kind() {
|
||||
ty::FnPtr(_) => candidates.vec.push(BuiltinCandidate { has_nested: false }),
|
||||
|
|
|
@ -157,10 +157,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
) -> Result<Vec<PredicateObligation<'tcx>>, SelectionError<'tcx>> {
|
||||
let tcx = self.tcx();
|
||||
|
||||
let trait_predicate = self.infcx.shallow_resolve(obligation.predicate);
|
||||
let placeholder_trait_predicate =
|
||||
self.infcx.enter_forall_and_leak_universe(trait_predicate).trait_ref;
|
||||
let placeholder_self_ty = placeholder_trait_predicate.self_ty();
|
||||
self.infcx.enter_forall_and_leak_universe(obligation.predicate).trait_ref;
|
||||
let placeholder_self_ty = self.infcx.shallow_resolve(placeholder_trait_predicate.self_ty());
|
||||
let candidate_predicate = self
|
||||
.for_each_item_bound(
|
||||
placeholder_self_ty,
|
||||
|
@ -422,7 +421,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
) -> Result<Vec<PredicateObligation<'tcx>>, SelectionError<'tcx>> {
|
||||
debug!(?obligation, "confirm_auto_impl_candidate");
|
||||
|
||||
let self_ty = self.infcx.shallow_resolve(obligation.predicate.self_ty());
|
||||
let self_ty = obligation.predicate.self_ty().map_bound(|ty| self.infcx.shallow_resolve(ty));
|
||||
let types = self.constituent_types_for_ty(self_ty)?;
|
||||
Ok(self.vtable_auto_impl(obligation, obligation.predicate.def_id(), types))
|
||||
}
|
||||
|
@ -1378,7 +1377,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let drop_trait = self.tcx().require_lang_item(LangItem::Drop, None);
|
||||
|
||||
let tcx = self.tcx();
|
||||
let self_ty = self.infcx.shallow_resolve(obligation.self_ty());
|
||||
let self_ty = obligation.self_ty().map_bound(|ty| self.infcx.shallow_resolve(ty));
|
||||
|
||||
let mut nested = vec![];
|
||||
let cause = obligation.derived_cause(BuiltinDerivedObligation);
|
||||
|
|
|
@ -571,7 +571,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
)?;
|
||||
// If the predicate has done any inference, then downgrade the
|
||||
// result to ambiguous.
|
||||
if this.infcx.shallow_resolve(goal) != goal {
|
||||
if this.infcx.resolve_vars_if_possible(goal) != goal {
|
||||
result = result.max(EvaluatedToAmbig);
|
||||
}
|
||||
Ok(result)
|
||||
|
@ -1774,9 +1774,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
// that means that we must have newly inferred something about the GAT.
|
||||
// We should give up in that case.
|
||||
if !generics.params.is_empty()
|
||||
&& obligation.predicate.args[generics.parent_count..]
|
||||
.iter()
|
||||
.any(|&p| p.has_non_region_infer() && self.infcx.shallow_resolve(p) != p)
|
||||
&& obligation.predicate.args[generics.parent_count..].iter().any(|&p| {
|
||||
p.has_non_region_infer() && self.infcx.resolve_vars_if_possible(p) != p
|
||||
})
|
||||
{
|
||||
ProjectionMatchesProjection::Ambiguous
|
||||
} else {
|
||||
|
|
|
@ -649,7 +649,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
|
|||
}
|
||||
|
||||
fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
|
||||
let ct = self.infcx.shallow_resolve(ct);
|
||||
let ct = self.infcx.shallow_resolve_const(ct);
|
||||
if let ty::ConstKind::Placeholder(p) = ct.kind() {
|
||||
let replace_var = self.mapped_consts.get(&p);
|
||||
match replace_var {
|
||||
|
|
|
@ -44,7 +44,7 @@ pub fn obligations<'tcx>(
|
|||
GenericArgKind::Const(ct) => {
|
||||
match ct.kind() {
|
||||
ty::ConstKind::Infer(_) => {
|
||||
let resolved = infcx.shallow_resolve(ct);
|
||||
let resolved = infcx.shallow_resolve_const(ct);
|
||||
if resolved == ct {
|
||||
// No progress.
|
||||
return None;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue