Add bound_impl_trait_ref
This commit is contained in:
parent
6c05e8d009
commit
0247faed29
8 changed files with 28 additions and 25 deletions
|
@ -23,7 +23,7 @@ use rustc_middle::traits::specialization_graph::OverlapMode;
|
|||
use rustc_middle::ty::fast_reject::{self, TreatParams};
|
||||
use rustc_middle::ty::fold::TypeFoldable;
|
||||
use rustc_middle::ty::subst::Subst;
|
||||
use rustc_middle::ty::{self, EarlyBinder, ImplSubject, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{self, ImplSubject, Ty, TyCtxt};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::DUMMY_SP;
|
||||
use std::fmt::Debug;
|
||||
|
@ -136,7 +136,7 @@ fn with_fresh_ty_vars<'cx, 'tcx>(
|
|||
let header = ty::ImplHeader {
|
||||
impl_def_id,
|
||||
self_ty: tcx.bound_type_of(impl_def_id).subst(tcx, impl_substs),
|
||||
trait_ref: EarlyBinder(tcx.impl_trait_ref(impl_def_id)).subst(tcx, impl_substs),
|
||||
trait_ref: tcx.bound_impl_trait_ref(impl_def_id).map(|i| i.subst(tcx, impl_substs)),
|
||||
predicates: tcx.predicates_of(impl_def_id).instantiate(tcx, impl_substs).predicates,
|
||||
};
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::infer::InferCtxt;
|
|||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::ty::subst::{Subst, SubstsRef};
|
||||
use rustc_middle::ty::{self, EarlyBinder, GenericParamDefKind};
|
||||
use rustc_middle::ty::{self, GenericParamDefKind};
|
||||
use rustc_span::symbol::sym;
|
||||
use std::iter;
|
||||
|
||||
|
@ -45,8 +45,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||
|
||||
self.tcx.for_each_relevant_impl(trait_ref.def_id, trait_self_ty, |def_id| {
|
||||
let impl_substs = self.fresh_substs_for_item(obligation.cause.span, def_id);
|
||||
let impl_trait_ref =
|
||||
EarlyBinder(tcx.impl_trait_ref(def_id).unwrap()).subst(tcx, impl_substs);
|
||||
let impl_trait_ref = tcx.bound_impl_trait_ref(def_id).unwrap().subst(tcx, impl_substs);
|
||||
|
||||
let impl_self_ty = impl_trait_ref.self_ty();
|
||||
|
||||
|
|
|
@ -2066,12 +2066,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
impl_def_id: DefId,
|
||||
obligation: &TraitObligation<'tcx>,
|
||||
) -> Result<Normalized<'tcx, SubstsRef<'tcx>>, ()> {
|
||||
let impl_trait_ref = self.tcx().impl_trait_ref(impl_def_id).unwrap();
|
||||
let impl_trait_ref = self.tcx().bound_impl_trait_ref(impl_def_id).unwrap();
|
||||
|
||||
// Before we create the substitutions and everything, first
|
||||
// consider a "quick reject". This avoids creating more types
|
||||
// and so forth that we need to.
|
||||
if self.fast_reject_trait_refs(obligation, &impl_trait_ref) {
|
||||
if self.fast_reject_trait_refs(obligation, &impl_trait_ref.0) {
|
||||
return Err(());
|
||||
}
|
||||
|
||||
|
@ -2081,7 +2081,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
|
||||
let impl_substs = self.infcx.fresh_substs_for_item(obligation.cause.span, impl_def_id);
|
||||
|
||||
let impl_trait_ref = EarlyBinder(impl_trait_ref).subst(self.tcx(), impl_substs);
|
||||
let impl_trait_ref = impl_trait_ref.subst(self.tcx(), impl_substs);
|
||||
|
||||
debug!(?impl_trait_ref);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ use rustc_errors::{struct_span_err, EmissionGuarantee};
|
|||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
use rustc_middle::lint::LintDiagnosticBuilder;
|
||||
use rustc_middle::ty::subst::{InternalSubsts, Subst, SubstsRef};
|
||||
use rustc_middle::ty::{self, EarlyBinder, ImplSubject, TyCtxt};
|
||||
use rustc_middle::ty::{self, ImplSubject, TyCtxt};
|
||||
use rustc_session::lint::builtin::COHERENCE_LEAK_CHECK;
|
||||
use rustc_session::lint::builtin::ORDER_DEPENDENT_TRAIT_OBJECTS;
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
|
@ -84,8 +84,8 @@ pub fn translate_substs<'a, 'tcx>(
|
|||
"translate_substs({:?}, {:?}, {:?}, {:?})",
|
||||
param_env, source_impl, source_substs, target_node
|
||||
);
|
||||
let source_trait_ref = EarlyBinder(infcx.tcx.impl_trait_ref(source_impl).unwrap())
|
||||
.subst(infcx.tcx, &source_substs);
|
||||
let source_trait_ref =
|
||||
infcx.tcx.bound_impl_trait_ref(source_impl).unwrap().subst(infcx.tcx, &source_substs);
|
||||
|
||||
// translate the Self and Param parts of the substitution, since those
|
||||
// vary across impls
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue