Some rebinds and dummys
This commit is contained in:
parent
a5029ac0ab
commit
4955d755d3
9 changed files with 29 additions and 20 deletions
|
@ -50,7 +50,10 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> {
|
||||||
|
|
||||||
debug!("higher_ranked_sub: OK result={:?}", result);
|
debug!("higher_ranked_sub: OK result={:?}", result);
|
||||||
|
|
||||||
Ok(ty::Binder::bind(result))
|
// We related `a_prime` and `b_prime`, which just had any bound vars
|
||||||
|
// replaced with placeholders or infer vars, respectively. Relating
|
||||||
|
// them should not introduce new bound vars.
|
||||||
|
Ok(ty::Binder::dummy(result))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -619,10 +619,9 @@ impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'
|
||||||
let v = iter::zip(a_v, b_v).map(|(ep_a, ep_b)| {
|
let v = iter::zip(a_v, b_v).map(|(ep_a, ep_b)| {
|
||||||
use crate::ty::ExistentialPredicate::*;
|
use crate::ty::ExistentialPredicate::*;
|
||||||
match (ep_a.skip_binder(), ep_b.skip_binder()) {
|
match (ep_a.skip_binder(), ep_b.skip_binder()) {
|
||||||
(Trait(a), Trait(b)) => Ok(ty::Binder::bind(Trait(
|
(Trait(a), Trait(b)) => Ok(ep_a
|
||||||
relation.relate(ep_a.rebind(a), ep_b.rebind(b))?.skip_binder(),
|
.rebind(Trait(relation.relate(ep_a.rebind(a), ep_b.rebind(b))?.skip_binder()))),
|
||||||
))),
|
(Projection(a), Projection(b)) => Ok(ep_a.rebind(Projection(
|
||||||
(Projection(a), Projection(b)) => Ok(ty::Binder::bind(Projection(
|
|
||||||
relation.relate(ep_a.rebind(a), ep_b.rebind(b))?.skip_binder(),
|
relation.relate(ep_a.rebind(a), ep_b.rebind(b))?.skip_binder(),
|
||||||
))),
|
))),
|
||||||
(AutoTrait(a), AutoTrait(b)) if a == b => Ok(ep_a.rebind(AutoTrait(a))),
|
(AutoTrait(a), AutoTrait(b)) if a == b => Ok(ep_a.rebind(AutoTrait(a))),
|
||||||
|
|
|
@ -2028,7 +2028,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||||
traits::ObligationCauseCode::RepeatVec(is_const_fn),
|
traits::ObligationCauseCode::RepeatVec(is_const_fn),
|
||||||
),
|
),
|
||||||
self.param_env,
|
self.param_env,
|
||||||
ty::Binder::bind(ty::TraitRef::new(
|
ty::Binder::dummy(ty::TraitRef::new(
|
||||||
self.tcx().require_lang_item(
|
self.tcx().require_lang_item(
|
||||||
LangItem::Copy,
|
LangItem::Copy,
|
||||||
Some(self.last_span),
|
Some(self.last_span),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use rustc_middle::traits;
|
use rustc_middle::traits;
|
||||||
use rustc_middle::ty::adjustment::CustomCoerceUnsized;
|
use rustc_middle::ty::adjustment::CustomCoerceUnsized;
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable};
|
||||||
|
|
||||||
use rustc_hir::lang_items::LangItem;
|
use rustc_hir::lang_items::LangItem;
|
||||||
|
|
||||||
|
@ -8,14 +8,16 @@ pub mod collector;
|
||||||
pub mod partitioning;
|
pub mod partitioning;
|
||||||
pub mod polymorphize;
|
pub mod polymorphize;
|
||||||
|
|
||||||
pub fn custom_coerce_unsize_info<'tcx>(
|
fn custom_coerce_unsize_info<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
source_ty: Ty<'tcx>,
|
source_ty: Ty<'tcx>,
|
||||||
target_ty: Ty<'tcx>,
|
target_ty: Ty<'tcx>,
|
||||||
) -> CustomCoerceUnsized {
|
) -> CustomCoerceUnsized {
|
||||||
let def_id = tcx.require_lang_item(LangItem::CoerceUnsized, None);
|
let def_id = tcx.require_lang_item(LangItem::CoerceUnsized, None);
|
||||||
|
|
||||||
let trait_ref = ty::Binder::bind(ty::TraitRef {
|
debug_assert!(!source_ty.has_escaping_bound_vars());
|
||||||
|
debug_assert!(!target_ty.has_escaping_bound_vars());
|
||||||
|
let trait_ref = ty::Binder::dummy(ty::TraitRef {
|
||||||
def_id,
|
def_id,
|
||||||
substs: tcx.mk_substs_trait(source_ty, &[target_ty.into()]),
|
substs: tcx.mk_substs_trait(source_ty, &[target_ty.into()]),
|
||||||
});
|
});
|
||||||
|
|
|
@ -82,9 +82,10 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
||||||
) -> AutoTraitResult<A> {
|
) -> AutoTraitResult<A> {
|
||||||
let tcx = self.tcx;
|
let tcx = self.tcx;
|
||||||
|
|
||||||
|
debug_assert!(!ty.has_escaping_bound_vars());
|
||||||
let trait_ref = ty::TraitRef { def_id: trait_did, substs: tcx.mk_substs_trait(ty, &[]) };
|
let trait_ref = ty::TraitRef { def_id: trait_did, substs: tcx.mk_substs_trait(ty, &[]) };
|
||||||
|
|
||||||
let trait_pred = ty::Binder::bind(trait_ref);
|
let trait_pred = ty::Binder::dummy(trait_ref);
|
||||||
|
|
||||||
let bail_out = tcx.infer_ctxt().enter(|infcx| {
|
let bail_out = tcx.infer_ctxt().enter(|infcx| {
|
||||||
let mut selcx = SelectionContext::with_negative(&infcx, true);
|
let mut selcx = SelectionContext::with_negative(&infcx, true);
|
||||||
|
@ -280,7 +281,7 @@ impl AutoTraitFinder<'tcx> {
|
||||||
|
|
||||||
let mut already_visited = FxHashSet::default();
|
let mut already_visited = FxHashSet::default();
|
||||||
let mut predicates = VecDeque::new();
|
let mut predicates = VecDeque::new();
|
||||||
predicates.push_back(ty::Binder::bind(ty::TraitPredicate {
|
predicates.push_back(ty::Binder::dummy(ty::TraitPredicate {
|
||||||
trait_ref: ty::TraitRef {
|
trait_ref: ty::TraitRef {
|
||||||
def_id: trait_did,
|
def_id: trait_did,
|
||||||
substs: infcx.tcx.mk_substs_trait(ty, &[]),
|
substs: infcx.tcx.mk_substs_trait(ty, &[]),
|
||||||
|
|
|
@ -757,7 +757,7 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeFoldable<'tcx>>(
|
||||||
struct IllegalSelfTypeVisitor<'tcx> {
|
struct IllegalSelfTypeVisitor<'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
trait_def_id: DefId,
|
trait_def_id: DefId,
|
||||||
supertraits: Option<Vec<ty::PolyTraitRef<'tcx>>>,
|
supertraits: Option<Vec<DefId>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TypeVisitor<'tcx> for IllegalSelfTypeVisitor<'tcx> {
|
impl<'tcx> TypeVisitor<'tcx> for IllegalSelfTypeVisitor<'tcx> {
|
||||||
|
@ -778,8 +778,10 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeFoldable<'tcx>>(
|
||||||
// Compute supertraits of current trait lazily.
|
// Compute supertraits of current trait lazily.
|
||||||
if self.supertraits.is_none() {
|
if self.supertraits.is_none() {
|
||||||
let trait_ref =
|
let trait_ref =
|
||||||
ty::Binder::bind(ty::TraitRef::identity(self.tcx, self.trait_def_id));
|
ty::Binder::dummy(ty::TraitRef::identity(self.tcx, self.trait_def_id));
|
||||||
self.supertraits = Some(traits::supertraits(self.tcx, trait_ref).collect());
|
self.supertraits = Some(
|
||||||
|
traits::supertraits(self.tcx, trait_ref).map(|t| t.def_id()).collect(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine whether the trait reference `Foo as
|
// Determine whether the trait reference `Foo as
|
||||||
|
@ -790,9 +792,11 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeFoldable<'tcx>>(
|
||||||
// direct equality here because all of these types
|
// direct equality here because all of these types
|
||||||
// are part of the formal parameter listing, and
|
// are part of the formal parameter listing, and
|
||||||
// hence there should be no inference variables.
|
// hence there should be no inference variables.
|
||||||
let projection_trait_ref = ty::Binder::bind(data.trait_ref(self.tcx));
|
let is_supertrait_of_current_trait = self
|
||||||
let is_supertrait_of_current_trait =
|
.supertraits
|
||||||
self.supertraits.as_ref().unwrap().contains(&projection_trait_ref);
|
.as_ref()
|
||||||
|
.unwrap()
|
||||||
|
.contains(&data.trait_ref(self.tcx).def_id);
|
||||||
|
|
||||||
if is_supertrait_of_current_trait {
|
if is_supertrait_of_current_trait {
|
||||||
ControlFlow::CONTINUE // do not walk contained types, do not report error, do collect $200
|
ControlFlow::CONTINUE // do not walk contained types, do not report error, do collect $200
|
||||||
|
|
|
@ -748,7 +748,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
cause,
|
cause,
|
||||||
obligation.recursion_depth + 1,
|
obligation.recursion_depth + 1,
|
||||||
obligation.param_env,
|
obligation.param_env,
|
||||||
ty::Binder::bind(outlives).to_predicate(tcx),
|
obligation.predicate.rebind(outlives).to_predicate(tcx),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1090,7 +1090,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||||
let late_bound_in_trait_ref =
|
let late_bound_in_trait_ref =
|
||||||
tcx.collect_constrained_late_bound_regions(&projection_ty);
|
tcx.collect_constrained_late_bound_regions(&projection_ty);
|
||||||
let late_bound_in_ty =
|
let late_bound_in_ty =
|
||||||
tcx.collect_referenced_late_bound_regions(&ty::Binder::bind(ty));
|
tcx.collect_referenced_late_bound_regions(&trait_ref.rebind(ty));
|
||||||
debug!("late_bound_in_trait_ref = {:?}", late_bound_in_trait_ref);
|
debug!("late_bound_in_trait_ref = {:?}", late_bound_in_trait_ref);
|
||||||
debug!("late_bound_in_ty = {:?}", late_bound_in_ty);
|
debug!("late_bound_in_ty = {:?}", late_bound_in_ty);
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ impl<'tcx> Bounds<'tcx> {
|
||||||
// If it could be sized, and is, add the `Sized` predicate.
|
// If it could be sized, and is, add the `Sized` predicate.
|
||||||
let sized_predicate = self.implicitly_sized.and_then(|span| {
|
let sized_predicate = self.implicitly_sized.and_then(|span| {
|
||||||
tcx.lang_items().sized_trait().map(|sized| {
|
tcx.lang_items().sized_trait().map(|sized| {
|
||||||
let trait_ref = ty::Binder::bind(ty::TraitRef {
|
let trait_ref = ty::Binder::dummy(ty::TraitRef {
|
||||||
def_id: sized,
|
def_id: sized,
|
||||||
substs: tcx.mk_substs_trait(param_ty, &[]),
|
substs: tcx.mk_substs_trait(param_ty, &[]),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue