diff options
| author | Matthew Jasper <mjjasper1@gmail.com> | 2021-02-12 22:41:00 +0000 |
|---|---|---|
| committer | Matthew Jasper <mjjasper1@gmail.com> | 2021-02-13 19:30:07 +0000 |
| commit | 79f6f11816cbef2bba6f5da6d4a4f0aa10535b88 (patch) | |
| tree | 7a135d483d8f0ab00edebae2d8eeffd61764b826 /compiler/rustc_trait_selection/src | |
| parent | 9526c0c6e83f37deb1d48e9761ee9bee2ae94f60 (diff) | |
| download | rust-79f6f11816cbef2bba6f5da6d4a4f0aa10535b88.tar.gz rust-79f6f11816cbef2bba6f5da6d4a4f0aa10535b88.zip | |
Remove some unnecessary `trait_ref` calls
Diffstat (limited to 'compiler/rustc_trait_selection/src')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/fulfill.rs | 20 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/object_safety.rs | 6 |
2 files changed, 11 insertions, 15 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index d4ced20f863..f3bbf901683 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -6,6 +6,7 @@ use rustc_errors::ErrorReported; use rustc_infer::traits::{TraitEngine, TraitEngineExt as _, TraitObligation}; use rustc_middle::mir::interpret::ErrorHandled; use rustc_middle::ty::error::ExpectedFound; +use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::ToPredicate; use rustc_middle::ty::{self, Binder, Const, Ty, TypeFoldable}; use std::marker::PhantomData; @@ -633,9 +634,9 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> { // only reason we can fail to make progress on // trait selection is because we don't have enough // information about the types in the trait. - *stalled_on = trait_ref_infer_vars( + *stalled_on = substs_infer_vars( self.selcx, - trait_obligation.predicate.map_bound(|pred| pred.trait_ref), + trait_obligation.predicate.map_bound(|pred| pred.trait_ref.substs), ); debug!( @@ -663,9 +664,9 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> { match project::poly_project_and_unify_type(self.selcx, &project_obligation) { Ok(Ok(Some(os))) => ProcessResult::Changed(mk_pending(os)), Ok(Ok(None)) => { - *stalled_on = trait_ref_infer_vars( + *stalled_on = substs_infer_vars( self.selcx, - project_obligation.predicate.to_poly_trait_ref(tcx), + project_obligation.predicate.map_bound(|pred| pred.projection_ty.substs), ); ProcessResult::Unchanged } @@ -678,16 +679,15 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> { } } -/// Returns the set of inference variables contained in a trait ref. -fn trait_ref_infer_vars<'a, 'tcx>( +/// Returns the set of inference variables contained in `substs`. +fn substs_infer_vars<'a, 'tcx>( selcx: &mut SelectionContext<'a, 'tcx>, - trait_ref: ty::PolyTraitRef<'tcx>, + substs: ty::Binder<SubstsRef<'tcx>>, ) -> Vec<TyOrConstInferVar<'tcx>> { selcx .infcx() - .resolve_vars_if_possible(trait_ref) - .skip_binder() - .substs + .resolve_vars_if_possible(substs) + .skip_binder() // ok because this check doesn't care about regions .iter() // FIXME(eddyb) try using `skip_current_subtree` to skip everything that // doesn't contain inference variables, not just the outermost level. diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs index e155f0366e1..7de20e477fe 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs @@ -292,11 +292,7 @@ fn predicate_references_self( // // This is ALT2 in issue #56288, see that for discussion of the // possible alternatives. - if data.projection_ty.trait_ref(tcx).substs[1..].iter().any(has_self_ty) { - Some(sp) - } else { - None - } + if data.projection_ty.substs[1..].iter().any(has_self_ty) { Some(sp) } else { None } } ty::PredicateKind::WellFormed(..) | ty::PredicateKind::ObjectSafe(..) |
