Skip to content

Commit 9ffe9be

Browse files
committed
Remove methods with implicit Binder::skip_bound
Fixes #20664.
1 parent 98546f8 commit 9ffe9be

File tree

5 files changed

+11
-22
lines changed

5 files changed

+11
-22
lines changed

src/librustc/traits/mod.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -855,16 +855,19 @@ fn vtable_methods<'a, 'tcx>(
855855

856856
// the method may have some early-bound lifetimes, add
857857
// regions for those
858-
let substs = Substs::for_item(tcx, def_id,
859-
|_, _| tcx.types.re_erased,
860-
|def, _| trait_ref.substs().type_for_def(def));
858+
let substs = trait_ref.map_bound(|trait_ref| {
859+
Substs::for_item(
860+
tcx, def_id,
861+
|_, _| tcx.types.re_erased,
862+
|def, _| trait_ref.substs.type_for_def(def))
863+
});
861864

862865
// the trait type may have higher-ranked lifetimes in it;
863866
// so erase them if they appear, so that we get the type
864867
// at some particular call site
865868
let substs = tcx.normalize_erasing_late_bound_regions(
866869
ty::ParamEnv::reveal_all(),
867-
&ty::Binder::bind(substs),
870+
&substs
868871
);
869872

870873
// It's possible that the method relies on where clauses that

src/librustc/traits/select.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
786786
// This suffices to allow chains like `FnMut` implemented in
787787
// terms of `Fn` etc, but we could probably make this more
788788
// precise still.
789-
let unbound_input_types = stack.fresh_trait_ref.input_types().any(|ty| ty.is_fresh());
789+
let unbound_input_types =
790+
stack.fresh_trait_ref.skip_binder().input_types().any(|ty| ty.is_fresh());
790791
// this check was an imperfect workaround for a bug n the old
791792
// intercrate mode, it should be removed when that goes away.
792793
if unbound_input_types &&

src/librustc/ty/sty.rs

-15
Original file line numberDiff line numberDiff line change
@@ -574,16 +574,6 @@ impl<'tcx> PolyTraitRef<'tcx> {
574574
self.skip_binder().def_id
575575
}
576576

577-
pub fn substs(&self) -> &'tcx Substs<'tcx> {
578-
// FIXME(#20664) every use of this fn is probably a bug, it should yield Binder<>
579-
self.skip_binder().substs
580-
}
581-
582-
pub fn input_types<'a>(&'a self) -> impl DoubleEndedIterator<Item=Ty<'tcx>> + 'a {
583-
// FIXME(#20664) every use of this fn is probably a bug, it should yield Binder<>
584-
self.skip_binder().input_types()
585-
}
586-
587577
pub fn to_poly_trait_predicate(&self) -> ty::PolyTraitPredicate<'tcx> {
588578
// Note that we preserve binding levels
589579
Binder(ty::TraitPredicate { trait_ref: self.skip_binder().clone() })
@@ -635,11 +625,6 @@ impl<'tcx> PolyExistentialTraitRef<'tcx> {
635625
pub fn def_id(&self) -> DefId {
636626
self.skip_binder().def_id
637627
}
638-
639-
pub fn input_types<'a>(&'a self) -> impl DoubleEndedIterator<Item=Ty<'tcx>> + 'a {
640-
// FIXME(#20664) every use of this fn is probably a bug, it should yield Binder<>
641-
self.skip_binder().input_types()
642-
}
643628
}
644629

645630
/// Binder is a binder for higher-ranked lifetimes. It is part of the

src/librustc_typeck/check/closure.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
303303
return None;
304304
}
305305

306-
let arg_param_ty = trait_ref.substs().type_at(1);
306+
let arg_param_ty = trait_ref.skip_binder().substs.type_at(1);
307307
let arg_param_ty = self.resolve_type_vars_if_possible(&arg_param_ty);
308308
debug!(
309309
"deduce_sig_from_projection: arg_param_ty {:?}",

src/librustc_typeck/check/method/probe.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,7 @@ impl<'tcx> Candidate<'tcx> {
14851485
// inference variables or other artifacts. This
14861486
// means they are safe to put into the
14871487
// `WhereClausePick`.
1488-
assert!(!trait_ref.substs().needs_infer());
1488+
assert!(!trait_ref.skip_binder().substs.needs_infer());
14891489

14901490
WhereClausePick(trait_ref.clone())
14911491
}

0 commit comments

Comments
 (0)