Auto merge of #123537 - compiler-errors:shallow, r=lcnr
Simplify shallow resolver to just fold ty/consts Probably faster than using a whole folder?
This commit is contained in:
@@ -1173,8 +1173,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(_)
|
||||
@@ -1325,7 +1325,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 {
|
||||
|
||||
Reference in New Issue
Block a user