From 0eb87ed55fa76e11777254c77ff7f11c74aa2bfa Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Tue, 23 Jun 2020 17:57:24 +0100 Subject: [PATCH] Rename projection_predicates to item_bounds --- .../rustc_infer/src/infer/outlives/verify.rs | 4 +-- compiler/rustc_middle/src/query/mod.rs | 4 +-- .../src/traits/project.rs | 6 ++--- .../src/traits/select/mod.rs | 6 ++--- compiler/rustc_ty/src/ty.rs | 25 +++++++------------ .../rustc_typeck/src/check/compare_method.rs | 8 +++--- 6 files changed, 21 insertions(+), 32 deletions(-) diff --git a/compiler/rustc_infer/src/infer/outlives/verify.rs b/compiler/rustc_infer/src/infer/outlives/verify.rs index 07924298c24..2b827f4f4ed 100644 --- a/compiler/rustc_infer/src/infer/outlives/verify.rs +++ b/compiler/rustc_infer/src/infer/outlives/verify.rs @@ -328,8 +328,8 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> { assoc_item_def_id: DefId, ) -> impl Iterator> { let tcx = self.tcx; - let predicates = tcx.projection_predicates(assoc_item_def_id); - predicates + let bounds = tcx.item_bounds(assoc_item_def_id); + bounds .into_iter() .filter_map(|p| p.to_opt_type_outlives()) .filter_map(|p| p.no_bound_vars()) diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index fe115bbb9c3..fadc7621785 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -156,7 +156,7 @@ rustc_queries! { cache_on_disk_if { key.is_local() } } - /// Returns the list of predicates that can be used for + /// Returns the list of bounds that can be used for /// `SelectionCandidate::ProjectionCandidate` and /// `ProjectionTyCandidate::TraitDef`. /// Specifically this is the bounds (equivalent to) those @@ -169,7 +169,7 @@ rustc_queries! { /// ^^^^^^^^^^^^^^^ /// /// `key` is the `DefId` of the associated type or opaque type. - query projection_predicates(key: DefId) -> &'tcx ty::List> { + query item_bounds(key: DefId) -> &'tcx ty::List> { desc { |tcx| "finding projection predicates for `{}`", tcx.def_path_str(key) } } diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index ef8f7b69b5d..71e34d2dcd0 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -909,10 +909,8 @@ fn assemble_candidates_from_trait_def<'cx, 'tcx>( // Check whether the self-type is itself a projection. // If so, extract what we know from the trait and try to come up with a good answer. let bounds = match *obligation_trait_ref.self_ty().kind() { - ty::Projection(ref data) => { - tcx.projection_predicates(data.item_def_id).subst(tcx, data.substs) - } - ty::Opaque(def_id, substs) => tcx.projection_predicates(def_id).subst(tcx, substs), + ty::Projection(ref data) => tcx.item_bounds(data.item_def_id).subst(tcx, data.substs), + ty::Opaque(def_id, substs) => tcx.item_bounds(def_id).subst(tcx, substs), ty::Infer(ty::TyVar(_)) => { // If the self-type is an inference variable, then it MAY wind up // being a projected type, so induce an ambiguity. diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 114dc79c44f..9bebf8d90c2 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -1171,10 +1171,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let tcx = self.infcx.tcx; let predicates = match *placeholder_trait_predicate.trait_ref.self_ty().kind() { - ty::Projection(ref data) => { - tcx.projection_predicates(data.item_def_id).subst(tcx, data.substs) - } - ty::Opaque(def_id, substs) => tcx.projection_predicates(def_id).subst(tcx, substs), + ty::Projection(ref data) => tcx.item_bounds(data.item_def_id).subst(tcx, data.substs), + ty::Opaque(def_id, substs) => tcx.item_bounds(def_id).subst(tcx, substs), _ => { span_bug!( obligation.cause.span, diff --git a/compiler/rustc_ty/src/ty.rs b/compiler/rustc_ty/src/ty.rs index c4b6b64339a..2be466bf773 100644 --- a/compiler/rustc_ty/src/ty.rs +++ b/compiler/rustc_ty/src/ty.rs @@ -500,7 +500,7 @@ fn asyncness(tcx: TyCtxt<'_>, def_id: DefId) -> hir::IsAsync { /// simplify checking that these bounds are met in impls. This means that /// a bound such as `for<'b> >::U: Clone` can't be used, as in /// `hr-associated-type-bound-1.rs`. -fn associated_type_projection_predicates( +fn associated_type_bounds( tcx: TyCtxt<'_>, assoc_item_def_id: DefId, ) -> &'_ ty::List> { @@ -545,21 +545,14 @@ fn associated_type_projection_predicates( }); let result = tcx.mk_predicates(predicates); - debug!( - "associated_type_projection_predicates({}) = {:?}", - tcx.def_path_str(assoc_item_def_id), - result - ); + debug!("associated_type_bounds({}) = {:?}", tcx.def_path_str(assoc_item_def_id), result); result } /// Opaque types don't have the same issues as associated types: the only /// predicates on an opaque type (excluding those it inherits from its parent /// item) should be of the form we're expecting. -fn opaque_type_projection_predicates( - tcx: TyCtxt<'_>, - def_id: DefId, -) -> &'_ ty::List> { +fn opaque_type_bounds(tcx: TyCtxt<'_>, def_id: DefId) -> &'_ ty::List> { let substs = InternalSubsts::identity_for_item(tcx, def_id); let bounds = tcx.predicates_of(def_id); @@ -607,15 +600,15 @@ fn opaque_type_projection_predicates( }); let result = tcx.mk_predicates(filtered_predicates); - debug!("opaque_type_projection_predicates({}) = {:?}", tcx.def_path_str(def_id), result); + debug!("opaque_type_bounds({}) = {:?}", tcx.def_path_str(def_id), result); result } -fn projection_predicates(tcx: TyCtxt<'_>, def_id: DefId) -> &'_ ty::List> { +fn item_bounds(tcx: TyCtxt<'_>, def_id: DefId) -> &'_ ty::List> { match tcx.def_kind(def_id) { - DefKind::AssocTy => associated_type_projection_predicates(tcx, def_id), - DefKind::OpaqueTy => opaque_type_projection_predicates(tcx, def_id), - k => bug!("projection_predicates called on {}", k.descr(def_id)), + DefKind::AssocTy => associated_type_bounds(tcx, def_id), + DefKind::OpaqueTy => opaque_type_bounds(tcx, def_id), + k => bug!("item_bounds called on {}", k.descr(def_id)), } } @@ -636,7 +629,7 @@ pub fn provide(providers: &mut ty::query::Providers) { instance_def_size_estimate, issue33140_self_ty, impl_defaultness, - projection_predicates, + item_bounds, ..*providers }; } diff --git a/compiler/rustc_typeck/src/check/compare_method.rs b/compiler/rustc_typeck/src/check/compare_method.rs index 7aa54e0ebcc..8111a0bad9f 100644 --- a/compiler/rustc_typeck/src/check/compare_method.rs +++ b/compiler/rustc_typeck/src/check/compare_method.rs @@ -1052,7 +1052,7 @@ crate fn compare_ty_impl<'tcx>( compare_type_predicate_entailment(tcx, impl_ty, impl_ty_span, trait_ty, impl_trait_ref)?; - compare_projection_bounds(tcx, trait_ty, impl_ty, impl_ty_span, impl_trait_ref) + check_type_bounds(tcx, trait_ty, impl_ty, impl_ty_span, impl_trait_ref) })(); } @@ -1170,7 +1170,7 @@ fn compare_type_predicate_entailment<'tcx>( /// For default associated types the normalization is not possible (the value /// from the impl could be overridden). We also can't normalize generic /// associated types (yet) because they contain bound parameters. -fn compare_projection_bounds<'tcx>( +fn check_type_bounds<'tcx>( tcx: TyCtxt<'tcx>, trait_ty: &ty::AssocItem, impl_ty: &ty::AssocItem, @@ -1237,8 +1237,8 @@ fn compare_projection_bounds<'tcx>( ObligationCauseCode::ItemObligation(trait_ty.def_id), ); - let predicates = tcx.projection_predicates(trait_ty.def_id); - debug!("compare_projection_bounds: projection_predicates={:?}", predicates); + let predicates = tcx.item_bounds(trait_ty.def_id); + debug!("check_type_bounds: item_bounds={:?}", predicates); for predicate in predicates { let concrete_ty_predicate = predicate.subst(tcx, rebased_substs);