提交 6eb4f1d0 编写于 作者: B bors

Auto merge of #50016 - tmandry:cleanup-binder, r=nikomatsakis

Make Binder's field private and clean up its usage

AKA "tour de rustc"

Closes #49814.
......@@ -262,8 +262,7 @@ impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>> for ty::Binder<T>
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>) {
let ty::Binder(ref inner) = *self;
inner.hash_stable(hcx, hasher);
self.skip_binder().hash_stable(hcx, hasher);
}
}
......
......@@ -388,14 +388,16 @@ fn query_region_constraints_into_obligations<'a>(
Obligation::new(
cause.clone(),
param_env,
ty::Predicate::RegionOutlives(ty::Binder(ty::OutlivesPredicate(r1, r2))),
ty::Predicate::RegionOutlives(
ty::Binder::dummy(ty::OutlivesPredicate(r1, r2))),
),
UnpackedKind::Type(t1) =>
Obligation::new(
cause.clone(),
param_env,
ty::Predicate::TypeOutlives(ty::Binder(ty::OutlivesPredicate(t1, r2))),
ty::Predicate::TypeOutlives(
ty::Binder::dummy(ty::OutlivesPredicate(t1, r2))),
),
}
})) as Box<dyn Iterator<Item = _>>
......
......@@ -302,7 +302,7 @@ struct Generalizer<'cx, 'gcx: 'cx+'tcx, 'tcx: 'cx> {
/// Result from a generalization operation. This includes
/// not only the generalized type, but also a bool flag
/// indicating whether further WF checks are needed.q
/// indicating whether further WF checks are needed.
struct Generalization<'tcx> {
ty: Ty<'tcx>,
......@@ -351,7 +351,7 @@ fn binders<T>(&mut self, a: &ty::Binder<T>, b: &ty::Binder<T>)
-> RelateResult<'tcx, ty::Binder<T>>
where T: Relate<'tcx>
{
Ok(ty::Binder(self.relate(a.skip_binder(), b.skip_binder())?))
Ok(ty::Binder::bind(self.relate(a.skip_binder(), b.skip_binder())?))
}
fn relate_item_substs(&mut self,
......
......@@ -916,7 +916,7 @@ pub fn note_type_err(
};
if let (Some(def_id), Some(ret_ty)) = (def_id, ret_ty) {
if exp_is_struct && exp_found.expected == ret_ty.0 {
if exp_is_struct && &exp_found.expected == ret_ty.skip_binder() {
let message = format!(
"did you mean `{}(/* fields */)`?",
self.tcx.item_path_str(def_id)
......
......@@ -80,7 +80,7 @@ pub fn higher_ranked_sub<T>(&mut self, a: &Binder<T>, b: &Binder<T>, a_is_expect
debug!("higher_ranked_sub: OK result={:?}", result);
Ok(ty::Binder(result))
Ok(ty::Binder::bind(result))
});
}
......@@ -239,7 +239,7 @@ pub fn higher_ranked_lub<T>(&mut self, a: &Binder<T>, b: &Binder<T>, a_is_expect
b,
result1);
Ok(ty::Binder(result1))
Ok(ty::Binder::bind(result1))
});
fn generalize_region<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
......@@ -335,7 +335,7 @@ pub fn higher_ranked_glb<T>(&mut self, a: &Binder<T>, b: &Binder<T>, a_is_expect
b,
result1);
Ok(ty::Binder(result1))
Ok(ty::Binder::bind(result1))
});
fn generalize_region<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
......
......@@ -98,7 +98,7 @@ fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
self.fields.trace.cause.clone(),
self.fields.param_env,
ty::Predicate::Subtype(
ty::Binder(ty::SubtypePredicate {
ty::Binder::dummy(ty::SubtypePredicate {
a_is_expected: self.a_is_expected,
a,
b,
......
......@@ -537,7 +537,7 @@ fn get_parent_trait_ref(&self, code: &ObligationCauseCode<'tcx>) -> Option<Strin
&data.parent_trait_ref);
match self.get_parent_trait_ref(&data.parent_code) {
Some(t) => Some(t),
None => Some(format!("{}", parent_trait_ref.0.self_ty())),
None => Some(format!("{}", parent_trait_ref.skip_binder().self_ty())),
}
}
_ => None,
......@@ -862,7 +862,7 @@ fn suggest_remove_reference(&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'tcx>,
trait_ref: &ty::Binder<ty::TraitRef<'tcx>>) {
let ty::Binder(trait_ref) = trait_ref;
let trait_ref = trait_ref.skip_binder();
let span = obligation.cause.span;
if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(span) {
......@@ -1102,7 +1102,7 @@ fn build_fn_sig_string<'a, 'gcx, 'tcx>(tcx: ty::TyCtxt<'a, 'gcx, 'tcx>,
::syntax::abi::Abi::Rust
)
};
format!("{}", ty::Binder(sig))
format!("{}", ty::Binder::bind(sig))
}
let argument_is_closure = expected_ref.skip_binder().substs.type_at(0).is_closure();
......@@ -1436,7 +1436,7 @@ fn note_obligation_cause_code<T>(&self,
}
ObligationCauseCode::BuiltinDerivedObligation(ref data) => {
let parent_trait_ref = self.resolve_type_vars_if_possible(&data.parent_trait_ref);
let ty = parent_trait_ref.0.self_ty();
let ty = parent_trait_ref.skip_binder().self_ty();
err.note(&format!("required because it appears within the type `{}`", ty));
obligated_types.push(ty);
......@@ -1453,7 +1453,7 @@ fn note_obligation_cause_code<T>(&self,
err.note(
&format!("required because of the requirements on the impl of `{}` for `{}`",
parent_trait_ref,
parent_trait_ref.0.self_ty()));
parent_trait_ref.skip_binder().self_ty()));
let parent_predicate = parent_trait_ref.to_predicate();
self.note_obligation_cause_code(err,
&parent_predicate,
......@@ -1484,7 +1484,7 @@ fn is_recursive_obligation(&self,
if let ObligationCauseCode::BuiltinDerivedObligation(ref data) = cause_code {
let parent_trait_ref = self.resolve_type_vars_if_possible(&data.parent_trait_ref);
for obligated_type in obligated_types {
if obligated_type == &parent_trait_ref.0.self_ty() {
if obligated_type == &parent_trait_ref.skip_binder().self_ty() {
return true;
}
}
......
......@@ -855,16 +855,19 @@ fn vtable_methods<'a, 'tcx>(
// the method may have some early-bound lifetimes, add
// regions for those
let substs = Substs::for_item(tcx, def_id,
|_, _| tcx.types.re_erased,
|def, _| trait_ref.substs().type_for_def(def));
let substs = trait_ref.map_bound(|trait_ref| {
Substs::for_item(
tcx, def_id,
|_, _| tcx.types.re_erased,
|def, _| trait_ref.substs.type_for_def(def))
});
// the trait type may have higher-ranked lifetimes in it;
// so erase them if they appear, so that we get the type
// at some particular call site
let substs = tcx.normalize_erasing_late_bound_regions(
ty::ParamEnv::reveal_all(),
&ty::Binder(substs),
&substs
);
// It's possible that the method relies on where clauses that
......@@ -997,7 +1000,7 @@ fn new(obligation: PredicateObligation<'tcx>,
impl<'tcx> TraitObligation<'tcx> {
fn self_ty(&self) -> ty::Binder<Ty<'tcx>> {
ty::Binder(self.predicate.skip_binder().self_ty())
self.predicate.map_bound(|p| p.self_ty())
}
}
......
......@@ -149,7 +149,7 @@ fn predicates_reference_self(
trait_def_id: DefId,
supertraits_only: bool) -> bool
{
let trait_ref = ty::Binder(ty::TraitRef {
let trait_ref = ty::Binder::dummy(ty::TraitRef {
def_id: trait_def_id,
substs: Substs::identity_for_item(self, trait_def_id)
});
......@@ -199,7 +199,7 @@ fn generics_require_sized_self(self, def_id: DefId) -> bool {
.any(|predicate| {
match predicate {
ty::Predicate::Trait(ref trait_pred) if trait_pred.def_id() == sized_def_id => {
trait_pred.0.self_ty().is_self()
trait_pred.skip_binder().self_ty().is_self()
}
ty::Predicate::Projection(..) |
ty::Predicate::Trait(..) |
......@@ -352,7 +352,7 @@ fn contains_illegal_self_type_reference(self,
// Compute supertraits of current trait lazily.
if supertraits.is_none() {
let trait_ref = ty::Binder(ty::TraitRef {
let trait_ref = ty::Binder::bind(ty::TraitRef {
def_id: trait_def_id,
substs: Substs::identity_for_item(self, trait_def_id)
});
......@@ -367,7 +367,7 @@ fn contains_illegal_self_type_reference(self,
// direct equality here because all of these types
// are part of the formal parameter listing, and
// hence there should be no inference variables.
let projection_trait_ref = ty::Binder(data.trait_ref(self));
let projection_trait_ref = ty::Binder::bind(data.trait_ref(self));
let is_supertrait_of_current_trait =
supertraits.as_ref().unwrap().contains(&projection_trait_ref);
......
......@@ -478,7 +478,7 @@ pub fn normalize_projection_type<'a, 'b, 'gcx, 'tcx>(
let def_id = projection_ty.item_def_id;
let ty_var = selcx.infcx().next_ty_var(
TypeVariableOrigin::NormalizeProjectionType(tcx.def_span(def_id)));
let projection = ty::Binder(ty::ProjectionPredicate {
let projection = ty::Binder::dummy(ty::ProjectionPredicate {
projection_ty,
ty: ty_var
});
......@@ -982,8 +982,7 @@ fn assemble_candidates_from_predicates<'cx, 'gcx, 'tcx, I>(
predicate);
match predicate {
ty::Predicate::Projection(data) => {
let same_def_id =
data.0.projection_ty.item_def_id == obligation.predicate.item_def_id;
let same_def_id = data.projection_def_id() == obligation.predicate.item_def_id;
let is_match = same_def_id && infcx.probe(|_| {
let data_poly_trait_ref =
......@@ -1241,7 +1240,7 @@ fn confirm_object_candidate<'cx, 'gcx, 'tcx>(
// item with the correct name
let env_predicates = env_predicates.filter_map(|p| match p {
ty::Predicate::Projection(data) =>
if data.0.projection_ty.item_def_id == obligation.predicate.item_def_id {
if data.projection_def_id() == obligation.predicate.item_def_id {
Some(data)
} else {
None
......@@ -1302,28 +1301,28 @@ fn confirm_generator_candidate<'cx, 'gcx, 'tcx>(
let gen_def_id = tcx.lang_items().gen_trait().unwrap();
// Note: we unwrap the binder here but re-create it below (1)
let ty::Binder((trait_ref, yield_ty, return_ty)) =
let predicate =
tcx.generator_trait_ref_and_outputs(gen_def_id,
obligation.predicate.self_ty(),
gen_sig);
let name = tcx.associated_item(obligation.predicate.item_def_id).name;
let ty = if name == Symbol::intern("Return") {
return_ty
} else if name == Symbol::intern("Yield") {
yield_ty
} else {
bug!()
};
gen_sig)
.map_bound(|(trait_ref, yield_ty, return_ty)| {
let name = tcx.associated_item(obligation.predicate.item_def_id).name;
let ty = if name == Symbol::intern("Return") {
return_ty
} else if name == Symbol::intern("Yield") {
yield_ty
} else {
bug!()
};
let predicate = ty::Binder(ty::ProjectionPredicate { // (1) recreate binder here
projection_ty: ty::ProjectionTy {
substs: trait_ref.substs,
item_def_id: obligation.predicate.item_def_id,
},
ty: ty
});
ty::ProjectionPredicate {
projection_ty: ty::ProjectionTy {
substs: trait_ref.substs,
item_def_id: obligation.predicate.item_def_id,
},
ty: ty
}
});
confirm_param_env_candidate(selcx, obligation, predicate)
.with_addl_obligations(vtable.nested)
......@@ -1400,21 +1399,21 @@ fn confirm_callable_candidate<'cx, 'gcx, 'tcx>(
// the `Output` associated type is declared on `FnOnce`
let fn_once_def_id = tcx.lang_items().fn_once_trait().unwrap();
// Note: we unwrap the binder here but re-create it below (1)
let ty::Binder((trait_ref, ret_type)) =
let predicate =
tcx.closure_trait_ref_and_return_type(fn_once_def_id,
obligation.predicate.self_ty(),
fn_sig,
flag);
let predicate = ty::Binder(ty::ProjectionPredicate { // (1) recreate binder here
projection_ty: ty::ProjectionTy::from_ref_and_name(
tcx,
trait_ref,
Symbol::intern(FN_OUTPUT_NAME),
),
ty: ret_type
});
flag)
.map_bound(|(trait_ref, ret_type)| {
ty::ProjectionPredicate {
projection_ty: ty::ProjectionTy::from_ref_and_name(
tcx,
trait_ref,
Symbol::intern(FN_OUTPUT_NAME),
),
ty: ret_type
}
});
confirm_param_env_candidate(selcx, obligation, predicate)
}
......
......@@ -786,7 +786,8 @@ fn evaluate_stack<'o>(&mut self,
// This suffices to allow chains like `FnMut` implemented in
// terms of `Fn` etc, but we could probably make this more
// precise still.
let unbound_input_types = stack.fresh_trait_ref.input_types().any(|ty| ty.is_fresh());
let unbound_input_types =
stack.fresh_trait_ref.skip_binder().input_types().any(|ty| ty.is_fresh());
// this check was an imperfect workaround for a bug n the old
// intercrate mode, it should be removed when that goes away.
if unbound_input_types &&
......@@ -1274,7 +1275,7 @@ fn check_candidate_cache(&mut self,
-> Option<SelectionResult<'tcx, SelectionCandidate<'tcx>>>
{
let tcx = self.tcx();
let trait_ref = &cache_fresh_trait_pred.0.trait_ref;
let trait_ref = &cache_fresh_trait_pred.skip_binder().trait_ref;
if self.can_use_global_caches(param_env) {
let cache = tcx.selection_cache.hashmap.borrow();
if let Some(cached) = cache.get(&trait_ref) {
......@@ -1294,7 +1295,7 @@ fn insert_candidate_cache(&mut self,
candidate: SelectionResult<'tcx, SelectionCandidate<'tcx>>)
{
let tcx = self.tcx();
let trait_ref = cache_fresh_trait_pred.0.trait_ref;
let trait_ref = cache_fresh_trait_pred.skip_binder().trait_ref;
if self.can_use_global_caches(param_env) {
let mut cache = tcx.selection_cache.hashmap.borrow_mut();
if let Some(trait_ref) = tcx.lift_to_global(&trait_ref) {
......@@ -1357,7 +1358,7 @@ fn assemble_candidates<'o>(&mut self,
let lang_items = self.tcx().lang_items();
if lang_items.copy_trait() == Some(def_id) {
debug!("obligation self ty is {:?}",
obligation.predicate.0.self_ty());
obligation.predicate.skip_binder().self_ty());
// User-defined copy impls are permitted, but only for
// structs and enums.
......@@ -1409,7 +1410,7 @@ fn assemble_candidates_from_projected_tys(&mut self,
// before we go into the whole skolemization thing, just
// quickly check if the self-type is a projection at all.
match obligation.predicate.0.trait_ref.self_ty().sty {
match obligation.predicate.skip_binder().trait_ref.self_ty().sty {
ty::TyProjection(_) | ty::TyAnon(..) => {}
ty::TyInfer(ty::TyVar(_)) => {
span_bug!(obligation.cause.span,
......@@ -1507,7 +1508,7 @@ fn match_projection(&mut self,
{
assert!(!skol_trait_ref.has_escaping_regions());
if let Err(_) = self.infcx.at(&obligation.cause, obligation.param_env)
.sup(ty::Binder(skol_trait_ref), trait_bound) {
.sup(ty::Binder::dummy(skol_trait_ref), trait_bound) {
return false;
}
......@@ -1605,7 +1606,7 @@ fn assemble_closure_candidates(&mut self,
candidates: &mut SelectionCandidateSet<'tcx>)
-> Result<(),SelectionError<'tcx>>
{
let kind = match self.tcx().lang_items().fn_trait_kind(obligation.predicate.0.def_id()) {
let kind = match self.tcx().lang_items().fn_trait_kind(obligation.predicate.def_id()) {
Some(k) => k,
None => { return Ok(()); }
};
......@@ -1661,12 +1662,12 @@ fn assemble_fn_pointer_candidates(&mut self,
// provide an impl, but only for suitable `fn` pointers
ty::TyFnDef(..) | ty::TyFnPtr(_) => {
if let ty::Binder(ty::FnSig {
if let ty::FnSig {
unsafety: hir::Unsafety::Normal,
abi: Abi::Rust,
variadic: false,
..
}) = self_ty.fn_sig(self.tcx()) {
} = self_ty.fn_sig(self.tcx()).skip_binder() {
candidates.vec.push(FnPointerCandidate);
}
}
......@@ -1687,7 +1688,7 @@ fn assemble_candidates_from_impls(&mut self,
self.tcx().for_each_relevant_impl(
obligation.predicate.def_id(),
obligation.predicate.0.trait_ref.self_ty(),
obligation.predicate.skip_binder().trait_ref.self_ty(),
|impl_def_id| {
self.probe(|this, snapshot| { /* [1] */
match this.match_impl(impl_def_id, obligation, snapshot) {
......@@ -2046,19 +2047,19 @@ fn sized_conditions(&mut self, obligation: &TraitObligation<'tcx>)
ty::TyGeneratorWitness(..) | ty::TyArray(..) | ty::TyClosure(..) |
ty::TyNever | ty::TyError => {
// safe for everything
Where(ty::Binder(Vec::new()))
Where(ty::Binder::dummy(Vec::new()))
}
ty::TyStr | ty::TySlice(_) | ty::TyDynamic(..) | ty::TyForeign(..) => Never,
ty::TyTuple(tys) => {
Where(ty::Binder(tys.last().into_iter().cloned().collect()))
Where(ty::Binder::bind(tys.last().into_iter().cloned().collect()))
}
ty::TyAdt(def, substs) => {
let sized_crit = def.sized_constraint(self.tcx());
// (*) binder moved here
Where(ty::Binder(
Where(ty::Binder::bind(
sized_crit.iter().map(|ty| ty.subst(self.tcx(), substs)).collect()
))
}
......@@ -2088,7 +2089,7 @@ fn copy_clone_conditions(&mut self, obligation: &TraitObligation<'tcx>)
match self_ty.sty {
ty::TyInfer(ty::IntVar(_)) | ty::TyInfer(ty::FloatVar(_)) |
ty::TyFnDef(..) | ty::TyFnPtr(_) | ty::TyError => {
Where(ty::Binder(Vec::new()))
Where(ty::Binder::dummy(Vec::new()))
}
ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) |
......@@ -2106,12 +2107,12 @@ fn copy_clone_conditions(&mut self, obligation: &TraitObligation<'tcx>)
ty::TyArray(element_ty, _) => {
// (*) binder moved here
Where(ty::Binder(vec![element_ty]))
Where(ty::Binder::bind(vec![element_ty]))
}
ty::TyTuple(tys) => {
// (*) binder moved here
Where(ty::Binder(tys.to_vec()))
Where(ty::Binder::bind(tys.to_vec()))
}
ty::TyClosure(def_id, substs) => {
......@@ -2119,7 +2120,7 @@ fn copy_clone_conditions(&mut self, obligation: &TraitObligation<'tcx>)
let is_copy_trait = Some(trait_id) == self.tcx().lang_items().copy_trait();
let is_clone_trait = Some(trait_id) == self.tcx().lang_items().clone_trait();
if is_copy_trait || is_clone_trait {
Where(ty::Binder(substs.upvar_tys(def_id, self.tcx()).collect()))
Where(ty::Binder::bind(substs.upvar_tys(def_id, self.tcx()).collect()))
} else {
Never
}
......@@ -2260,7 +2261,7 @@ fn collect_predicates_for_types(&mut self,
// 3. Re-bind the regions back to `for<'a> &'a int : Copy`
types.skip_binder().into_iter().flat_map(|ty| { // binder moved -\
let ty: ty::Binder<Ty<'tcx>> = ty::Binder(ty); // <----------/
let ty: ty::Binder<Ty<'tcx>> = ty::Binder::bind(ty); // <----/
self.in_snapshot(|this, snapshot| {
let (skol_ty, skol_map) =
......@@ -2450,18 +2451,19 @@ fn confirm_builtin_candidate(&mut self,
/// 1. For each constituent type `Y` in `X`, `Y : Foo` holds
/// 2. For each where-clause `C` declared on `Foo`, `[Self => X] C` holds.
fn confirm_auto_impl_candidate(&mut self,
obligation: &TraitObligation<'tcx>,
trait_def_id: DefId)
-> VtableAutoImplData<PredicateObligation<'tcx>>
obligation: &TraitObligation<'tcx>,
trait_def_id: DefId)
-> VtableAutoImplData<PredicateObligation<'tcx>>
{
debug!("confirm_auto_impl_candidate({:?}, {:?})",
obligation,
trait_def_id);
// binder is moved below
let self_ty = self.infcx.shallow_resolve(obligation.predicate.skip_binder().self_ty());
let types = self.constituent_types_for_ty(self_ty);
self.vtable_auto_impl(obligation, trait_def_id, ty::Binder(types))
let types = obligation.predicate.map_bound(|inner| {
let self_ty = self.infcx.shallow_resolve(inner.self_ty());
self.constituent_types_for_ty(self_ty)
});
self.vtable_auto_impl(obligation, trait_def_id, types)
}
/// See `confirm_auto_impl_candidate`
......@@ -2726,7 +2728,7 @@ fn confirm_closure_candidate(&mut self,
{
debug!("confirm_closure_candidate({:?})", obligation);
let kind = match self.tcx().lang_items().fn_trait_kind(obligation.predicate.0.def_id()) {
let kind = match self.tcx().lang_items().fn_trait_kind(obligation.predicate.def_id()) {
Some(k) => k,
None => bug!("closure candidate for non-fn trait {:?}", obligation)
};
......@@ -2835,14 +2837,15 @@ fn confirm_builtin_unsize_candidate(&mut self,
// Trait+Kx+'a -> Trait+Ky+'b (upcasts).
(&ty::TyDynamic(ref data_a, r_a), &ty::TyDynamic(ref data_b, r_b)) => {
// See assemble_candidates_for_unsizing for more info.
// Binders reintroduced below in call to mk_existential_predicates.
let principal = data_a.skip_binder().principal();
let iter = principal.into_iter().map(ty::ExistentialPredicate::Trait)
.chain(data_a.skip_binder().projection_bounds()
.map(|x| ty::ExistentialPredicate::Projection(x)))
.chain(data_b.auto_traits().map(ty::ExistentialPredicate::AutoTrait));
let new_trait = tcx.mk_dynamic(
ty::Binder(tcx.mk_existential_predicates(iter)), r_b);
let existential_predicates = data_a.map_bound(|data_a| {
let principal = data_a.principal();
let iter = principal.into_iter().map(ty::ExistentialPredicate::Trait)
.chain(data_a.projection_bounds()
.map(|x| ty::ExistentialPredicate::Projection(x)))
.chain(data_b.auto_traits().map(ty::ExistentialPredicate::AutoTrait));
tcx.mk_existential_predicates(iter)
});
let new_trait = tcx.mk_dynamic(existential_predicates, r_b);
let InferOk { obligations, .. } =
self.infcx.at(&obligation.cause, obligation.param_env)
.eq(target, new_trait)
......@@ -2857,7 +2860,7 @@ fn confirm_builtin_unsize_candidate(&mut self,
nested.push(Obligation::with_depth(cause,
obligation.recursion_depth + 1,
obligation.param_env,
ty::Binder(outlives).to_predicate()));
ty::Binder::bind(outlives).to_predicate()));
}
// T -> Trait.
......@@ -2900,7 +2903,7 @@ fn confirm_builtin_unsize_candidate(&mut self,
// If the type is `Foo+'a`, ensures that the type
// being cast to `Foo+'a` outlives `'a`:
let outlives = ty::OutlivesPredicate(source, r);
push(ty::Binder(outlives).to_predicate());
push(ty::Binder::dummy(outlives).to_predicate());
}
// [T; n] -> [T].
......@@ -3201,18 +3204,19 @@ fn closure_trait_ref_unnormalized(&mut self,
-> ty::PolyTraitRef<'tcx>
{
let closure_type = self.infcx.closure_sig(closure_def_id, substs);
let ty::Binder((trait_ref, _)) =
self.tcx().closure_trait_ref_and_return_type(obligation.predicate.def_id(),
obligation.predicate.0.self_ty(), // (1)
closure_type,
util::TupleArgumentsFlag::No);
// (1) Feels icky to skip the binder here, but OTOH we know
// that the self-type is an unboxed closure type and hence is
// in fact unparameterized (or at least does not reference any
// regions bound in the obligation). Still probably some
// refactoring could make this nicer.
ty::Binder(trait_ref)
self.tcx().closure_trait_ref_and_return_type(obligation.predicate.def_id(),
obligation.predicate
.skip_binder().self_ty(), // (1)
closure_type,
util::TupleArgumentsFlag::No)
.map_bound(|(trait_ref, _)| trait_ref)
}
fn generator_trait_ref_unnormalized(&mut self,
......@@ -3222,17 +3226,18 @@ fn generator_trait_ref_unnormalized(&mut self,
-> ty::PolyTraitRef<'tcx>
{
let gen_sig = substs.generator_poly_sig(closure_def_id, self.tcx());
let ty::Binder((trait_ref, ..)) =
self.tcx().generator_trait_ref_and_outputs(obligation.predicate.def_id(),
obligation.predicate.0.self_ty(), // (1)
gen_sig);
// (1) Feels icky to skip the binder here, but OTOH we know
// that the self-type is an generator type and hence is
// in fact unparameterized (or at least does not reference any
// regions bound in the obligation). Still probably some
// refactoring could make this nicer.
ty::Binder(trait_ref)
self.tcx().generator_trait_ref_and_outputs(obligation.predicate.def_id(),
obligation.predicate
.skip_binder().self_ty(), // (1)
gen_sig)
.map_bound(|(trait_ref, ..)| trait_ref)
}
/// Returns the obligations that are implied by instantiating an
......
......@@ -209,13 +209,13 @@ fn push(&mut self, predicate: &ty::Predicate<'tcx>) {
None
} else {
Some(ty::Predicate::RegionOutlives(
ty::Binder(ty::OutlivesPredicate(r, r_min))))
ty::Binder::dummy(ty::OutlivesPredicate(r, r_min))))
},
Component::Param(p) => {
let ty = tcx.mk_param(p.idx, p.name);
Some(ty::Predicate::TypeOutlives(
ty::Binder(ty::OutlivesPredicate(ty, r_min))))
ty::Binder::dummy(ty::OutlivesPredicate(ty, r_min))))
},
Component::UnresolvedInferenceVariable(_) => {
......@@ -514,7 +514,7 @@ pub fn closure_trait_ref_and_return_type(self,
def_id: fn_trait_def_id,
substs: self.mk_substs_trait(self_ty, &[arguments_tuple]),
};
ty::Binder((trait_ref, sig.skip_binder().output()))
ty::Binder::bind((trait_ref, sig.skip_binder().output()))
}
pub fn generator_trait_ref_and_outputs(self,
......@@ -527,7 +527,7 @@ pub fn generator_trait_ref_and_outputs(self,
def_id: fn_trait_def_id,
substs: self.mk_substs_trait(self_ty, &[]),
};
ty::Binder((trait_ref, sig.skip_binder().yield_ty, sig.skip_binder().return_ty))
ty::Binder::bind((trait_ref, sig.skip_binder().yield_ty, sig.skip_binder().return_ty))
}
pub fn impl_is_default(self, node_item_def_id: DefId) -> bool {
......
......@@ -92,6 +92,6 @@ fn binders<T>(&mut self, a: &ty::Binder<T>, b: &ty::Binder<T>)
-> RelateResult<'tcx, ty::Binder<T>>
where T: Relate<'tcx>
{
Ok(ty::Binder(self.relate(a.skip_binder(), b.skip_binder())?))
Ok(ty::Binder::bind(self.relate(a.skip_binder(), b.skip_binder())?))
}
}
......@@ -394,7 +394,7 @@ pub fn flatten_late_bound_regions<T>(self, bound2_value: &Binder<Binder<T>>)
}
}
});
Binder(value)
Binder::bind(value)
}
/// Returns a set of all late-bound regions that are constrained
......@@ -446,7 +446,7 @@ pub fn anonymize_late_bound_regions<T>(self, sig: &Binder<T>) -> Binder<T>
where T : TypeFoldable<'tcx>,
{
let mut counter = 0;
Binder(self.replace_late_bound_regions(sig, |_| {
Binder::bind(self.replace_late_bound_regions(sig, |_| {
counter += 1;
self.mk_region(ty::ReLateBound(ty::DebruijnIndex::new(1), ty::BrAnon(counter)))
}).0)
......
......@@ -259,7 +259,7 @@ fn resolve_associated_item<'a, 'tcx>(
def_id, trait_id, rcvr_substs);
let trait_ref = ty::TraitRef::from_method(tcx, trait_id, rcvr_substs);
let vtbl = tcx.trans_fulfill_obligation((param_env, ty::Binder(trait_ref)));
let vtbl = tcx.trans_fulfill_obligation((param_env, ty::Binder::bind(trait_ref)));
// Now that we know which impl is being used, we can dispatch to
// the actual function:
......
......@@ -1048,18 +1048,18 @@ pub fn subst_supertrait(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>,
// from the substitution and the value being substituted into, and
// this trick achieves that).
let substs = &trait_ref.0.substs;
let substs = &trait_ref.skip_binder().substs;
match *self {
Predicate::Trait(ty::Binder(ref data)) =>
Predicate::Trait(ty::Binder(data.subst(tcx, substs))),
Predicate::Subtype(ty::Binder(ref data)) =>
Predicate::Subtype(ty::Binder(data.subst(tcx, substs))),
Predicate::RegionOutlives(ty::Binder(ref data)) =>
Predicate::RegionOutlives(ty::Binder(data.subst(tcx, substs))),
Predicate::TypeOutlives(ty::Binder(ref data)) =>
Predicate::TypeOutlives(ty::Binder(data.subst(tcx, substs))),
Predicate::Projection(ty::Binder(ref data)) =>
Predicate::Projection(ty::Binder(data.subst(tcx, substs))),
Predicate::Trait(ref binder) =>
Predicate::Trait(binder.map_bound(|data| data.subst(tcx, substs))),
Predicate::Subtype(ref binder) =>
Predicate::Subtype(binder.map_bound(|data| data.subst(tcx, substs))),
Predicate::RegionOutlives(ref binder) =>
Predicate::RegionOutlives(binder.map_bound(|data| data.subst(tcx, substs))),
Predicate::TypeOutlives(ref binder) =>
Predicate::TypeOutlives(binder.map_bound(|data| data.subst(tcx, substs))),
Predicate::Projection(ref binder) =>
Predicate::Projection(binder.map_bound(|data| data.subst(tcx, substs))),
Predicate::WellFormed(data) =>
Predicate::WellFormed(data.subst(tcx, substs)),
Predicate::ObjectSafe(trait_def_id) =>
......@@ -1095,7 +1095,7 @@ pub fn self_ty(&self) -> Ty<'tcx> {
impl<'tcx> PolyTraitPredicate<'tcx> {
pub fn def_id(&self) -> DefId {
// ok to skip binder since trait def-id does not care about regions
self.0.def_id()
self.skip_binder().def_id()
}
}
......@@ -1149,11 +1149,20 @@ pub fn to_poly_trait_ref(&self, tcx: TyCtxt) -> PolyTraitRef<'tcx> {
// This is because here `self` has a `Binder` and so does our
// return value, so we are preserving the number of binding
// levels.
ty::Binder(self.0.projection_ty.trait_ref(tcx))
self.map_bound(|predicate| predicate.projection_ty.trait_ref(tcx))
}
pub fn ty(&self) -> Binder<Ty<'tcx>> {
Binder(self.skip_binder().ty) // preserves binding levels
self.map_bound(|predicate| predicate.ty)
}
/// The DefId of the TraitItem for the associated type.
///
/// Note that this is not the DefId of the TraitRef containing this
/// associated type, which is in tcx.associated_item(projection_def_id()).container.
pub fn projection_def_id(&self) -> DefId {
// ok to skip binder since trait def-id does not care about regions
self.skip_binder().projection_ty.item_def_id
}
}
......@@ -1163,8 +1172,7 @@ pub trait ToPolyTraitRef<'tcx> {
impl<'tcx> ToPolyTraitRef<'tcx> for TraitRef<'tcx> {
fn to_poly_trait_ref(&self) -> PolyTraitRef<'tcx> {
assert!(!self.has_escaping_regions());
ty::Binder(self.clone())
ty::Binder::dummy(self.clone())
}
}
......@@ -1180,12 +1188,7 @@ pub trait ToPredicate<'tcx> {
impl<'tcx> ToPredicate<'tcx> for TraitRef<'tcx> {
fn to_predicate(&self) -> Predicate<'tcx> {
// we're about to add a binder, so let's check that we don't
// accidentally capture anything, or else that might be some
// weird debruijn accounting.
assert!(!self.has_escaping_regions());
ty::Predicate::Trait(ty::Binder(ty::TraitPredicate {
ty::Predicate::Trait(ty::Binder::dummy(ty::TraitPredicate {
trait_ref: self.clone()
}))
}
......@@ -1224,17 +1227,19 @@ pub fn walk_tys(&self) -> IntoIter<Ty<'tcx>> {
ty::Predicate::Trait(ref data) => {
data.skip_binder().input_types().collect()
}
ty::Predicate::Subtype(ty::Binder(SubtypePredicate { a, b, a_is_expected: _ })) => {
ty::Predicate::Subtype(binder) => {
let SubtypePredicate { a, b, a_is_expected: _ } = binder.skip_binder();
vec![a, b]
}
ty::Predicate::TypeOutlives(ty::Binder(ref data)) => {
vec![data.0]
ty::Predicate::TypeOutlives(binder) => {
vec![binder.skip_binder().0]
}
ty::Predicate::RegionOutlives(..) => {
vec![]
}
ty::Predicate::Projection(ref data) => {
data.0.projection_ty.substs.types().chain(Some(data.0.ty)).collect()
let inner = data.skip_binder();
inner.projection_ty.substs.types().chain(Some(inner.ty)).collect()
}
ty::Predicate::WellFormed(data) => {
vec![data]
......@@ -2090,7 +2095,7 @@ fn sized_constraint_for_ty(&self,
Some(x) => x,
_ => return vec![ty]
};
let sized_predicate = Binder(TraitRef {
let sized_predicate = Binder::dummy(TraitRef {
def_id: sized_trait,
substs: tcx.mk_substs_trait(ty, &[])
}).to_predicate();
......
......@@ -431,10 +431,10 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
{
// Wrap our types with a temporary GeneratorWitness struct
// inside the binder so we can related them
let a_types = ty::Binder(GeneratorWitness(*a_types.skip_binder()));
let b_types = ty::Binder(GeneratorWitness(*b_types.skip_binder()));
let a_types = a_types.map_bound(GeneratorWitness);
let b_types = b_types.map_bound(GeneratorWitness);
// Then remove the GeneratorWitness for the result
let types = ty::Binder(relation.relate(&a_types, &b_types)?.skip_binder().0);
let types = relation.relate(&a_types, &b_types)?.map_bound(|witness| witness.0);
Ok(tcx.mk_generator_witness(types))
}
......
......@@ -270,7 +270,7 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lif
impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::Binder<T> {
type Lifted = ty::Binder<T::Lifted>;
fn lift_to_tcx<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Option<Self::Lifted> {
tcx.lift(&self.0).map(|x| ty::Binder(x))
tcx.lift(self.skip_binder()).map(ty::Binder::bind)
}
}
......@@ -720,7 +720,7 @@ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
ty::Binder(self.0.fold_with(folder))
self.map_bound_ref(|ty| ty.fold_with(folder))
}
fn fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
......@@ -728,7 +728,7 @@ fn fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Se
}
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.0.visit_with(visitor)
self.skip_binder().visit_with(visitor)
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
......
......@@ -345,7 +345,7 @@ pub fn generator_return_ty(self, def_id: DefId, tcx: TyCtxt<'_, '_, '_>) -> Ty<'
/// binder, but it never contains bound regions. Probably this
/// function should be removed.
pub fn generator_poly_sig(self, def_id: DefId, tcx: TyCtxt<'_, '_, '_>) -> PolyGenSig<'tcx> {
ty::Binder(self.generator_sig(def_id, tcx))
ty::Binder::dummy(self.generator_sig(def_id, tcx))
}
/// Return the "generator signature", which consists of its yield
......@@ -504,13 +504,13 @@ pub fn auto_traits<'a>(&'a self) -> impl Iterator<Item=DefId> + 'a {
impl<'tcx> Binder<&'tcx Slice<ExistentialPredicate<'tcx>>> {
pub fn principal(&self) -> Option<PolyExistentialTraitRef<'tcx>> {
self.skip_binder().principal().map(Binder)
self.skip_binder().principal().map(Binder::bind)
}
#[inline]
pub fn projection_bounds<'a>(&'a self) ->
impl Iterator<Item=PolyExistentialProjection<'tcx>> + 'a {
self.skip_binder().projection_bounds().map(Binder)
self.skip_binder().projection_bounds().map(Binder::bind)
}
#[inline]
......@@ -520,7 +520,7 @@ pub fn auto_traits<'a>(&'a self) -> impl Iterator<Item=DefId> + 'a {
pub fn iter<'a>(&'a self)
-> impl DoubleEndedIterator<Item=Binder<ExistentialPredicate<'tcx>>> + 'tcx {
self.skip_binder().iter().cloned().map(Binder)
self.skip_binder().iter().cloned().map(Binder::bind)
}
}
......@@ -567,26 +567,16 @@ pub fn input_types<'a>(&'a self) -> impl DoubleEndedIterator<Item=Ty<'tcx>> + 'a
impl<'tcx> PolyTraitRef<'tcx> {
pub fn self_ty(&self) -> Ty<'tcx> {
self.0.self_ty()
self.skip_binder().self_ty()
}
pub fn def_id(&self) -> DefId {
self.0.def_id
}
pub fn substs(&self) -> &'tcx Substs<'tcx> {
// FIXME(#20664) every use of this fn is probably a bug, it should yield Binder<>
self.0.substs
}
pub fn input_types<'a>(&'a self) -> impl DoubleEndedIterator<Item=Ty<'tcx>> + 'a {
// FIXME(#20664) every use of this fn is probably a bug, it should yield Binder<>
self.0.input_types()
self.skip_binder().def_id
}
pub fn to_poly_trait_predicate(&self) -> ty::PolyTraitPredicate<'tcx> {
// Note that we preserve binding levels
Binder(ty::TraitPredicate { trait_ref: self.0.clone() })
Binder(ty::TraitPredicate { trait_ref: self.skip_binder().clone() })
}
}
......@@ -633,12 +623,7 @@ pub fn with_self_ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, self_ty: Ty<'tcx>)
impl<'tcx> PolyExistentialTraitRef<'tcx> {
pub fn def_id(&self) -> DefId {
self.0.def_id
}
pub fn input_types<'a>(&'a self) -> impl DoubleEndedIterator<Item=Ty<'tcx>> + 'a {
// FIXME(#20664) every use of this fn is probably a bug, it should yield Binder<>
self.0.input_types()
self.skip_binder().def_id
}
}
......@@ -650,7 +635,7 @@ pub fn input_types<'a>(&'a self) -> impl DoubleEndedIterator<Item=Ty<'tcx>> + 'a
/// type from `Binder<T>` to just `T` (see
/// e.g. `liberate_late_bound_regions`).
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)]
pub struct Binder<T>(pub T);
pub struct Binder<T>(T);
impl<T> Binder<T> {
/// Wraps `value` in a binder, asserting that `value` does not
......@@ -664,6 +649,12 @@ pub fn dummy<'tcx>(value: T) -> Binder<T>
Binder(value)
}
/// Wraps `value` in a binder, binding late-bound regions (if any).
pub fn bind<'tcx>(value: T) -> Binder<T>
{
Binder(value)
}
/// Skips the binder and returns the "bound" value. This is a
/// risky thing to do because it's easy to get confused about
/// debruijn indices and the like. It is usually better to
......@@ -685,7 +676,7 @@ pub fn skip_binder(&self) -> &T {
}
pub fn as_ref(&self) -> Binder<&T> {
ty::Binder(&self.0)
Binder(&self.0)
}
pub fn map_bound_ref<F, U>(&self, f: F) -> Binder<U>
......@@ -697,7 +688,7 @@ pub fn map_bound_ref<F, U>(&self, f: F) -> Binder<U>
pub fn map_bound<F, U>(self, f: F) -> Binder<U>
where F: FnOnce(T) -> U
{
ty::Binder(f(self.0))
Binder(f(self.0))
}
/// Unwraps and returns the value within, but only if it contains
......@@ -730,7 +721,7 @@ pub fn no_late_bound_regions<'tcx>(self) -> Option<T>
pub fn fuse<U,F,R>(self, u: Binder<U>, f: F) -> Binder<R>
where F: FnOnce(T, U) -> R
{
ty::Binder(f(self.0, u.0))
Binder(f(self.0, u.0))
}
/// Split the contents into two things that share the same binder
......@@ -743,7 +734,7 @@ pub fn split<U,V,F>(self, f: F) -> (Binder<U>, Binder<V>)
where F: FnOnce(T) -> (U, V)
{
let (u, v) = f(self.0);
(ty::Binder(u), ty::Binder(v))
(Binder(u), Binder(v))
}
}
......@@ -839,7 +830,7 @@ pub fn output(&self) -> Ty<'tcx> {
impl<'tcx> PolyFnSig<'tcx> {
pub fn inputs(&self) -> Binder<&'tcx [Ty<'tcx>]> {
Binder(self.skip_binder().inputs())
self.map_bound_ref(|fn_sig| fn_sig.inputs())
}
pub fn input(&self, index: usize) -> ty::Binder<Ty<'tcx>> {
self.map_bound_ref(|fn_sig| fn_sig.inputs()[index])
......@@ -1152,6 +1143,10 @@ pub fn with_self_ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, self_ty: Ty<'tcx>)
-> ty::PolyProjectionPredicate<'tcx> {
self.map_bound(|p| p.with_self_ty(tcx, self_ty))
}
pub fn item_def_id(&self) -> DefId {
return self.skip_binder().item_def_id;
}
}
impl DebruijnIndex {
......
......@@ -380,7 +380,7 @@ pub fn required_region_bounds(self,
ty::Predicate::ConstEvaluatable(..) => {
None
}
ty::Predicate::TypeOutlives(ty::Binder(ty::OutlivesPredicate(t, r))) => {
ty::Predicate::TypeOutlives(predicate) => {
// Search for a bound of the form `erased_self_ty
// : 'a`, but be wary of something like `for<'a>
// erased_self_ty : 'a` (we interpret a
......@@ -390,8 +390,9 @@ pub fn required_region_bounds(self,
// it's kind of a moot point since you could never
// construct such an object, but this seems
// correct even if that code changes).
if t == erased_self_ty && !r.has_escaping_regions() {
Some(r)
let ty::OutlivesPredicate(ref t, ref r) = predicate.skip_binder();
if t == &erased_self_ty && !r.has_escaping_regions() {
Some(*r)
} else {
None
}
......@@ -561,7 +562,7 @@ pub fn closure_env_ty(self,
ty::ClosureKind::FnMut => self.mk_mut_ref(self.mk_region(env_region), closure_ty),
ty::ClosureKind::FnOnce => closure_ty,
};
Some(ty::Binder(env_ty))
Some(ty::Binder::bind(env_ty))
}
/// Given the def-id of some item that has no type parameters, make
......
......@@ -307,7 +307,7 @@ fn compute(&mut self, ty0: Ty<'tcx>) -> bool {
cause,
param_env,
ty::Predicate::TypeOutlives(
ty::Binder(
ty::Binder::dummy(
ty::OutlivesPredicate(mt.ty, r)))));
}
}
......@@ -492,7 +492,8 @@ fn from_object_ty(&mut self, ty: Ty<'tcx>,
for implicit_bound in implicit_bounds {
let cause = self.cause(traits::ObjectTypeBound(ty, explicit_bound));
let outlives = ty::Binder(ty::OutlivesPredicate(explicit_bound, implicit_bound));
let outlives = ty::Binder::dummy(
ty::OutlivesPredicate(explicit_bound, implicit_bound));
self.out.push(traits::Obligation::new(cause,
self.param_env,
outlives.to_predicate()));
......
......@@ -473,7 +473,7 @@ fn name_by_region_index(index: usize) -> InternedString {
let value = if let Some(v) = lifted {
v
} else {
return original.0.print_display(f, self);
return original.skip_binder().print_display(f, self);
};
if self.binder_depth == 0 {
......@@ -679,9 +679,9 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
ty::tls::with(|tcx| {
let dummy_self = tcx.mk_infer(ty::FreshTy(0));
let trait_ref = tcx.lift(&ty::Binder(*self))
let trait_ref = *tcx.lift(&ty::Binder::bind(*self))
.expect("could not lift TraitRef for printing")
.with_self_ty(tcx, dummy_self).0;
.with_self_ty(tcx, dummy_self).skip_binder();
cx.parameterized(f, trait_ref.substs, trait_ref.def_id, &[])
})
}
......
......@@ -284,7 +284,7 @@ pub fn assert_eq(&self, a: Ty<'tcx>, b: Ty<'tcx>) {
}
pub fn t_fn(&self, input_tys: &[Ty<'tcx>], output_ty: Ty<'tcx>) -> Ty<'tcx> {
self.infcx.tcx.mk_fn_ptr(ty::Binder(self.infcx.tcx.mk_fn_sig(
self.infcx.tcx.mk_fn_ptr(ty::Binder::bind(self.infcx.tcx.mk_fn_sig(
input_tys.iter().cloned(),
output_ty,
false,
......
......@@ -960,7 +960,7 @@ fn method_call_refers_to_method<'a, 'tcx>(cx: &LateContext<'a, 'tcx>,
// Attempt to select a concrete impl before checking.
ty::TraitContainer(trait_def_id) => {
let trait_ref = ty::TraitRef::from_method(tcx, trait_def_id, callee_substs);
let trait_ref = ty::Binder(trait_ref);
let trait_ref = ty::Binder::bind(trait_ref);
let span = tcx.hir.span(expr_id);
let obligation =
traits::Obligation::new(traits::ObligationCause::misc(span, expr_id),
......
......@@ -163,7 +163,7 @@ pub fn custom_coerce_unsize_info<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
-> CustomCoerceUnsized {
let def_id = tcx.lang_items().coerce_unsized_trait().unwrap();
let trait_ref = ty::Binder(ty::TraitRef {
let trait_ref = ty::Binder::bind(ty::TraitRef {
def_id: def_id,
substs: tcx.mk_substs_trait(source_ty, &[target_ty])
});
......
......@@ -86,14 +86,14 @@
}
Constraint::RegSubReg(r1, r2) => ty::OutlivesPredicate(r1.into(), r2),
})
.map(ty::Binder) // no bound regions in the code above
.map(ty::Binder::dummy) // no bound regions in the code above
.collect();
outlives.extend(
region_obligations
.into_iter()
.map(|(_, r_o)| ty::OutlivesPredicate(r_o.sup_type.into(), r_o.sub_region))
.map(ty::Binder) // no bound regions in the code above
.map(ty::Binder::dummy) // no bound regions in the code above
);
outlives
......
......@@ -406,7 +406,7 @@ pub fn eh_unwind_resume(&self) -> ValueRef {
return llfn;
}
let ty = tcx.mk_fn_ptr(ty::Binder(tcx.mk_fn_sig(
let ty = tcx.mk_fn_ptr(ty::Binder::bind(tcx.mk_fn_sig(
iter::once(tcx.mk_mut_ptr(tcx.types.u8)),
tcx.types.never,
false,
......
......@@ -958,7 +958,7 @@ fn gen_fn<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
output: Ty<'tcx>,
trans: &mut for<'b> FnMut(Builder<'b, 'tcx>))
-> ValueRef {
let rust_fn_ty = cx.tcx.mk_fn_ptr(ty::Binder(cx.tcx.mk_fn_sig(
let rust_fn_ty = cx.tcx.mk_fn_ptr(ty::Binder::bind(cx.tcx.mk_fn_sig(
inputs.into_iter(),
output,
false,
......@@ -985,7 +985,7 @@ fn get_rust_try_fn<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
// Define the type up front for the signature of the rust_try function.
let tcx = cx.tcx;
let i8p = tcx.mk_mut_ptr(tcx.types.i8);
let fn_ty = tcx.mk_fn_ptr(ty::Binder(tcx.mk_fn_sig(
let fn_ty = tcx.mk_fn_ptr(ty::Binder::bind(tcx.mk_fn_sig(
iter::once(i8p),
tcx.mk_nil(),
false,
......
......@@ -363,7 +363,7 @@ pub(super) fn instantiate_poly_trait_ref_inner(&self,
trait_def_id,
self_ty,
trait_ref.path.segments.last().unwrap());
let poly_trait_ref = ty::Binder(ty::TraitRef::new(trait_def_id, substs));
let poly_trait_ref = ty::Binder::bind(ty::TraitRef::new(trait_def_id, substs));
poly_projections.extend(assoc_bindings.iter().filter_map(|binding| {
// specify type to assert that error was already reported in Err case:
......@@ -485,7 +485,7 @@ fn ast_type_binding_to_poly_projection_predicate(
// for<'a> <T as FnMut<(&'a u32,)>>::Output = &'a str // <-- 'a is ok
let late_bound_in_trait_ref = tcx.collect_constrained_late_bound_regions(&trait_ref);
let late_bound_in_ty =
tcx.collect_referenced_late_bound_regions(&ty::Binder(binding.ty));
tcx.collect_referenced_late_bound_regions(&ty::Binder::bind(binding.ty));
debug!("late_bound_in_trait_ref = {:?}", late_bound_in_trait_ref);
debug!("late_bound_in_ty = {:?}", late_bound_in_ty);
for br in late_bound_in_ty.difference(&late_bound_in_trait_ref) {
......@@ -639,7 +639,7 @@ fn conv_object_ty_poly_trait_ref(&self,
}
for projection_bound in &projection_bounds {
associated_types.remove(&projection_bound.0.projection_ty.item_def_id);
associated_types.remove(&projection_bound.projection_def_id());
}
for item_def_id in associated_types {
......@@ -654,6 +654,7 @@ fn conv_object_ty_poly_trait_ref(&self,
.emit();
}
// skip_binder is okay, because the predicates are re-bound.
let mut v =
iter::once(ty::ExistentialPredicate::Trait(*existential_principal.skip_binder()))
.chain(auto_traits.into_iter().map(ty::ExistentialPredicate::AutoTrait))
......@@ -661,7 +662,7 @@ fn conv_object_ty_poly_trait_ref(&self,
.map(|x| ty::ExistentialPredicate::Projection(*x.skip_binder())))
.collect::<AccumulateVec<[_; 8]>>();
v.sort_by(|a, b| a.cmp(tcx, b));
let existential_predicates = ty::Binder(tcx.mk_existential_predicates(v.into_iter()));
let existential_predicates = ty::Binder::bind(tcx.mk_existential_predicates(v.into_iter()));
// Explicitly specified region bound. Use that.
......@@ -825,7 +826,7 @@ pub fn associated_path_def_to_ty(&self,
};
let candidates =
traits::supertraits(tcx, ty::Binder(trait_ref))
traits::supertraits(tcx, ty::Binder::bind(trait_ref))
.filter(|r| self.trait_defines_associated_type_named(r.def_id(),
assoc_name));
......@@ -853,7 +854,7 @@ pub fn associated_path_def_to_ty(&self,
}
};
let trait_did = bound.0.def_id;
let trait_did = bound.def_id();
let (assoc_ident, def_scope) = tcx.adjust(assoc_name, trait_did, ref_id);
let item = tcx.associated_items(trait_did).find(|i| {
Namespace::from(i.kind) == Namespace::Type &&
......@@ -1184,7 +1185,7 @@ pub fn ty_of_fn(&self,
debug!("ty_of_fn: output_ty={:?}", output_ty);
let bare_fn_ty = ty::Binder(tcx.mk_fn_sig(
let bare_fn_ty = ty::Binder::bind(tcx.mk_fn_sig(
input_tys.into_iter(),
output_ty,
decl.variadic,
......@@ -1396,7 +1397,8 @@ pub fn predicates(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, param_ty: Ty<'tcx>)
// account for the binder being introduced below; no need to shift `param_ty`
// because, at present at least, it can only refer to early-bound regions
let region_bound = tcx.mk_region(ty::fold::shift_region(*region_bound, 1));
vec.push(ty::Binder(ty::OutlivesPredicate(param_ty, region_bound)).to_predicate());
vec.push(
ty::Binder::dummy(ty::OutlivesPredicate(param_ty, region_bound)).to_predicate());
}
for bound_trait_ref in &self.trait_bounds {
......
......@@ -267,7 +267,7 @@ fn confirm_builtin_call(&self,
// This is the "default" function signature, used in case of error.
// In that case, we check each argument against "error" in order to
// set up all the node type bindings.
(ty::Binder(self.tcx.mk_fn_sig(
(ty::Binder::bind(self.tcx.mk_fn_sig(
self.err_args(arg_exprs.len()).into_iter(),
self.tcx.types.err,
false,
......
......@@ -303,7 +303,7 @@ fn deduce_sig_from_projection(
return None;
}
let arg_param_ty = trait_ref.substs().type_at(1);
let arg_param_ty = trait_ref.skip_binder().substs.type_at(1);
let arg_param_ty = self.resolve_type_vars_if_possible(&arg_param_ty);
debug!(
"deduce_sig_from_projection: arg_param_ty {:?}",
......@@ -317,7 +317,7 @@ fn deduce_sig_from_projection(
}
};
let ret_param_ty = projection.0.ty;
let ret_param_ty = projection.skip_binder().ty;
let ret_param_ty = self.resolve_type_vars_if_possible(&ret_param_ty);
debug!(
"deduce_sig_from_projection: ret_param_ty {:?}",
......@@ -458,7 +458,7 @@ fn sig_of_closure_with_expectation(
// regions appearing free in `expected_sig` are now bound up
// in this binder we are creating.
assert!(!expected_sig.sig.has_regions_escaping_depth(1));
let bound_sig = ty::Binder(self.tcx.mk_fn_sig(
let bound_sig = ty::Binder::bind(self.tcx.mk_fn_sig(
expected_sig.sig.inputs().iter().cloned(),
expected_sig.sig.output(),
decl.variadic,
......@@ -562,7 +562,7 @@ fn check_supplied_sig_against_expectation(
let (supplied_ty, _) = self.infcx.replace_late_bound_regions_with_fresh_var(
hir_ty.span,
LateBoundRegionConversionTime::FnCall,
&ty::Binder(supplied_ty),
&ty::Binder::bind(supplied_ty),
); // recreated from (*) above
// Check that E' = S'.
......@@ -607,7 +607,7 @@ fn supplied_sig_of_closure(&self, decl: &hir::FnDecl) -> ty::PolyFnSig<'tcx> {
hir::DefaultReturn(_) => astconv.ty_infer(decl.output.span()),
};
let result = ty::Binder(self.tcx.mk_fn_sig(
let result = ty::Binder::bind(self.tcx.mk_fn_sig(
supplied_arguments,
supplied_return,
decl.variadic,
......@@ -639,7 +639,7 @@ fn error_sig_of_closure(&self, decl: &hir::FnDecl) -> ty::PolyFnSig<'tcx> {
hir::DefaultReturn(_) => {}
}
let result = ty::Binder(self.tcx.mk_fn_sig(
let result = ty::Binder::bind(self.tcx.mk_fn_sig(
supplied_arguments,
self.tcx.types.err,
decl.variadic,
......
......@@ -558,7 +558,8 @@ fn coerce_unsized(&self, source: Ty<'tcx>, target: Ty<'tcx>) -> CoerceResult<'tc
let trait_ref = match obligation.predicate {
ty::Predicate::Trait(ref tr) if traits.contains(&tr.def_id()) => {
if unsize_did == tr.def_id() {
if let ty::TyTuple(..) = tr.0.input_types().nth(1).unwrap().sty {
let sty = &tr.skip_binder().input_types().nth(1).unwrap().sty;
if let ty::TyTuple(..) = sty {
debug!("coerce_unsized: found unsized tuple coercion");
has_unsized_tuple_coercion = true;
}
......
......@@ -234,9 +234,11 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let mut selcx = traits::SelectionContext::new(&infcx);
let impl_m_own_bounds = impl_m_predicates.instantiate_own(tcx, impl_to_skol_substs);
let (impl_m_own_bounds, _) = infcx.replace_late_bound_regions_with_fresh_var(impl_m_span,
infer::HigherRankedType,
&ty::Binder(impl_m_own_bounds.predicates));
let (impl_m_own_bounds, _) = infcx.replace_late_bound_regions_with_fresh_var(
impl_m_span,
infer::HigherRankedType,
&ty::Binder::bind(impl_m_own_bounds.predicates)
);
for predicate in impl_m_own_bounds {
let traits::Normalized { value: predicate, obligations } =
traits::normalize(&mut selcx, param_env, normalize_cause.clone(), &predicate);
......@@ -270,7 +272,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
impl_m_node_id,
param_env,
&impl_sig);
let impl_fty = tcx.mk_fn_ptr(ty::Binder(impl_sig));
let impl_fty = tcx.mk_fn_ptr(ty::Binder::bind(impl_sig));
debug!("compare_impl_method: impl_fty={:?}", impl_fty);
let trait_sig = tcx.liberate_late_bound_regions(
......@@ -283,7 +285,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
impl_m_node_id,
param_env,
&trait_sig);
let trait_fty = tcx.mk_fn_ptr(ty::Binder(trait_sig));
let trait_fty = tcx.mk_fn_ptr(ty::Binder::bind(trait_sig));
debug!("compare_impl_method: trait_fty={:?}", trait_fty);
......@@ -505,7 +507,7 @@ fn compare_self_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx.infer_ctxt().enter(|infcx| {
let self_arg_ty = tcx.liberate_late_bound_regions(
method.def_id,
&ty::Binder(self_arg_ty)
&ty::Binder::bind(self_arg_ty)
);
let can_eq_self = |ty| infcx.can_eq(param_env, untransformed_self_ty, ty).is_ok();
match ExplicitSelf::determine(self_arg_ty, can_eq_self) {
......
......@@ -129,7 +129,7 @@ pub fn resolve_interior<'a, 'gcx, 'tcx>(fcx: &'a FnCtxt<'a, 'gcx, 'tcx>,
ty::BrAnon(counter)))
});
let witness = fcx.tcx.mk_generator_witness(ty::Binder(type_list));
let witness = fcx.tcx.mk_generator_witness(ty::Binder::bind(type_list));
debug!("Types in generator after region replacement {:?}, span = {:?}",
witness, body.value.span);
......
......@@ -61,7 +61,7 @@ fn equate_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
return;
}
let fty = tcx.mk_fn_ptr(ty::Binder(tcx.mk_fn_sig(
let fty = tcx.mk_fn_ptr(ty::Binder::bind(tcx.mk_fn_sig(
inputs.into_iter(),
output,
false,
......@@ -304,7 +304,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
"try" => {
let mut_u8 = tcx.mk_mut_ptr(tcx.types.u8);
let fn_ty = ty::Binder(tcx.mk_fn_sig(
let fn_ty = ty::Binder::bind(tcx.mk_fn_sig(
iter::once(mut_u8),
tcx.mk_nil(),
false,
......
......@@ -125,7 +125,7 @@ fn confirm(&mut self,
// We won't add these if we encountered an illegal sized bound, so that we can use
// a custom error in that case.
if !illegal_sized_bound {
let method_ty = self.tcx.mk_fn_ptr(ty::Binder(method_sig));
let method_ty = self.tcx.mk_fn_ptr(ty::Binder::bind(method_sig));
self.add_obligations(method_ty, all_substs, &method_predicates);
}
......@@ -587,7 +587,7 @@ fn predicates_require_illegal_sized_bound(&self,
}
})
.any(|trait_pred| {
match trait_pred.0.self_ty().sty {
match trait_pred.skip_binder().self_ty().sty {
ty::TyDynamic(..) => true,
_ => false,
}
......
......@@ -336,7 +336,7 @@ pub fn lookup_method_in_trait(&self,
&bounds));
// Also add an obligation for the method type being well-formed.
let method_ty = tcx.mk_fn_ptr(ty::Binder(fn_sig));
let method_ty = tcx.mk_fn_ptr(ty::Binder::bind(fn_sig));
debug!("lookup_in_trait_adjusted: matched method method_ty={:?} obligation={:?}",
method_ty,
obligation);
......
......@@ -650,7 +650,7 @@ fn assemble_inherent_candidates_from_param(&mut self,
.filter_map(|predicate| {
match *predicate {
ty::Predicate::Trait(ref trait_predicate) => {
match trait_predicate.0.trait_ref.self_ty().sty {
match trait_predicate.skip_binder().trait_ref.self_ty().sty {
ty::TyParam(ref p) if *p == param_ty => {
Some(trait_predicate.to_poly_trait_ref())
}
......@@ -1204,7 +1204,7 @@ fn consider_probe(&self,
if !selcx.evaluate_obligation(&o) {
result = ProbeResult::NoMatch;
if let &ty::Predicate::Trait(ref pred) = &o.predicate {
possibly_unsatisfied_predicates.push(pred.0.trait_ref);
possibly_unsatisfied_predicates.push(pred.skip_binder().trait_ref);
}
}
}
......@@ -1485,7 +1485,7 @@ fn to_unadjusted_pick(&self) -> Pick<'tcx> {
// inference variables or other artifacts. This
// means they are safe to put into the
// `WhereClausePick`.
assert!(!trait_ref.substs().needs_infer());
assert!(!trait_ref.skip_binder().substs.needs_infer());
WhereClausePick(trait_ref.clone())
}
......
......@@ -1727,7 +1727,7 @@ fn get_type_parameter_bounds(&self, _: Span, def_id: DefId)
predicates: self.param_env.caller_bounds.iter().filter(|predicate| {
match **predicate {
ty::Predicate::Trait(ref data) => {
data.0.self_ty().is_param(index)
data.skip_binder().self_ty().is_param(index)
}
_ => false
}
......
......@@ -508,7 +508,7 @@ fn check_method_receiver<'fcx, 'gcx, 'tcx>(fcx: &FnCtxt<'fcx, 'gcx, 'tcx>,
let self_ty = fcx.normalize_associated_types_in(span, &self_ty);
let self_ty = fcx.tcx.liberate_late_bound_regions(
method.def_id,
&ty::Binder(self_ty)
&ty::Binder::bind(self_ty)
);
let self_arg_ty = sig.inputs()[0];
......@@ -517,7 +517,7 @@ fn check_method_receiver<'fcx, 'gcx, 'tcx>(fcx: &FnCtxt<'fcx, 'gcx, 'tcx>,
let self_arg_ty = fcx.normalize_associated_types_in(span, &self_arg_ty);
let self_arg_ty = fcx.tcx.liberate_late_bound_regions(
method.def_id,
&ty::Binder(self_arg_ty)
&ty::Binder::bind(self_arg_ty)
);
let mut autoderef = fcx.autoderef(span, self_arg_ty).include_raw_pointers();
......
......@@ -1171,7 +1171,7 @@ fn fn_sig<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let inputs = fields.iter().map(|f| {
tcx.type_of(tcx.hir.local_def_id(f.id))
});
ty::Binder(tcx.mk_fn_sig(
ty::Binder::bind(tcx.mk_fn_sig(
inputs,
ty,
false,
......@@ -1434,7 +1434,7 @@ pub fn explicit_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
for bound in &param.bounds {
let bound_region = AstConv::ast_region_to_region(&icx, bound, None);
let outlives = ty::Binder(ty::OutlivesPredicate(region, bound_region));
let outlives = ty::Binder::bind(ty::OutlivesPredicate(region, bound_region));
predicates.push(outlives.to_predicate());
}
}
......@@ -1482,7 +1482,7 @@ pub fn explicit_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let region = AstConv::ast_region_to_region(&icx,
lifetime,
None);
let pred = ty::Binder(ty::OutlivesPredicate(ty, region));
let pred = ty::Binder::bind(ty::OutlivesPredicate(ty, region));
predicates.push(ty::Predicate::TypeOutlives(pred))
}
}
......@@ -1493,7 +1493,7 @@ pub fn explicit_predicates_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let r1 = AstConv::ast_region_to_region(&icx, &region_pred.lifetime, None);
for bound in &region_pred.bounds {
let r2 = AstConv::ast_region_to_region(&icx, bound, None);
let pred = ty::Binder(ty::OutlivesPredicate(r1, r2));
let pred = ty::Binder::bind(ty::OutlivesPredicate(r1, r2));
predicates.push(ty::Predicate::RegionOutlives(pred))
}
}
......@@ -1627,7 +1627,7 @@ fn predicates_from_bound<'tcx>(astconv: &AstConv<'tcx, 'tcx>,
}
hir::RegionTyParamBound(ref lifetime) => {
let region = astconv.ast_region_to_region(lifetime, None);
let pred = ty::Binder(ty::OutlivesPredicate(param_ty, region));
let pred = ty::Binder::bind(ty::OutlivesPredicate(param_ty, region));
vec![ty::Predicate::TypeOutlives(pred)]
}
hir::TraitTyParamBound(_, hir::TraitBoundModifier::Maybe) => {
......
......@@ -212,7 +212,7 @@ fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx.mk_nil()
};
let se_ty = tcx.mk_fn_ptr(ty::Binder(
let se_ty = tcx.mk_fn_ptr(ty::Binder::bind(
tcx.mk_fn_sig(
iter::empty(),
expected_return_type,
......@@ -261,7 +261,7 @@ fn check_start_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
_ => ()
}
let se_ty = tcx.mk_fn_ptr(ty::Binder(
let se_ty = tcx.mk_fn_ptr(ty::Binder::bind(
tcx.mk_fn_sig(
[
tcx.types.isize,
......
......@@ -258,7 +258,7 @@ fn check_explicit_predicates<'tcx>(
// where OutlivesPredicate<type1, region1> is the predicate
// we want to add.
ty::Predicate::TypeOutlives(poly) => {
let predicate = poly.0.subst(tcx, substs);
let predicate = poly.skip_binder().subst(tcx, substs);
insert_outlives_predicate(
tcx,
predicate.0.into(),
......@@ -271,7 +271,7 @@ fn check_explicit_predicates<'tcx>(
// where OutlivesPredicate<region1, region2> is the predicate
// we want to add.
ty::Predicate::RegionOutlives(poly) => {
let predicate = poly.0.subst(tcx, substs);
let predicate = poly.skip_binder().subst(tcx, substs);
insert_outlives_predicate(
tcx,
predicate.0.into(),
......
......@@ -89,11 +89,11 @@ fn inferred_outlives_crate<'tcx>(
let vec: Vec<ty::Predicate<'tcx>> = set.iter()
.map(
|ty::OutlivesPredicate(kind1, region2)| match kind1.unpack() {
UnpackedKind::Type(ty1) => ty::Predicate::TypeOutlives(ty::Binder(
UnpackedKind::Type(ty1) => ty::Predicate::TypeOutlives(ty::Binder::bind(
ty::OutlivesPredicate(ty1, region2),
)),
UnpackedKind::Lifetime(region1) => ty::Predicate::RegionOutlives(
ty::Binder(ty::OutlivesPredicate(region1, region2)),
ty::Binder::bind(ty::OutlivesPredicate(region1, region2)),
),
},
)
......
......@@ -313,11 +313,13 @@ fn add_constraints_from_ty(&mut self,
if let Some(p) = data.principal() {
let poly_trait_ref = p.with_self_ty(self.tcx(), self.tcx().types.err);
self.add_constraints_from_trait_ref(current, poly_trait_ref.0, variance);
self.add_constraints_from_trait_ref(
current, *poly_trait_ref.skip_binder(), variance);
}
for projection in data.projection_bounds() {
self.add_constraints_from_ty(current, projection.0.ty, self.invariant);
self.add_constraints_from_ty(
current, projection.skip_binder().ty, self.invariant);
}
}
......@@ -399,10 +401,10 @@ fn add_constraints_from_sig(&mut self,
sig: ty::PolyFnSig<'tcx>,
variance: VarianceTermPtr<'a>) {
let contra = self.contravariant(variance);
for &input in sig.0.inputs() {
for &input in sig.skip_binder().inputs() {
self.add_constraints_from_ty(current, input, contra);
}
self.add_constraints_from_ty(current, sig.0.output(), variance);
self.add_constraints_from_ty(current, sig.skip_binder().output(), variance);
}
/// Adds constraints appropriate for a region appearing in a
......
......@@ -286,7 +286,7 @@ fn find_auto_trait_generics(
substs: tcx.mk_substs_trait(ty, &[]),
};
let trait_pred = ty::Binder(trait_ref);
let trait_pred = ty::Binder::bind(trait_ref);
let bail_out = tcx.infer_ctxt().enter(|infcx| {
let mut selcx = SelectionContext::with_negative(&infcx, true);
......@@ -622,7 +622,7 @@ fn evaluate_predicates<'b, 'gcx, 'c>(
let mut already_visited = FxHashSet();
let mut predicates = VecDeque::new();
predicates.push_back(ty::Binder(ty::TraitPredicate {
predicates.push_back(ty::Binder::bind(ty::TraitPredicate {
trait_ref: ty::TraitRef {
def_id: trait_did,
substs: infcx.tcx.mk_substs_trait(ty, &[]),
......
......@@ -120,7 +120,7 @@ fn clean(&self, cx: &DocContext) -> Option<U> {
impl<T, U> Clean<U> for ty::Binder<T> where T: Clean<U> {
fn clean(&self, cx: &DocContext) -> U {
self.0.clean(cx)
self.skip_binder().clean(cx)
}
}
......@@ -2846,15 +2846,15 @@ fn clean(&self, cx: &DocContext) -> Type {
}
let mut bindings = vec![];
for ty::Binder(ref pb) in obj.projection_bounds() {
for pb in obj.projection_bounds() {
bindings.push(TypeBinding {
name: cx.tcx.associated_item(pb.item_def_id).name.clean(cx),
ty: pb.ty.clean(cx)
name: cx.tcx.associated_item(pb.item_def_id()).name.clean(cx),
ty: pb.skip_binder().ty.clean(cx)
});
}
let path = external_path(cx, &cx.tcx.item_name(did), Some(did),
false, bindings, principal.0.substs);
false, bindings, principal.skip_binder().substs);
ResolvedPath {
path,
typarams: Some(typarams),
......
......@@ -154,7 +154,7 @@ fn trait_is_same_or_supertrait(cx: &DocContext, child: DefId,
let predicates = cx.tcx.super_predicates_of(child).predicates;
predicates.iter().filter_map(|pred| {
if let ty::Predicate::Trait(ref pred) = *pred {
if pred.0.trait_ref.self_ty().is_self() {
if pred.skip_binder().trait_ref.self_ty().is_self() {
Some(pred.def_id())
} else {
None
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册