From 9ffe9bea53ac6dfb1bc1b23b22fbe1c5fafcfe8c Mon Sep 17 00:00:00 2001 From: Tyler Mandry Date: Fri, 20 Apr 2018 11:46:18 -0500 Subject: [PATCH] Remove methods with implicit Binder::skip_bound Fixes #20664. --- src/librustc/traits/mod.rs | 11 +++++++---- src/librustc/traits/select.rs | 3 ++- src/librustc/ty/sty.rs | 15 --------------- src/librustc_typeck/check/closure.rs | 2 +- src/librustc_typeck/check/method/probe.rs | 2 +- 5 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index 9e636db3a76..728d9f1a027 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -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::bind(substs), + &substs ); // It's possible that the method relies on where clauses that diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index b61407ffdb6..cfc14b7bfe4 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -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 && diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index d5b63939dd6..92e879a584b 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -574,16 +574,6 @@ pub fn def_id(&self) -> DefId { self.skip_binder().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.skip_binder().substs - } - - pub fn input_types<'a>(&'a self) -> impl DoubleEndedIterator> + 'a { - // FIXME(#20664) every use of this fn is probably a bug, it should yield Binder<> - self.skip_binder().input_types() - } - pub fn to_poly_trait_predicate(&self) -> ty::PolyTraitPredicate<'tcx> { // Note that we preserve binding levels Binder(ty::TraitPredicate { trait_ref: self.skip_binder().clone() }) @@ -635,11 +625,6 @@ impl<'tcx> PolyExistentialTraitRef<'tcx> { pub fn def_id(&self) -> DefId { self.skip_binder().def_id } - - pub fn input_types<'a>(&'a self) -> impl DoubleEndedIterator> + 'a { - // FIXME(#20664) every use of this fn is probably a bug, it should yield Binder<> - self.skip_binder().input_types() - } } /// Binder is a binder for higher-ranked lifetimes. It is part of the diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index 0deda993d4f..ed0613860d0 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -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 {:?}", diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 5c1ca44f9f5..b41a6dcf384 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -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()) } -- GitLab