Use infcx.partially_normalize_associated_types_in
This commit is contained in:
parent
341d8b8a2c
commit
3dee3aac78
4 changed files with 43 additions and 36 deletions
|
@ -9,6 +9,7 @@ use super::{
|
|||
};
|
||||
use crate::infer::error_reporting::{TyCategory, TypeAnnotationNeeded as ErrorCode};
|
||||
use crate::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||
use crate::infer::InferCtxtExt as _;
|
||||
use crate::infer::{self, InferCtxt, TyCtxtInferExt};
|
||||
use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
|
||||
use crate::traits::query::normalize::AtExt as _;
|
||||
|
@ -28,7 +29,7 @@ use rustc_hir::GenericParam;
|
|||
use rustc_hir::Item;
|
||||
use rustc_hir::Node;
|
||||
use rustc_infer::infer::error_reporting::TypeErrCtxt;
|
||||
use rustc_infer::infer::TypeTrace;
|
||||
use rustc_infer::infer::{InferOk, TypeTrace};
|
||||
use rustc_middle::traits::select::OverflowError;
|
||||
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
|
||||
use rustc_middle::ty::error::ExpectedFound;
|
||||
|
@ -2528,18 +2529,15 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
|
||||
self.probe(|_| {
|
||||
let mut selcx = SelectionContext::new(self);
|
||||
|
||||
let cleaned_pred =
|
||||
pred.fold_with(&mut ParamToVarFolder { infcx: self, var_map: Default::default() });
|
||||
|
||||
let cleaned_pred = super::project::normalize(
|
||||
&mut selcx,
|
||||
param_env,
|
||||
ObligationCause::dummy(),
|
||||
cleaned_pred,
|
||||
)
|
||||
.value;
|
||||
let InferOk { value: cleaned_pred, .. } =
|
||||
self.infcx.partially_normalize_associated_types_in(
|
||||
ObligationCause::dummy(),
|
||||
param_env,
|
||||
cleaned_pred,
|
||||
);
|
||||
|
||||
let obligation =
|
||||
Obligation::new(self.tcx, ObligationCause::dummy(), param_env, cleaned_pred);
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
use super::{
|
||||
DefIdOrName, Obligation, ObligationCause, ObligationCauseCode, PredicateObligation,
|
||||
SelectionContext,
|
||||
};
|
||||
use super::{DefIdOrName, Obligation, ObligationCause, ObligationCauseCode, PredicateObligation};
|
||||
|
||||
use crate::autoderef::Autoderef;
|
||||
use crate::infer::InferCtxt;
|
||||
use crate::traits::normalize_to;
|
||||
|
||||
use hir::def::CtorOf;
|
||||
use hir::HirId;
|
||||
|
@ -23,7 +19,7 @@ use rustc_hir::lang_items::LangItem;
|
|||
use rustc_hir::{AsyncGeneratorKind, GeneratorKind, Node};
|
||||
use rustc_infer::infer::error_reporting::TypeErrCtxt;
|
||||
use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
|
||||
use rustc_infer::infer::LateBoundRegionConversionTime;
|
||||
use rustc_infer::infer::{InferOk, LateBoundRegionConversionTime};
|
||||
use rustc_middle::hir::map;
|
||||
use rustc_middle::ty::{
|
||||
self, suggest_arbitrary_trait_bound, suggest_constraining_type_param, AdtKind, DefIdTree,
|
||||
|
@ -2986,13 +2982,12 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
self.tcx.mk_substs_trait(trait_pred.self_ty(), []),
|
||||
)
|
||||
});
|
||||
let projection_ty = normalize_to(
|
||||
&mut SelectionContext::new(self),
|
||||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
projection_ty,
|
||||
&mut vec![],
|
||||
);
|
||||
let InferOk { value: projection_ty, .. } = self
|
||||
.partially_normalize_associated_types_in(
|
||||
obligation.cause.clone(),
|
||||
obligation.param_env,
|
||||
projection_ty,
|
||||
);
|
||||
|
||||
debug!(
|
||||
normalized_projection_type = ?self.resolve_vars_if_possible(projection_ty)
|
||||
|
|
|
@ -8,7 +8,9 @@ use rustc_hir::def_id::DefId;
|
|||
use rustc_middle::ty::{self, ImplSubject, ToPredicate, Ty, TyCtxt, TypeVisitable};
|
||||
use rustc_middle::ty::{GenericArg, SubstsRef};
|
||||
|
||||
use super::{Normalized, Obligation, ObligationCause, PredicateObligation, SelectionContext};
|
||||
use super::{Obligation, ObligationCause, PredicateObligation, SelectionContext};
|
||||
use crate::infer::InferCtxtExt;
|
||||
use rustc_infer::infer::InferOk;
|
||||
pub use rustc_infer::traits::{self, util::*};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -200,13 +202,15 @@ pub fn impl_subject_and_oblig<'a, 'tcx>(
|
|||
) -> (ImplSubject<'tcx>, impl Iterator<Item = PredicateObligation<'tcx>>) {
|
||||
let subject = selcx.tcx().bound_impl_subject(impl_def_id);
|
||||
let subject = subject.subst(selcx.tcx(), impl_substs);
|
||||
let Normalized { value: subject, obligations: normalization_obligations1 } =
|
||||
super::normalize(selcx, param_env, ObligationCause::dummy(), subject);
|
||||
let InferOk { value: subject, obligations: normalization_obligations1 } = selcx
|
||||
.infcx()
|
||||
.partially_normalize_associated_types_in(ObligationCause::dummy(), param_env, subject);
|
||||
|
||||
let predicates = selcx.tcx().predicates_of(impl_def_id);
|
||||
let predicates = predicates.instantiate(selcx.tcx(), impl_substs);
|
||||
let Normalized { value: predicates, obligations: normalization_obligations2 } =
|
||||
super::normalize(selcx, param_env, ObligationCause::dummy(), predicates);
|
||||
let InferOk { value: predicates, obligations: normalization_obligations2 } = selcx
|
||||
.infcx()
|
||||
.partially_normalize_associated_types_in(ObligationCause::dummy(), param_env, predicates);
|
||||
let impl_obligations =
|
||||
super::predicates_for_generics(|_, _| ObligationCause::dummy(), param_env, predicates);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue