diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index 8a9db246d7c15..8d1f9cea853f9 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -671,7 +671,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> { ) -> Option { let tcx = self.infcx.tcx; let sig = tcx.fn_sig(callee_did).instantiate_identity().skip_binder(); - let clauses = tcx.predicates_of(callee_did); + let clauses = tcx.clauses_of(callee_did); let generic_args = match call_expr.kind { // For method calls, generic arguments are attached to the call node. @@ -688,7 +688,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> { // First, is there at least one method on one of `param`'s trait bounds? // This keeps us from suggesting borrowing the argument to `mem::drop`, e.g. - if !clauses.instantiate_identity(tcx).predicates.iter().any(|clause| { + if !clauses.instantiate_identity(tcx).clauses.iter().any(|clause| { clause.as_trait_clause().is_some_and(|tc| { tc.self_ty().skip_binder().is_param(param.index) && tc.polarity() == ty::PredicatePolarity::Positive @@ -738,8 +738,8 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> { return false; } - // Test the callee's predicates, substituting in `ref_ty` for the moved argument type. - clauses.instantiate(tcx, new_args).predicates.iter().all(|clause| { + // Test the callee's clauses, substituting in `ref_ty` for the moved argument type. + clauses.instantiate(tcx, new_args).clauses.iter().all(|clause| { // Normalize before testing to see through type aliases and projections. let normalized = tcx .try_normalize_erasing_regions( diff --git a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs index ed4e25f009aed..99cd7104692e1 100644 --- a/compiler/rustc_borrowck/src/diagnostics/move_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/move_errors.rs @@ -643,26 +643,26 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> { let closure_hir_id = tcx.local_def_id_to_hir_id(def_id.expect_local()); let hir::Node::Expr(parent) = tcx.parent_hir_node(closure_hir_id) else { return None }; - let predicates = match parent.kind { + let gen_clauses = match parent.kind { hir::ExprKind::Call(callee, _) => { let ty = typeck_result.node_type_opt(callee.hir_id)?; let ty::FnDef(fn_def_id, args) = *ty.kind() else { return None }; - tcx.predicates_of(fn_def_id).instantiate(tcx, args.no_bound_vars().unwrap()) + tcx.clauses_of(fn_def_id).instantiate(tcx, args.no_bound_vars().unwrap()) } hir::ExprKind::MethodCall(..) => { let (_, method) = typeck_result.type_dependent_def(parent.hir_id)?; let args = typeck_result.node_args(parent.hir_id); - tcx.predicates_of(method).instantiate(tcx, args) + tcx.clauses_of(method).instantiate(tcx, args) } _ => return None, }; // Check whether one of the where-bounds requires the closure to impl `Fn[Mut]` // or `AsyncFn[Mut]`. - for (pred, span) in predicates.predicates.iter().zip(predicates.spans.iter()) { - let pred = pred.skip_norm_wip(); + for (clause, span) in gen_clauses.clauses.iter().zip(gen_clauses.spans.iter()) { + let clause = clause.skip_norm_wip(); let dominated_by_fn_trait = self - .closure_clause_kind(pred, def_id, asyncness) + .closure_clause_kind(clause, def_id, asyncness) .is_some_and(|kind| matches!(kind, ty::ClosureKind::Fn | ty::ClosureKind::FnMut)); if dominated_by_fn_trait { // Found `` or diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs index cce2bba7b3365..56dc3ed8c8600 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs @@ -1210,19 +1210,17 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { return false; }; - tcx.predicates_of(callee_def_id) - .instantiate(tcx, generic_args) - .predicates - .iter() - .any(|predicate| { - predicate.as_trait_clause().is_some_and(|trait_pred| { + tcx.clauses_of(callee_def_id).instantiate(tcx, generic_args).clauses.iter().any( + |clause| { + clause.as_trait_clause().is_some_and(|trait_pred| { trait_pred.polarity() == ty::PredicatePolarity::Positive && tcx.fn_trait_kind_from_def_id(trait_pred.def_id()) == Some(ty::ClosureKind::Fn) && trait_pred.self_ty().skip_binder().peel_refs() == input_ty.peel_refs() }) - }) + }, + ) }; // If the HIR node is a function or method call, get the DefId diff --git a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs index 72eff72c7f9ed..e32ac17fd8016 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_errors.rs @@ -1167,17 +1167,17 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> { } }); - let preds = tcx.predicates_of(method_def_id).instantiate(tcx, args); + let clauses = tcx.clauses_of(method_def_id).instantiate(tcx, args); let ocx = ObligationCtxt::new(&self.infcx); - ocx.register_obligations(preds.iter().map(|(pred, span)| { - trace!(?pred); + ocx.register_obligations(clauses.iter().map(|(clause, span)| { + trace!(?clause); Obligation::misc( tcx, span, self.mir_def_id(), self.infcx.param_env, - pred.skip_norm_wip(), + clause.skip_norm_wip(), ) })); diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index 1e15382c3e54b..822078da2c727 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -1065,12 +1065,12 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { return None; }; - let predicates: Vec<_> = self + let clauses: Vec<_> = self .infcx .tcx - .predicates_of(self.body.source.def_id()) + .clauses_of(self.body.source.def_id()) .instantiate_identity(self.infcx.tcx) - .predicates + .clauses .into_iter() .map(Unnormalized::skip_norm_wip) .collect(); @@ -1081,7 +1081,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { .defining_ty .upvar_tys() .iter() - .position(|ty| self.any_param_predicate_mentions(&predicates, ty, region)) + .position(|ty| self.any_param_clause_mentions(&clauses, ty, region)) { let (upvar_name, upvar_span) = self.regioncx.get_upvar_name_and_span_for_region( self.infcx.tcx, @@ -1099,7 +1099,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { .universal_regions() .unnormalized_input_tys .iter() - .position(|ty| self.any_param_predicate_mentions(&predicates, *ty, region)) + .position(|ty| self.any_param_clause_mentions(&clauses, *ty, region)) { let (arg_name, arg_span) = self.regioncx.get_argument_name_and_span_for_region( self.body, @@ -1119,7 +1119,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { } } - fn any_param_predicate_mentions( + fn any_param_clause_mentions( &self, clauses: &[ty::Clause<'tcx>], ty: Ty<'tcx>, diff --git a/compiler/rustc_borrowck/src/type_check/canonical.rs b/compiler/rustc_borrowck/src/type_check/canonical.rs index 08b0ec8edbca2..5931d6f7370b0 100644 --- a/compiler/rustc_borrowck/src/type_check/canonical.rs +++ b/compiler/rustc_borrowck/src/type_check/canonical.rs @@ -141,18 +141,18 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } #[instrument(level = "debug", skip(self))] - pub(super) fn normalize_and_prove_instantiated_predicates( + pub(super) fn normalize_and_prove_instantiated_clauses( &mut self, // Keep this parameter for now, in case we start using // it in `ConstraintCategory` at some point. _def_id: DefId, - instantiated_predicates: ty::InstantiatedPredicates<'tcx>, + instantiated_clauses: ty::InstantiatedClauses<'tcx>, locations: Locations, ) { - for (predicate, span) in instantiated_predicates { - debug!(?span, ?predicate); + for (clause, span) in instantiated_clauses { + debug!(?span, ?clause); let category = ConstraintCategory::Predicate(span); - let clause = self.normalize_with_category(predicate, locations, category); + let clause = self.normalize_with_category(clause, locations, category); self.prove_clause(clause, locations, category); } } diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 370d43d35d3ac..47ff62e9f85a8 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -1489,7 +1489,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { if self.infcx.type_is_sized_modulo_regions(self.infcx.param_env, dst.ty) { // Wide to thin ptr cast. This may even occur in an env with - // impossible predicates, such as `where dyn Trait: Sized`. + // impossible clauses, such as `where dyn Trait: Sized`. // In this case, we don't want to fall into the case below, // since the types may not actually be equatable, but it's // fine to perform this operation in an impossible env. @@ -1722,10 +1722,10 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { && tcx.anon_const_kind(def_id) == ty::AnonConstKind::NonTypeSystemInline { let def_id = def_id.expect_local(); - let predicates = self.prove_closure_bounds(tcx, def_id, uv.args, location); - self.normalize_and_prove_instantiated_predicates( + let clauses = self.prove_closure_bounds(tcx, def_id, uv.args, location); + self.normalize_and_prove_instantiated_clauses( def_id.to_def_id(), - predicates, + clauses, location.to_locations(), ); } @@ -1840,10 +1840,10 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { if let ty::FnDef(def_id, args) = *constant.const_.ty().kind() { let args = args.no_bound_vars().unwrap(); - let instantiated_predicates = tcx.predicates_of(def_id).instantiate(tcx, args); - self.normalize_and_prove_instantiated_predicates( + let instantiated_clauses = tcx.clauses_of(def_id).instantiate(tcx, args); + self.normalize_and_prove_instantiated_clauses( def_id, - instantiated_predicates, + instantiated_clauses, locations, ); @@ -2603,9 +2603,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { aggregate_kind, location ); - let (def_id, instantiated_predicates) = match *aggregate_kind { + let (def_id, instantiated_clauses) = match *aggregate_kind { AggregateKind::Adt(adt_did, _, args, _, _) => { - (adt_did, tcx.predicates_of(adt_did).instantiate(tcx, args)) + (adt_did, tcx.clauses_of(adt_did).instantiate(tcx, args)) } // For closures, we have some **extra requirements** we @@ -2634,13 +2634,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } AggregateKind::Array(_) | AggregateKind::Tuple | AggregateKind::RawPtr(..) => { - (CRATE_DEF_ID.to_def_id(), ty::InstantiatedPredicates::empty()) + (CRATE_DEF_ID.to_def_id(), ty::InstantiatedClauses::empty()) } }; - self.normalize_and_prove_instantiated_predicates( + self.normalize_and_prove_instantiated_clauses( def_id, - instantiated_predicates, + instantiated_clauses, location.to_locations(), ); } @@ -2651,7 +2651,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { def_id: LocalDefId, args: GenericArgsRef<'tcx>, location: Location, - ) -> ty::InstantiatedPredicates<'tcx> { + ) -> ty::InstantiatedClauses<'tcx> { let root_def_id = self.root_cx.root_def_id(); // We will have to handle propagated closure requirements for this closure, // but need to defer this until the nested body has been fully borrow checked. @@ -2695,7 +2695,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { ); } - tcx.predicates_of(def_id).instantiate(tcx, args) + tcx.clauses_of(def_id).instantiate(tcx, args) } } diff --git a/compiler/rustc_const_eval/src/interpret/intern.rs b/compiler/rustc_const_eval/src/interpret/intern.rs index f74a85c7340ae..ecc00547e4599 100644 --- a/compiler/rustc_const_eval/src/interpret/intern.rs +++ b/compiler/rustc_const_eval/src/interpret/intern.rs @@ -172,7 +172,7 @@ fn intern_as_new_static<'tcx>( feed.eval_static_initializer(Ok(alloc)); feed.generics_of(tcx.generics_of(static_id).clone()); feed.def_ident_span(tcx.def_ident_span(static_id)); - feed.explicit_predicates_of(tcx.explicit_predicates_of(static_id)); + feed.explicit_clauses_of(tcx.explicit_clauses_of(static_id)); feed.feed_hir(); } diff --git a/compiler/rustc_hir_analysis/src/check/always_applicable.rs b/compiler/rustc_hir_analysis/src/check/always_applicable.rs index 9a8008214ed04..b9c0011d1a4ff 100644 --- a/compiler/rustc_hir_analysis/src/check/always_applicable.rs +++ b/compiler/rustc_hir_analysis/src/check/always_applicable.rs @@ -293,7 +293,7 @@ fn ensure_impl_predicates_are_implied_by_item_defn<'tcx>( ocx.eq(&ObligationCause::dummy_with_span(impl_span), adt_env, fresh_adt_ty, impl_adt_ty) .expect("equating fully generic trait ref should never fail"); - for (clause, span) in tcx.predicates_of(impl_def_id).instantiate(tcx, fresh_impl_args) { + for (clause, span) in tcx.clauses_of(impl_def_id).instantiate(tcx, fresh_impl_args) { let normalize_cause = traits::ObligationCause::misc(span, impl_def_id); let pred = ocx.normalize(&normalize_cause, adt_env, clause); let cause = traits::ObligationCause::new( diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 626529cb6fc5b..26d289a0fc70c 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -792,7 +792,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), DefKind::Static { .. } => { tcx.ensure_ok().generics_of(def_id); tcx.ensure_ok().type_of(def_id); - tcx.ensure_ok().predicates_of(def_id); + tcx.ensure_ok().clauses_of(def_id); check_static_inhabited(tcx, def_id); check_static_linkage(tcx, def_id); @@ -809,7 +809,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), DefKind::Enum => { tcx.ensure_ok().generics_of(def_id); tcx.ensure_ok().type_of(def_id); - tcx.ensure_ok().predicates_of(def_id); + tcx.ensure_ok().clauses_of(def_id); crate::collect::check_enum_variant_types(tcx, def_id); check_enum(tcx, def_id); check_variances_for_type_defn(tcx, def_id); @@ -820,7 +820,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), DefKind::Fn => { tcx.ensure_ok().generics_of(def_id); tcx.ensure_ok().type_of(def_id); - tcx.ensure_ok().predicates_of(def_id); + tcx.ensure_ok().clauses_of(def_id); tcx.ensure_ok().fn_sig(def_id); tcx.ensure_ok().codegen_fn_attrs(def_id); if let Some(i) = tcx.intrinsic(def_id) { @@ -835,7 +835,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), DefKind::Impl { of_trait } => { tcx.ensure_ok().generics_of(def_id); tcx.ensure_ok().type_of(def_id); - tcx.ensure_ok().predicates_of(def_id); + tcx.ensure_ok().clauses_of(def_id); tcx.ensure_ok().associated_items(def_id); if of_trait { let impl_trait_header = tcx.impl_trait_header(def_id); @@ -853,8 +853,8 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), DefKind::Trait => { tcx.ensure_ok().generics_of(def_id); tcx.ensure_ok().trait_def(def_id); - tcx.ensure_ok().explicit_super_predicates_of(def_id); - tcx.ensure_ok().predicates_of(def_id); + tcx.ensure_ok().explicit_super_clauses_of(def_id); + tcx.ensure_ok().clauses_of(def_id); tcx.ensure_ok().associated_items(def_id); let assoc_items = tcx.associated_items(def_id); @@ -879,9 +879,9 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), } DefKind::TraitAlias => { tcx.ensure_ok().generics_of(def_id); - tcx.ensure_ok().explicit_implied_predicates_of(def_id); - tcx.ensure_ok().explicit_super_predicates_of(def_id); - tcx.ensure_ok().predicates_of(def_id); + tcx.ensure_ok().explicit_implied_clauses_of(def_id); + tcx.ensure_ok().explicit_super_clauses_of(def_id); + tcx.ensure_ok().clauses_of(def_id); res = res.and(wfcheck::check_trait(tcx, def_id)); // Trait aliases do not have hir checks anymore return res; @@ -889,13 +889,13 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), def_kind @ (DefKind::Struct | DefKind::Union) => { tcx.ensure_ok().generics_of(def_id); tcx.ensure_ok().type_of(def_id); - tcx.ensure_ok().predicates_of(def_id); + tcx.ensure_ok().clauses_of(def_id); let adt = tcx.adt_def(def_id).non_enum_variant(); for f in adt.fields.iter() { tcx.ensure_ok().generics_of(f.did); tcx.ensure_ok().type_of(f.did); - tcx.ensure_ok().predicates_of(f.did); + tcx.ensure_ok().clauses_of(f.did); } if let Some((_, ctor_def_id)) = adt.ctor { @@ -924,7 +924,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), check_opaque(tcx, def_id); } - tcx.ensure_ok().predicates_of(def_id); + tcx.ensure_ok().clauses_of(def_id); tcx.ensure_ok().explicit_item_bounds(def_id); tcx.ensure_ok().explicit_item_self_bounds(def_id); if tcx.is_conditionally_const(def_id) { @@ -940,7 +940,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), DefKind::Const { .. } => { tcx.ensure_ok().generics_of(def_id); tcx.ensure_ok().type_of(def_id); - tcx.ensure_ok().predicates_of(def_id); + tcx.ensure_ok().clauses_of(def_id); res = res.and(enter_wf_checking_ctxt(tcx, def_id, |wfcx| { let ty = tcx.type_of(def_id).instantiate_identity(); @@ -973,7 +973,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), DefKind::TyAlias => { tcx.ensure_ok().generics_of(def_id); tcx.ensure_ok().type_of(def_id); - tcx.ensure_ok().predicates_of(def_id); + tcx.ensure_ok().clauses_of(def_id); let ty = tcx.type_of(def_id).instantiate_identity(); let span = tcx.def_span(def_id); if tcx.type_alias_is_checked(def_id) { @@ -1069,7 +1069,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), tcx.ensure_ok().generics_of(def_id); tcx.ensure_ok().type_of(def_id); - tcx.ensure_ok().predicates_of(def_id); + tcx.ensure_ok().clauses_of(def_id); if tcx.is_conditionally_const(def_id) { tcx.ensure_ok().explicit_implied_const_bounds(def_id); tcx.ensure_ok().const_conditions(def_id); @@ -1109,7 +1109,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), tcx.ensure_ok().codegen_fn_attrs(def_id); tcx.ensure_ok().type_of(def_id); tcx.ensure_ok().fn_sig(def_id); - tcx.ensure_ok().predicates_of(def_id); + tcx.ensure_ok().clauses_of(def_id); res = res.and(check_associated_item(tcx, def_id)); let assoc_item = tcx.associated_item(def_id); match assoc_item.container { @@ -1126,7 +1126,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), } DefKind::AssocConst { .. } => { tcx.ensure_ok().type_of(def_id); - tcx.ensure_ok().predicates_of(def_id); + tcx.ensure_ok().clauses_of(def_id); res = res.and(check_associated_item(tcx, def_id)); let assoc_item = tcx.associated_item(def_id); match assoc_item.container { @@ -1142,7 +1142,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), return res; } DefKind::AssocTy => { - tcx.ensure_ok().predicates_of(def_id); + tcx.ensure_ok().clauses_of(def_id); res = res.and(check_associated_item(tcx, def_id)); let assoc_item = tcx.associated_item(def_id); @@ -2071,11 +2071,11 @@ fn check_type_alias_type_params_are_used<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalD // Lazily calculated because it is only needed in case of an error. let bounded_params = LazyCell::new(|| { - tcx.explicit_predicates_of(def_id) - .predicates + tcx.explicit_clauses_of(def_id) + .clauses .iter() - .filter_map(|(predicate, span)| { - let bounded_ty = match predicate.kind().skip_binder() { + .filter_map(|(clause, span)| { + let bounded_ty = match clause.kind().skip_binder() { ty::ClauseKind::Trait(pred) => pred.trait_ref.self_ty(), ty::ClauseKind::TypeOutlives(pred) => pred.0, _ => return None, diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index 6489c626084a0..e9add5aa2c3bd 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -69,7 +69,7 @@ fn compare_impl_method<'tcx>( impl_trait_ref: ty::TraitRef<'tcx>, ) -> Result<(), ErrorGuaranteed> { check_method_is_structurally_compatible(tcx, impl_m, trait_m, impl_trait_ref, false)?; - compare_method_predicate_entailment(tcx, impl_m, trait_m, impl_trait_ref)?; + compare_method_clause_entailment(tcx, impl_m, trait_m, impl_trait_ref)?; Ok(()) } @@ -165,13 +165,13 @@ fn check_method_is_structurally_compatible<'tcx>( /// /// We do this by creating a parameter environment which contains a /// generic parameter corresponding to `impl_to_placeholder_args`. We then build -/// `trait_to_placeholder_args` and use it to convert the predicates contained +/// `trait_to_placeholder_args` and use it to convert the clauses contained /// in the `trait_m` generics to the placeholder form. /// -/// Finally we register each of these predicates as an obligation and check that +/// Finally we register each of these clauses as an obligation and check that /// they hold. #[instrument(level = "debug", skip(tcx, impl_trait_ref))] -fn compare_method_predicate_entailment<'tcx>( +fn compare_method_clause_entailment<'tcx>( tcx: TyCtxt<'tcx>, impl_m: ty::AssocItem, trait_m: ty::AssocItem, @@ -203,27 +203,26 @@ fn compare_method_predicate_entailment<'tcx>( ); debug!(?trait_to_impl_args); - let impl_m_predicates = tcx.predicates_of(impl_m.def_id); - let trait_m_predicates = tcx.predicates_of(trait_m.def_id); + let impl_m_clauses = tcx.clauses_of(impl_m.def_id); + let trait_m_clauses = tcx.clauses_of(trait_m.def_id); // This is the only tricky bit of the new way we check implementation methods - // We need to build a set of predicates where only the method-level bounds + // We need to build a set of clauses where only the method-level bounds // are from the trait and we assume all other bounds from the implementation // to be previously satisfied. // // We then register the obligations from the impl_m and check to see // if all constraints hold. - let impl_predicates = tcx.predicates_of(impl_m_predicates.parent.unwrap()); - let mut hybrid_preds = impl_predicates.instantiate_identity(tcx).predicates; - hybrid_preds.extend( - trait_m_predicates.instantiate_own(tcx, trait_to_impl_args).map(|(predicate, _)| predicate), - ); + let impl_clauses = tcx.clauses_of(impl_m_clauses.parent.unwrap()); + let mut hybrid_clauses = impl_clauses.instantiate_identity(tcx).clauses; + hybrid_clauses + .extend(trait_m_clauses.instantiate_own(tcx, trait_to_impl_args).map(|(clause, _)| clause)); let is_conditionally_const = tcx.is_conditionally_const(impl_m.def_id); if is_conditionally_const { // Augment the hybrid param-env with the const conditions // of the impl header and the trait method. - hybrid_preds.extend( + hybrid_clauses.extend( tcx.const_conditions(impl_def_id) .instantiate_identity(tcx) .into_iter() @@ -236,9 +235,9 @@ fn compare_method_predicate_entailment<'tcx>( ); } - let hybrid_preds = hybrid_preds.into_iter().map(Unnormalized::skip_norm_wip); + let hybrid_clauses = hybrid_clauses.into_iter().map(Unnormalized::skip_norm_wip); let normalize_cause = traits::ObligationCause::misc(impl_m_span, impl_m_def_id); - let param_env = ty::ParamEnv::new(tcx.mk_clauses_from_iter(hybrid_preds)); + let param_env = ty::ParamEnv::new(tcx.mk_clauses_from_iter(hybrid_clauses)); // NOTE(-Zhigher-ranked-assumptions): The `hybrid_preds` // should be well-formed. However, using them may result in // region errors as we currently don't track placeholder @@ -259,14 +258,14 @@ fn compare_method_predicate_entailment<'tcx>( let infcx = &tcx.infer_ctxt().build(TypingMode::non_body_analysis()); let ocx = ObligationCtxt::new_with_diagnostics(infcx); - // Create obligations for each predicate declared by the impl + // Create obligations for each clause declared by the impl // definition in the context of the hybrid param-env. This makes // sure that the impl's method's where clauses are not more // restrictive than the trait's method (and the impl itself). - let impl_m_own_bounds = impl_m_predicates.instantiate_own_identity(); - for (predicate, span) in impl_m_own_bounds { + let impl_m_own_bounds = impl_m_clauses.instantiate_own_identity(); + for (clause, span) in impl_m_own_bounds { let normalize_cause = traits::ObligationCause::misc(span, impl_m_def_id); - let predicate = ocx.normalize(&normalize_cause, param_env, predicate); + let clause = ocx.normalize(&normalize_cause, param_env, clause); let cause = ObligationCause::new( span, @@ -277,7 +276,7 @@ fn compare_method_predicate_entailment<'tcx>( kind: impl_m.kind, }, ); - ocx.register_obligation(traits::Obligation::new(tcx, cause, param_env, predicate)); + ocx.register_obligation(traits::Obligation::new(tcx, cause, param_env, clause)); } // If we're within a const implementation, we need to make sure that the method @@ -488,13 +487,13 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>( impl_trait_ref.args, ); - let hybrid_preds = tcx - .predicates_of(impl_m.container_id(tcx)) + let hybrid_clauses = tcx + .clauses_of(impl_m.container_id(tcx)) .instantiate_identity(tcx) .into_iter() - .chain(tcx.predicates_of(trait_m.def_id).instantiate_own(tcx, trait_to_impl_args)) + .chain(tcx.clauses_of(trait_m.def_id).instantiate_own(tcx, trait_to_impl_args)) .map(|(clause, _)| clause.skip_norm_wip()); - let param_env = ty::ParamEnv::new(tcx.mk_clauses_from_iter(hybrid_preds)); + let param_env = ty::ParamEnv::new(tcx.mk_clauses_from_iter(hybrid_clauses)); let param_env = traits::normalize_param_env_or_error( tcx, param_env, @@ -509,11 +508,11 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>( // We check these because if the where clauses of the signatures do not match // up, then we don't want to give spurious other errors that point at the RPITITs. // They're not necessary to check, though, because we already check them in - // `compare_method_predicate_entailment`. - let impl_m_own_bounds = tcx.predicates_of(impl_m_def_id).instantiate_own_identity(); - for (predicate, span) in impl_m_own_bounds { + // `compare_method_clause_entailment`. + let impl_m_own_bounds = tcx.clauses_of(impl_m_def_id).instantiate_own_identity(); + for (clause, span) in impl_m_own_bounds { let normalize_cause = traits::ObligationCause::misc(span, impl_m_def_id); - let predicate = ocx.normalize(&normalize_cause, param_env, predicate); + let clause = ocx.normalize(&normalize_cause, param_env, clause); let cause = ObligationCause::new( span, @@ -524,7 +523,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>( kind: impl_m.kind, }, ); - ocx.register_obligation(traits::Obligation::new(tcx, cause, param_env, predicate)); + ocx.register_obligation(traits::Obligation::new(tcx, cause, param_env, clause)); } // Normalize the impl signature with fresh variables for lifetime inference. @@ -648,13 +647,13 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>( // Unify the whole function signature. We need to do this to fully infer // the lifetimes of the return type, but do this after unifying just the // return types, since we want to avoid duplicating errors from - // `compare_method_predicate_entailment`. + // `compare_method_clause_entailment`. match ocx.eq(&cause, param_env, trait_sig, impl_sig) { Ok(()) => {} Err(terr) => { - // This function gets called during `compare_method_predicate_entailment` when normalizing a + // This function gets called during `compare_method_clause_entailment` when normalizing a // signature that contains RPITIT. When the method signatures don't match, we have to - // emit an error now because `compare_method_predicate_entailment` will not report the error + // emit an error now because `compare_method_clause_entailment` will not report the error // when normalization fails. let emitted = report_trait_method_mismatch( infcx, @@ -1375,9 +1374,7 @@ fn check_region_late_boundedness<'tcx>( tcx.def_span(trait_param_def_id), format!("`{}` is late-bound", tcx.item_name(trait_param_def_id)), ); - if let Some(span) = - find_region_in_predicates(tcx, impl_m.def_id, early_bound_region) - { + if let Some(span) = find_region_in_clauses(tcx, impl_m.def_id, early_bound_region) { multispan.push_span_label( span, format!( @@ -1415,8 +1412,7 @@ fn check_region_late_boundedness<'tcx>( tcx.def_span(trait_param_def_id), format!("`{}` is early-bound", tcx.item_name(trait_param_def_id)), ); - if let Some(span) = - find_region_in_predicates(tcx, trait_m.def_id, early_bound_region) + if let Some(span) = find_region_in_clauses(tcx, trait_m.def_id, early_bound_region) { multispan.push_span_label( span, @@ -1440,13 +1436,13 @@ fn check_region_late_boundedness<'tcx>( Some(diag.emit()) } -fn find_region_in_predicates<'tcx>( +fn find_region_in_clauses<'tcx>( tcx: TyCtxt<'tcx>, def_id: DefId, early_bound_region: ty::Region<'tcx>, ) -> Option { - for (pred, span) in tcx.explicit_predicates_of(def_id).instantiate_identity(tcx) { - if pred.skip_norm_wip().visit_with(&mut FindRegion(early_bound_region)).is_break() { + for (clause, span) in tcx.explicit_clauses_of(def_id).instantiate_identity(tcx) { + if clause.skip_norm_wip().visit_with(&mut FindRegion(early_bound_region)).is_break() { return Some(span); } } @@ -2150,7 +2146,7 @@ fn compare_impl_const<'tcx>( compare_number_of_generics(tcx, impl_const_item, trait_const_item, false)?; compare_generic_param_kinds(tcx, impl_const_item, trait_const_item, false)?; check_region_bounds_on_impl_item(tcx, impl_const_item, trait_const_item, false)?; - compare_const_predicate_entailment(tcx, impl_const_item, trait_const_item, impl_trait_ref) + compare_const_clause_entailment(tcx, impl_const_item, trait_const_item, impl_trait_ref) } fn compare_type_const<'tcx>( @@ -2182,11 +2178,12 @@ fn compare_type_const<'tcx>( Ok(()) } -/// The equivalent of [compare_method_predicate_entailment], but for associated constants +/// The equivalent of [compare_method_clause_entailment], but for associated constants /// instead of associated functions. -// FIXME(generic_const_items): If possible extract the common parts of `compare_{type,const}_predicate_entailment`. +// FIXME(generic_const_items): If possible extract the common parts of +// `compare_{type,const}_clause_entailment`. #[instrument(level = "debug", skip(tcx))] -fn compare_const_predicate_entailment<'tcx>( +fn compare_const_clause_entailment<'tcx>( tcx: TyCtxt<'tcx>, impl_ct: ty::AssocItem, trait_ct: ty::AssocItem, @@ -2218,21 +2215,19 @@ fn compare_const_predicate_entailment<'tcx>( }; let mut cause = ObligationCause::new(impl_ct_span, impl_ct_def_id, code.clone()); - let impl_ct_predicates = tcx.predicates_of(impl_ct.def_id); - let trait_ct_predicates = tcx.predicates_of(trait_ct.def_id); + let impl_ct_clauses = tcx.clauses_of(impl_ct.def_id); + let trait_ct_clauses = tcx.clauses_of(trait_ct.def_id); - // The predicates declared by the impl definition, the trait and the + // The clauses declared by the impl definition, the trait and the // associated const in the trait are assumed. - let impl_predicates = tcx.predicates_of(impl_ct_predicates.parent.unwrap()); - let mut hybrid_preds = impl_predicates.instantiate_identity(tcx).predicates; - hybrid_preds.extend( - trait_ct_predicates - .instantiate_own(tcx, trait_to_impl_args) - .map(|(predicate, _)| predicate), + let impl_clauses = tcx.clauses_of(impl_ct_clauses.parent.unwrap()); + let mut hybrid_clauses = impl_clauses.instantiate_identity(tcx).clauses; + hybrid_clauses.extend( + trait_ct_clauses.instantiate_own(tcx, trait_to_impl_args).map(|(clause, _)| clause), ); - let hybrid_preds = hybrid_preds.into_iter().map(Unnormalized::skip_norm_wip); + let hybrid_clauses = hybrid_clauses.into_iter().map(Unnormalized::skip_norm_wip); - let param_env = ty::ParamEnv::new(tcx.mk_clauses_from_iter(hybrid_preds)); + let param_env = ty::ParamEnv::new(tcx.mk_clauses_from_iter(hybrid_clauses)); let param_env = traits::normalize_param_env_or_error( tcx, param_env, @@ -2242,13 +2237,13 @@ fn compare_const_predicate_entailment<'tcx>( let infcx = tcx.infer_ctxt().build(TypingMode::non_body_analysis()); let ocx = ObligationCtxt::new_with_diagnostics(&infcx); - let impl_ct_own_bounds = impl_ct_predicates.instantiate_own_identity(); - for (predicate, span) in impl_ct_own_bounds { + let impl_ct_own_bounds = impl_ct_clauses.instantiate_own_identity(); + for (clause, span) in impl_ct_own_bounds { let cause = ObligationCause::misc(span, impl_ct_def_id); - let predicate = ocx.normalize(&cause, param_env, predicate); + let clause = ocx.normalize(&cause, param_env, clause); let cause = ObligationCause::new(span, impl_ct_def_id, code.clone()); - ocx.register_obligation(traits::Obligation::new(tcx, cause, param_env, predicate)); + ocx.register_obligation(traits::Obligation::new(tcx, cause, param_env, clause)); } // There is no "body" here, so just pass dummy id. @@ -2316,14 +2311,14 @@ fn compare_impl_ty<'tcx>( compare_number_of_generics(tcx, impl_ty, trait_ty, false)?; compare_generic_param_kinds(tcx, impl_ty, trait_ty, false)?; check_region_bounds_on_impl_item(tcx, impl_ty, trait_ty, false)?; - compare_type_predicate_entailment(tcx, impl_ty, trait_ty, impl_trait_ref)?; + compare_type_clause_entailment(tcx, impl_ty, trait_ty, impl_trait_ref)?; check_type_bounds(tcx, trait_ty, impl_ty, impl_trait_ref) } -/// The equivalent of [compare_method_predicate_entailment], but for associated types +/// The equivalent of [compare_method_clause_entailment], but for associated types /// instead of associated functions. #[instrument(level = "debug", skip(tcx))] -fn compare_type_predicate_entailment<'tcx>( +fn compare_type_clause_entailment<'tcx>( tcx: TyCtxt<'tcx>, impl_ty: ty::AssocItem, trait_ty: ty::AssocItem, @@ -2336,10 +2331,10 @@ fn compare_type_predicate_entailment<'tcx>( impl_trait_ref.args, ); - let impl_ty_predicates = tcx.predicates_of(impl_ty.def_id); - let trait_ty_predicates = tcx.predicates_of(trait_ty.def_id); + let impl_ty_clauses = tcx.clauses_of(impl_ty.def_id); + let trait_ty_clauses = tcx.clauses_of(trait_ty.def_id); - let impl_ty_own_bounds = impl_ty_predicates.instantiate_own_identity(); + let impl_ty_own_bounds = impl_ty_clauses.instantiate_own_identity(); // If there are no bounds, then there are no const conditions, so no need to check that here. if impl_ty_own_bounds.len() == 0 { // Nothing to check. @@ -2352,16 +2347,14 @@ fn compare_type_predicate_entailment<'tcx>( let impl_ty_def_id = impl_ty.def_id.expect_local(); debug!(?trait_to_impl_args); - // The predicates declared by the impl definition, the trait and the + // The clauses declared by the impl definition, the trait and the // associated type in the trait are assumed. - let impl_predicates = tcx.predicates_of(impl_ty_predicates.parent.unwrap()); - let mut hybrid_preds = impl_predicates.instantiate_identity(tcx).predicates; - hybrid_preds.extend( - trait_ty_predicates - .instantiate_own(tcx, trait_to_impl_args) - .map(|(predicate, _)| predicate), + let impl_clauses = tcx.clauses_of(impl_ty_clauses.parent.unwrap()); + let mut hybrid_clauses = impl_clauses.instantiate_identity(tcx).clauses; + hybrid_clauses.extend( + trait_ty_clauses.instantiate_own(tcx, trait_to_impl_args).map(|(predicate, _)| predicate), ); - debug!(?hybrid_preds); + debug!(?hybrid_clauses); let impl_ty_span = tcx.def_span(impl_ty_def_id); let normalize_cause = ObligationCause::misc(impl_ty_span, impl_ty_def_id); @@ -2370,8 +2363,8 @@ fn compare_type_predicate_entailment<'tcx>( if is_conditionally_const { // Augment the hybrid param-env with the const conditions // of the impl header and the trait assoc type. - hybrid_preds.extend( - tcx.const_conditions(impl_ty_predicates.parent.unwrap()) + hybrid_clauses.extend( + tcx.const_conditions(impl_ty_clauses.parent.unwrap()) .instantiate_identity(tcx) .into_iter() .chain( @@ -2383,17 +2376,17 @@ fn compare_type_predicate_entailment<'tcx>( ); } - let hybrid_preds = hybrid_preds.into_iter().map(Unnormalized::skip_norm_wip); - let param_env = ty::ParamEnv::new(tcx.mk_clauses_from_iter(hybrid_preds)); + let hybrid_clauses = hybrid_clauses.into_iter().map(Unnormalized::skip_norm_wip); + let param_env = ty::ParamEnv::new(tcx.mk_clauses_from_iter(hybrid_clauses)); let param_env = traits::normalize_param_env_or_error(tcx, param_env, normalize_cause); debug!(caller_bounds=?param_env.caller_bounds()); let infcx = tcx.infer_ctxt().build(TypingMode::non_body_analysis()); let ocx = ObligationCtxt::new_with_diagnostics(&infcx); - for (predicate, span) in impl_ty_own_bounds { + for (clause, span) in impl_ty_own_bounds { let cause = ObligationCause::misc(span, impl_ty_def_id); - let predicate = ocx.normalize(&cause, param_env, predicate); + let clause = ocx.normalize(&cause, param_env, clause); let cause = ObligationCause::new( span, @@ -2404,7 +2397,7 @@ fn compare_type_predicate_entailment<'tcx>( kind: impl_ty.kind, }, ); - ocx.register_obligation(traits::Obligation::new(tcx, cause, param_env, predicate)); + ocx.register_obligation(traits::Obligation::new(tcx, cause, param_env, clause)); } if is_conditionally_const { diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs index 70ab2cc44e0c6..6b5313e4254fa 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs @@ -139,13 +139,13 @@ pub(crate) fn check_refining_return_position_impl_trait_in_trait<'tcx>( pairs.push((trait_projection, impl_opaque)); } - let hybrid_preds = tcx - .predicates_of(impl_def_id) + let hybrid_clauses = tcx + .clauses_of(impl_def_id) .instantiate_identity(tcx) .into_iter() - .chain(tcx.predicates_of(trait_m.def_id).instantiate_own(tcx, trait_m_to_impl_m_args)) + .chain(tcx.clauses_of(trait_m.def_id).instantiate_own(tcx, trait_m_to_impl_m_args)) .map(|(clause, _)| clause.skip_norm_wip()); - let param_env = ty::ParamEnv::new(tcx.mk_clauses_from_iter(hybrid_preds)); + let param_env = ty::ParamEnv::new(tcx.mk_clauses_from_iter(hybrid_clauses)); let param_env = normalize_param_env_or_error(tcx, param_env, ObligationCause::dummy()); let ref infcx = tcx.infer_ctxt().build(TypingMode::non_body_analysis()); diff --git a/compiler/rustc_hir_analysis/src/check/entry.rs b/compiler/rustc_hir_analysis/src/check/entry.rs index 9fae7ddaca64e..a18fdcfa6f5fe 100644 --- a/compiler/rustc_hir_analysis/src/check/entry.rs +++ b/compiler/rustc_hir_analysis/src/check/entry.rs @@ -166,15 +166,15 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) -> Result<(), ErrorGuar )?; let main_fn_generics = tcx.generics_of(main_def_id); - let main_fn_predicates = tcx.predicates_of(main_def_id); + let main_fn_clauses = tcx.clauses_of(main_def_id); if main_fn_generics.count() != 0 || !main_fnsig.bound_vars().is_empty() { let generics_param_span = main_fn_generics_params_span(tcx, main_def_id); return Err(tcx.dcx().emit_err(diagnostics::MainFunctionGenericParameters { span: generics_param_span.unwrap_or(main_span), label_span: generics_param_span, })); - } else if !main_fn_predicates.predicates.is_empty() { - // generics may bring in implicit predicates, so we skip this check if generics is present. + } else if !main_fn_clauses.clauses.is_empty() { + // Generics may bring in implicit clauses, so we skip this check if generics are present. let generics_where_clauses_span = main_fn_where_clauses_span(tcx, main_def_id); return Err(tcx.dcx().emit_err(diagnostics::WhereClauseOnMain { span: generics_where_clauses_span.unwrap_or(main_span), diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index a3bdd0bae7e77..451db9fd64aca 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -324,19 +324,19 @@ fn default_body_is_unstable( err.emit(); } -/// Re-sugar `ty::GenericPredicates` in a way suitable to be used in structured suggestions. -fn bounds_from_generic_predicates<'tcx>( +/// Re-sugar `ty::GenericClauses` in a way suitable to be used in structured suggestions. +fn bounds_from_generic_clauses<'tcx>( tcx: TyCtxt<'tcx>, - predicates: impl IntoIterator, Span)>, + clauses: impl IntoIterator, Span)>, assoc: ty::AssocItem, ) -> (String, String) { let mut types: FxIndexMap, Vec> = FxIndexMap::default(); let mut regions: FxIndexMap, Vec>> = FxIndexMap::default(); let mut projections = vec![]; - for (predicate, _) in predicates { - debug!("predicate {:?}", predicate); - let bound_predicate = predicate.kind(); - match bound_predicate.skip_binder() { + for (clause, _) in clauses { + debug!("clause {:?}", clause); + let bound_clause = clause.kind(); + match bound_clause.skip_binder() { ty::ClauseKind::Trait(trait_predicate) => { let entry = types.entry(trait_predicate.self_ty()).or_default(); let def_id = trait_predicate.def_id(); @@ -346,7 +346,7 @@ fn bounds_from_generic_predicates<'tcx>( } } ty::ClauseKind::Projection(projection_pred) => { - projections.push(bound_predicate.rebind(projection_pred)); + projections.push(bound_clause.rebind(projection_pred)); } ty::ClauseKind::RegionOutlives(OutlivesPredicate(a, b)) => { regions.entry(a).or_default().push(b); @@ -442,7 +442,7 @@ fn fn_sig_suggestion<'tcx>( tcx: TyCtxt<'tcx>, sig: ty::FnSig<'tcx>, ident: Ident, - predicates: impl IntoIterator, Span)>, + clauses: impl IntoIterator, Span)>, assoc: ty::AssocItem, ) -> String { let splatted_arg_index = sig.splatted().map(usize::from); @@ -502,7 +502,7 @@ fn fn_sig_suggestion<'tcx>( let output = if !output.is_unit() { format!(" -> {output}") } else { String::new() }; let safety = sig.safety().prefix_str(); - let (generics, where_clauses) = bounds_from_generic_predicates(tcx, predicates, assoc); + let (generics, where_clauses) = bounds_from_generic_clauses(tcx, clauses, assoc); // FIXME: this is not entirely correct, as the lifetimes from borrowed params will // not be present in the `fn` definition, nor will we account for renamed @@ -535,15 +535,15 @@ fn suggestion_signature<'tcx>( tcx.fn_sig(assoc.def_id).instantiate(tcx, args).skip_norm_wip(), ), assoc.ident(tcx), - tcx.predicates_of(assoc.def_id) + tcx.clauses_of(assoc.def_id) .instantiate_own(tcx, args) .map(|(c, s)| (c.skip_norm_wip(), s)), assoc, ), ty::AssocKind::Type { .. } => { - let (generics, where_clauses) = bounds_from_generic_predicates( + let (generics, where_clauses) = bounds_from_generic_clauses( tcx, - tcx.predicates_of(assoc.def_id) + tcx.clauses_of(assoc.def_id) .instantiate_own(tcx, args) .map(|(c, s)| (c.skip_norm_wip(), s)), assoc, diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index fd2944a122f03..213e55860a76c 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -1405,7 +1405,7 @@ pub(super) fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, def_id: let infcx = wfcx.infcx; let tcx = wfcx.tcx(); - let predicates = tcx.predicates_of(def_id.to_def_id()); + let gen_clauses = tcx.clauses_of(def_id.to_def_id()); let generics = tcx.generics_of(def_id); // Check that concrete defaults are well-formed. See test `type-check-defaults.rs`. @@ -1472,10 +1472,10 @@ pub(super) fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, def_id: } } - // Check that trait predicates are WF when params are instantiated with their defaults. - // We don't want to overly constrain the predicates that may be written but we want to + // Check that trait clauses are WF when params are instantiated with their defaults. + // We don't want to overly constrain the clauses that may be written but we want to // catch cases where a default my never be applied such as `struct Foo`. - // Therefore we check if a predicate which contains a single type param + // Therefore we check if a clause which contains a single type param // with a concrete default is WF with that default instantiated. // For more examples see tests `defaults-well-formedness.rs` and `type-check-defaults.rs`. // @@ -1493,11 +1493,11 @@ pub(super) fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, def_id: tcx.mk_param_from_def(param) }); - // Now we build the instantiated predicates. - let default_obligations = predicates - .predicates + // Now we build the instantiated clauses. + let default_obligations = gen_clauses + .clauses .iter() - .flat_map(|&(pred, sp)| { + .flat_map(|&(clause, sp)| { #[derive(Default)] struct CountParams { params: FxHashSet, @@ -1523,52 +1523,52 @@ pub(super) fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, def_id: } } let mut param_count = CountParams::default(); - let has_region = pred.visit_with(&mut param_count).is_break(); - let instantiated_pred = ty::EarlyBinder::bind(tcx, pred).instantiate(tcx, args); + let has_region = clause.visit_with(&mut param_count).is_break(); + let instantiated_clause = ty::EarlyBinder::bind(tcx, clause).instantiate(tcx, args); // Don't check non-defaulted params, dependent defaults (including lifetimes) - // or preds with multiple params. - if instantiated_pred.skip_normalization().has_non_region_param() + // or clauses with multiple params. + if instantiated_clause.skip_normalization().has_non_region_param() || param_count.params.len() > 1 || has_region { None - } else if predicates - .predicates + } else if gen_clauses + .clauses .iter() - .any(|&(p, _)| Unnormalized::new_wip(p) == instantiated_pred) + .any(|&(p, _)| Unnormalized::new_wip(p) == instantiated_clause) { - // Avoid duplication of predicates that contain no parameters, for example. + // Avoid duplication of clauses that contain no parameters, for example. None } else { - Some((instantiated_pred, sp)) + Some((instantiated_clause, sp)) } }) - .map(|(pred, sp)| { + .map(|(clause, sp)| { // Convert each of those into an obligation. So if you have // something like `struct Foo`, we would - // take that predicate `T: Copy`, instantiated with `String: Copy` + // take that clause `T: Copy`, instantiated with `String: Copy` // (actually that happens in the previous `flat_map` call), // and then try to prove it (in this case, we'll fail). // - // Note the subtle difference from how we handle `predicates` - // below: there, we are not trying to prove those predicates + // Note the subtle difference from how we handle `gen_clauses` + // below: there, we are not trying to prove those clauses // to be *true* but merely *well-formed*. - let pred = wfcx.normalize(sp, None, pred); + let clause = wfcx.normalize(sp, None, clause); let cause = traits::ObligationCause::new( sp, wfcx.body_def_id, ObligationCauseCode::WhereClause(def_id.to_def_id(), sp), ); - Obligation::new(tcx, cause, wfcx.param_env, pred) + Obligation::new(tcx, cause, wfcx.param_env, clause) }); - let predicates = predicates.instantiate_identity(tcx); + let gen_clauses = gen_clauses.instantiate_identity(tcx); - let assoc_const_obligations: Vec<_> = predicates - .predicates + let assoc_const_obligations: Vec<_> = gen_clauses + .clauses .iter() .copied() - .zip(predicates.spans.iter().copied()) + .zip(gen_clauses.spans.iter().copied()) .filter_map(|(clause, sp)| { let clause = clause.skip_norm_wip(); let proj = clause.as_projection_clause()?; @@ -1592,8 +1592,8 @@ pub(super) fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, def_id: }) .collect(); - assert_eq!(predicates.predicates.len(), predicates.spans.len()); - let wf_obligations = predicates.into_iter().flat_map(|(p, sp)| { + assert_eq!(gen_clauses.clauses.len(), gen_clauses.spans.len()); + let wf_obligations = gen_clauses.into_iter().flat_map(|(p, sp)| { traits::wf::clause_obligations( infcx, wfcx.param_env, @@ -1996,8 +1996,8 @@ pub(super) fn check_variances_for_type_defn<'tcx>(tcx: TyCtxt<'tcx>, def_id: Loc kind => span_bug!(tcx.def_span(def_id), "cannot compute the variances of {kind:?}"), } - let ty_predicates = tcx.predicates_of(def_id); - assert_eq!(ty_predicates.parent, None); + let ty_clauses = tcx.clauses_of(def_id); + assert_eq!(ty_clauses.parent, None); let variances = tcx.variances_of(def_id); let mut constrained_parameters: FxHashSet<_> = variances @@ -2007,7 +2007,7 @@ pub(super) fn check_variances_for_type_defn<'tcx>(tcx: TyCtxt<'tcx>, def_id: Loc .map(|(index, _)| Parameter(index as u32)) .collect(); - identify_constrained_generic_params(tcx, ty_predicates, None, &mut constrained_parameters); + identify_constrained_generic_params(tcx, ty_clauses, None, &mut constrained_parameters); // Lazily calculated because it is only needed in case of an error. let explicitly_bounded_params = LazyCell::new(|| { @@ -2287,12 +2287,12 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { let mut span = tcx.def_span(self.body_def_id); let empty_env = ty::ParamEnv::empty(); - let predicates_with_span = tcx.predicates_of(self.body_def_id).predicates.iter().copied(); + let clauses_with_span = tcx.clauses_of(self.body_def_id).clauses.iter().copied(); // Check elaborated bounds. - let implied_obligations = traits::elaborate(tcx, predicates_with_span); + let implied_obligations = traits::elaborate(tcx, clauses_with_span); - for (pred, obligation_span) in implied_obligations { - match pred.kind().skip_binder() { + for (clause, obligation_span) in implied_obligations { + match clause.kind().skip_binder() { // We lower empty bounds like `Vec:` as // `WellFormed(Vec)`, which will later get checked by // regular WF checking @@ -2303,8 +2303,8 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { } // Match the existing behavior. - if pred.is_global() && !pred.has_type_flags(TypeFlags::HAS_BINDER_VARS) { - let pred = self.normalize(span, None, Unnormalized::new_wip(pred)); + if clause.is_global() && !clause.has_type_flags(TypeFlags::HAS_BINDER_VARS) { + let clause = self.normalize(span, None, Unnormalized::new_wip(clause)); // only use the span of the predicate clause (#90869) let hir_node = tcx.hir_node_by_def_id(self.body_def_id); @@ -2325,7 +2325,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { ObligationCauseCode::TrivialBound, ), empty_env, - pred, + clause, ); self.ocx.register_obligation(obligation); } diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index 6c393ed3dfc6b..bf17952313479 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -8,7 +8,7 @@ //! //! Collecting is ultimately defined by a bundle of queries that //! inquire after various facts about the items in the crate (e.g., -//! `type_of`, `generics_of`, `predicates_of`, etc). See the `provide` function +//! `type_of`, `generics_of`, `clauses_of`, etc). See the `provide` function //! for the full set. //! //! At present, however, we do run collection across all items in the @@ -47,10 +47,10 @@ use tracing::{debug, instrument}; use crate::diagnostics::{self, ElidedLifetimesAreNotAllowedInDelegations}; use crate::hir_ty_lowering::{HirTyLowerer, InherentAssocCandidate, RegionInferReason}; +mod clauses_of; pub(crate) mod dump; mod generics_of; mod item_bounds; -mod predicates_of; mod resolve_bound_vars; mod type_of; @@ -71,16 +71,16 @@ pub(crate) fn provide(providers: &mut Providers) { item_non_self_bounds: item_bounds::item_non_self_bounds, impl_super_outlives: item_bounds::impl_super_outlives, generics_of: generics_of::generics_of, - predicates_of: predicates_of::predicates_of, - explicit_predicates_of: predicates_of::explicit_predicates_of, - explicit_super_predicates_of: predicates_of::explicit_super_predicates_of, - explicit_implied_predicates_of: predicates_of::explicit_implied_predicates_of, + clauses_of: clauses_of::clauses_of, + explicit_clauses_of: clauses_of::explicit_clauses_of, + explicit_super_clauses_of: clauses_of::explicit_super_clauses_of, + explicit_implied_clauses_of: clauses_of::explicit_implied_clauses_of, explicit_supertraits_containing_assoc_item: - predicates_of::explicit_supertraits_containing_assoc_item, - trait_explicit_predicates_and_bounds: predicates_of::trait_explicit_predicates_and_bounds, - const_conditions: predicates_of::const_conditions, - explicit_implied_const_bounds: predicates_of::explicit_implied_const_bounds, - type_param_predicates: predicates_of::type_param_predicates, + clauses_of::explicit_supertraits_containing_assoc_item, + trait_explicit_clauses_and_bounds: clauses_of::trait_explicit_clauses_and_bounds, + const_conditions: clauses_of::const_conditions, + explicit_implied_const_bounds: clauses_of::explicit_implied_const_bounds, + type_param_clauses: clauses_of::type_param_clauses, trait_def, adt_def, fn_sig, @@ -391,7 +391,7 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> { def_id: LocalDefId, assoc_ident: Ident, ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { - self.tcx.at(span).type_param_predicates((self.item_def_id, def_id, assoc_ident)) + self.tcx.at(span).type_param_clauses((self.item_def_id, def_id, assoc_ident)) } #[instrument(level = "debug", skip(self, _span), ret)] @@ -634,7 +634,7 @@ fn get_new_lifetime_name<'tcx>( pub(super) fn check_ctor(tcx: TyCtxt<'_>, def_id: LocalDefId) { tcx.ensure_ok().generics_of(def_id); tcx.ensure_ok().type_of(def_id); - tcx.ensure_ok().predicates_of(def_id); + tcx.ensure_ok().clauses_of(def_id); } pub(super) fn check_enum_variant_types(tcx: TyCtxt<'_>, def_id: LocalDefId) { @@ -714,7 +714,7 @@ pub(super) fn check_enum_variant_types(tcx: TyCtxt<'_>, def_id: LocalDefId) { for f in &variant.fields { tcx.ensure_ok().generics_of(f.did); tcx.ensure_ok().type_of(f.did); - tcx.ensure_ok().predicates_of(f.did); + tcx.ensure_ok().clauses_of(f.did); } // Lower the ctor, if any. This also registers the variant as an item. @@ -1395,7 +1395,7 @@ pub fn suggest_impl_trait<'tcx>( fn impl_is_fully_generic_for_reflection(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { tcx.impl_trait_header(def_id).is_fully_generic_for_reflection() - && tcx.explicit_predicates_of(def_id).is_fully_generic_for_reflection() + && tcx.explicit_clauses_of(def_id).is_fully_generic_for_reflection() } fn impl_trait_header(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::ImplTraitHeader<'_> { diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/clauses_of.rs similarity index 83% rename from compiler/rustc_hir_analysis/src/collect/predicates_of.rs rename to compiler/rustc_hir_analysis/src/collect/clauses_of.rs index 46f90ad160cac..3c91caf3d7eed 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/clauses_of.rs @@ -7,8 +7,8 @@ use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::find_attr; use rustc_middle::ty::{ - self, GenericPredicates, ImplTraitInTraitData, RegionExt, Ty, TyCtxt, TypeVisitable, - TypeVisitor, Upcast, + self, GenericClauses, ImplTraitInTraitData, RegionExt, Ty, TyCtxt, TypeVisitable, TypeVisitor, + Upcast, }; use rustc_middle::{bug, span_bug}; use rustc_span::{DUMMY_SP, Ident, Span}; @@ -17,46 +17,46 @@ use tracing::{debug, instrument, trace}; use super::item_bounds::explicit_item_bounds_with_filter; use crate::collect::ItemCtxt; use crate::constrained_generic_params as cgp; -use crate::delegation::inherit_predicates_for_delegation_item; +use crate::delegation::inherit_clauses_for_delegation_item; use crate::hir_ty_lowering::{ HirTyLowerer, ImpliedBoundsContext, OverlappingAsssocItemConstraints, PredicateFilter, RegionInferReason, }; -/// Returns a list of all type predicates (explicit and implicit) for the definition with -/// ID `def_id`. This includes all predicates returned by `explicit_predicates_of`, plus +/// Returns a list of all type clauses (explicit and implicit) for the definition with +/// ID `def_id`. This includes all clauses returned by `explicit_clauses_of`, plus /// inferred constraints concerning which regions outlive other regions. #[instrument(level = "debug", skip(tcx))] -pub(super) fn predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicates<'_> { - let mut result = tcx.explicit_predicates_of(def_id); - debug!("predicates_of: explicit_predicates_of({:?}) = {:?}", def_id, result); +pub(super) fn clauses_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericClauses<'_> { + let mut result = tcx.explicit_clauses_of(def_id); + debug!("clauses_of: explicit_clauses_of({:?}) = {:?}", def_id, result); let inferred_outlives = tcx.inferred_outlives_of(def_id); if !inferred_outlives.is_empty() { - debug!("predicates_of: inferred_outlives_of({:?}) = {:?}", def_id, inferred_outlives,); + debug!("clauses_of: inferred_outlives_of({:?}) = {:?}", def_id, inferred_outlives,); let inferred_outlives_iter = inferred_outlives.iter().map(|(clause, span)| ((*clause).upcast(tcx), *span)); - if result.predicates.is_empty() { - result.predicates = tcx.arena.alloc_from_iter(inferred_outlives_iter); + if result.clauses.is_empty() { + result.clauses = tcx.arena.alloc_from_iter(inferred_outlives_iter); } else { - result.predicates = tcx.arena.alloc_from_iter( - result.predicates.into_iter().copied().chain(inferred_outlives_iter), - ); + result.clauses = tcx + .arena + .alloc_from_iter(result.clauses.into_iter().copied().chain(inferred_outlives_iter)); } } if tcx.is_trait(def_id) { - // For traits, add `Self: Trait` predicate. This is - // not part of the predicates that a user writes, but it + // For traits, add `Self: Trait` clause. This is + // not part of the clauses that a user writes, but it // is something that one must prove in order to invoke a // method or project an associated type. // - // In the chalk setup, this predicate is not part of the - // "predicates" for a trait item. But it is useful in + // In the chalk setup, this clause is not part of the + // "clauses" for a trait item. But it is useful in // rustc because if you directly (e.g.) invoke a trait // method like `Trait::method(...)`, you must naturally // prove that the trait applies to the types that were - // used, and adding the predicate into this list ensures + // used, and adding the clause into this list ensures // that this is done. // // We use a DUMMY_SP here as a way to signal trait bounds that come @@ -65,60 +65,60 @@ pub(super) fn predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredic // `tcx.def_span(def_id);` let span = DUMMY_SP; - result.predicates = tcx.arena.alloc_from_iter( + result.clauses = tcx.arena.alloc_from_iter( result - .predicates + .clauses .iter() .copied() .chain(std::iter::once((ty::TraitRef::identity(tcx, def_id).upcast(tcx), span))), ); } - debug!("predicates_of({:?}) = {:?}", def_id, result); + debug!("clauses_of({:?}) = {:?}", def_id, result); result } -/// Returns a list of user-specified type predicates for the definition with ID `def_id`. +/// Returns a list of user-specified type clauses for the definition with ID `def_id`. /// N.B., this does not include any implied/inferred constraints. #[instrument(level = "trace", skip(tcx), ret)] -fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::GenericPredicates<'_> { +fn gather_explicit_clauses_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::GenericClauses<'_> { use rustc_hir::*; match tcx.opt_rpitit_info(def_id.to_def_id()) { Some(ImplTraitInTraitData::Trait { fn_def_id, .. }) => { - let mut predicates = Vec::new(); + let mut clauses = Vec::new(); - // RPITITs should inherit the predicates of their parent. This is + // RPITITs should inherit the clauses of their parent. This is // both to ensure that the RPITITs are only instantiated when the - // parent predicates would hold, and also so that the param-env - // inherits these predicates as assumptions. + // parent clauses would hold, and also so that the param-env + // inherits these clauses as assumptions. let identity_args = ty::GenericArgs::identity_for_item(tcx, def_id); - predicates.extend( - tcx.explicit_predicates_of(fn_def_id) + clauses.extend( + tcx.explicit_clauses_of(fn_def_id) .instantiate_own(tcx, identity_args) .map(|(c, s)| (c.skip_norm_wip(), s)), ); - // We also install bidirectional outlives predicates for the RPITIT + // We also install bidirectional outlives clauses for the RPITIT // to keep the duplicates lifetimes from opaque lowering in sync. // We only need to compute bidirectional outlives for the duplicated // opaque lifetimes, which explains the slicing below. - compute_bidirectional_outlives_predicates( + compute_bidirectional_outlives_clauses( tcx, &tcx.generics_of(def_id.to_def_id()).own_params [tcx.generics_of(fn_def_id).own_params.len()..], - &mut predicates, + &mut clauses, ); - return ty::GenericPredicates { + return ty::GenericClauses { parent: Some(tcx.local_parent(def_id).to_def_id()), - predicates: tcx.arena.alloc_from_iter(predicates), + clauses: tcx.arena.alloc_from_iter(clauses), }; } Some(ImplTraitInTraitData::Impl { fn_def_id }) => { let trait_item_def_id = tcx.trait_item_of(def_id).unwrap(); - let trait_assoc_predicates = tcx.explicit_predicates_of(trait_item_def_id); + let trait_assoc_clauses = tcx.explicit_clauses_of(trait_item_def_id); let impl_assoc_identity_args = ty::GenericArgs::identity_for_item(tcx, def_id); let impl_def_id = tcx.parent(fn_def_id); @@ -128,13 +128,13 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen let impl_assoc_args = impl_assoc_identity_args.rebase_onto(tcx, impl_def_id, impl_trait_ref_args); - let impl_predicates = trait_assoc_predicates + let impl_clauses = trait_assoc_clauses .instantiate_own(tcx, impl_assoc_args) .map(|(c, s)| (c.skip_norm_wip(), s)); - return ty::GenericPredicates { + return ty::GenericClauses { parent: Some(impl_def_id), - predicates: tcx.arena.alloc_from_iter(impl_predicates), + clauses: tcx.arena.alloc_from_iter(impl_clauses), }; } @@ -147,7 +147,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen if let Some(sig) = node.fn_sig() && let Some(sig_id) = sig.decl.opt_delegation_sig_id() { - return inherit_predicates_for_delegation_item(tcx, def_id, sig_id); + return inherit_clauses_for_delegation_item(tcx, def_id, sig_id); } let mut is_trait = None; @@ -159,7 +159,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen // We use an `IndexSet` to preserve order of insertion. // Preserving the order of insertion is important here so as not to break UI tests. - let mut predicates: FxIndexSet<(ty::Clause<'_>, Span)> = FxIndexSet::default(); + let mut clauses: FxIndexSet<(ty::Clause<'_>, Span)> = FxIndexSet::default(); let hir_generics = node.generics().unwrap_or(NO_GENERICS); if let Node::Item(item) = node { @@ -184,7 +184,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen let generics = tcx.generics_of(def_id); // Below we'll consider the bounds on the type parameters (including `Self`) - // and the explicit where-clauses, but to get the full set of predicates + // and the explicit where-clauses, but to get the full set of clauses // on a trait we must also consider the bounds that follow the trait's name, // like `trait Foo: A + B + C`. if let Some((self_bounds, span)) = is_trait { @@ -211,7 +211,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen ImpliedBoundsContext::TraitDef(def_id), span, ); - predicates.extend(bounds); + clauses.extend(bounds); } // In default impls, we can assume that the self type implements @@ -223,10 +223,10 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen // (see below). Recall that a default impl is not itself an impl, but rather a // set of defaults that can be incorporated into another impl. if let Some(trait_ref) = is_default_impl_trait { - predicates.insert((trait_ref.upcast(tcx), tcx.def_span(def_id))); + clauses.insert((trait_ref.upcast(tcx), tcx.def_span(def_id))); } - // Add implicit predicates that should be treated as if the user has written them, + // Add implicit clauses that should be treated as if the user has written them, // including the implicit `T: Sized` for all generic parameters, and `ConstArgHasType` // for const params. for param in hir_generics.params { @@ -251,20 +251,20 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen param.span, ); trace!(?bounds); - predicates.extend(bounds); - trace!(?predicates); + clauses.extend(bounds); + trace!(?clauses); } hir::GenericParamKind::Const { .. } => { let param_def_id = param.def_id.to_def_id(); let ct_ty = tcx.type_of(param_def_id).instantiate_identity().skip_norm_wip(); let ct = icx.lowerer().lower_const_param(param_def_id, param.hir_id); - predicates + clauses .insert((ty::ClauseKind::ConstArgHasType(ct, ct_ty).upcast(tcx), param.span)); } } } - trace!(?predicates); + trace!(?clauses); // Add inline `` bounds and bounds in the where clause. for predicate in hir_generics.predicates { match predicate.kind { @@ -281,11 +281,11 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen // noop (see #53696) and `Ty` is still checked for WF. let span = bound_pred.bounded_ty.span; - let predicate = ty::Binder::bind_with_vars( + let clause = ty::Binder::bind_with_vars( ty::ClauseKind::WellFormed(ty.into()), bound_vars, ); - predicates.insert((predicate.upcast(tcx), span)); + clauses.insert((clause.upcast(tcx), span)); } } @@ -298,14 +298,14 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen PredicateFilter::All, OverlappingAsssocItemConstraints::Allowed, ); - predicates.extend(bounds); + clauses.extend(bounds); } hir::WherePredicateKind::RegionPredicate(region_pred) => { let r1 = icx .lowerer() .lower_lifetime(region_pred.lifetime, RegionInferReason::RegionPredicate); - predicates.extend(region_pred.bounds.iter().map(|bound| { + clauses.extend(region_pred.bounds.iter().map(|bound| { let (r2, span) = match bound { hir::GenericBound::Outlives(lt) => ( icx.lowerer().lower_lifetime(lt, RegionInferReason::RegionPredicate), @@ -318,16 +318,16 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen ) } }; - let pred = + let clause = ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(r1, r2)).upcast(tcx); - (pred, span) + (clause, span) })) } } } if tcx.features().generic_const_exprs() { - predicates.extend(const_evaluatable_predicates_of(tcx, def_id, &predicates)); + clauses.extend(const_evaluatable_clauses_of(tcx, def_id, &clauses)); } let attrs = tcx.hir_attrs(tcx.local_def_id_to_hir_id(def_id)); @@ -338,15 +338,15 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen find_attr!(attrs, UnstableFeatureBound(i) => i).map(|i| i.as_slice()).unwrap_or_default(); for (feat_name, span) in allow_unstable_feature_attr { - predicates.insert((ty::ClauseKind::UnstableFeature(*feat_name).upcast(tcx), *span)); + clauses.insert((ty::ClauseKind::UnstableFeature(*feat_name).upcast(tcx), *span)); } - let mut predicates: Vec<_> = predicates.into_iter().collect(); + let mut clauses: Vec<_> = clauses.into_iter().collect(); - // Subtle: before we store the predicates into the tcx, we - // sort them so that predicates like `T: Foo` come + // Subtle: before we store the clauses into the tcx, we + // sort them so that clauses like `T: Foo` come // before uses of `U`. This avoids false ambiguity errors - // in trait checking. See `setup_constraining_predicates` + // in trait checking. See `setup_constraining_clauses` // for details. if let Node::Item(&Item { kind: ItemKind::Impl(impl_), .. }) = node { let self_ty = tcx.type_of(def_id).instantiate_identity().skip_norm_wip(); @@ -354,34 +354,31 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen .of_trait .is_some() .then(|| tcx.impl_trait_ref(def_id).instantiate_identity().skip_norm_wip()); - cgp::setup_constraining_predicates( + cgp::setup_constraining_clauses( tcx, - &mut predicates, + &mut clauses, trait_ref, &mut cgp::parameters_for_impl(tcx, self_ty, trait_ref), ); } // Opaque types duplicate some of their generic parameters. - // We create bi-directional Outlives predicates between the original + // We create bi-directional Outlives clauses between the original // and the duplicated parameter, to ensure that they do not get out of sync. if let Node::OpaqueTy(..) = node { - compute_bidirectional_outlives_predicates(tcx, &generics.own_params, &mut predicates); - debug!(?predicates); + compute_bidirectional_outlives_clauses(tcx, &generics.own_params, &mut clauses); + debug!(?clauses); } - ty::GenericPredicates { - parent: generics.parent, - predicates: tcx.arena.alloc_from_iter(predicates), - } + ty::GenericClauses { parent: generics.parent, clauses: tcx.arena.alloc_from_iter(clauses) } } -/// Opaques have duplicated lifetimes and we need to compute bidirectional outlives predicates to +/// Opaques have duplicated lifetimes and we need to compute bidirectional outlives clauses to /// enforce that these lifetimes stay in sync. -fn compute_bidirectional_outlives_predicates<'tcx>( +fn compute_bidirectional_outlives_clauses<'tcx>( tcx: TyCtxt<'tcx>, opaque_own_params: &[ty::GenericParamDef], - predicates: &mut Vec<(ty::Clause<'tcx>, Span)>, + clauses: &mut Vec<(ty::Clause<'tcx>, Span)>, ) { for param in opaque_own_params { let orig_lifetime = tcx.map_opaque_lifetime_to_parent_lifetime(param.def_id.expect_local()); @@ -391,12 +388,12 @@ fn compute_bidirectional_outlives_predicates<'tcx>( ty::EarlyParamRegion { index: param.index, name: param.name }, ); let span = tcx.def_span(param.def_id); - predicates.push(( + clauses.push(( ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(orig_lifetime, dup_lifetime)) .upcast(tcx), span, )); - predicates.push(( + clauses.push(( ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(dup_lifetime, orig_lifetime)) .upcast(tcx), span, @@ -405,15 +402,15 @@ fn compute_bidirectional_outlives_predicates<'tcx>( } } -#[instrument(level = "debug", skip(tcx, predicates), ret)] -fn const_evaluatable_predicates_of<'tcx>( +#[instrument(level = "debug", skip(tcx, clauses), ret)] +fn const_evaluatable_clauses_of<'tcx>( tcx: TyCtxt<'tcx>, def_id: LocalDefId, - predicates: &FxIndexSet<(ty::Clause<'tcx>, Span)>, + clauses: &FxIndexSet<(ty::Clause<'tcx>, Span)>, ) -> FxIndexSet<(ty::Clause<'tcx>, Span)> { struct ConstCollector<'tcx> { tcx: TyCtxt<'tcx>, - preds: FxIndexSet<(ty::Clause<'tcx>, Span)>, + clauses: FxIndexSet<(ty::Clause<'tcx>, Span)>, } fn is_const_param_default(tcx: TyCtxt<'_>, kind: ty::AliasConstKind<'_>) -> bool { @@ -452,7 +449,7 @@ fn const_evaluatable_predicates_of<'tcx>( } let span = alias_const.kind.def_span(self.tcx); - self.preds.insert((ty::ClauseKind::ConstEvaluatable(c).upcast(self.tcx), span)); + self.clauses.insert((ty::ClauseKind::ConstEvaluatable(c).upcast(self.tcx), span)); } } } @@ -460,9 +457,9 @@ fn const_evaluatable_predicates_of<'tcx>( let hir_id = tcx.local_def_id_to_hir_id(def_id); let node = tcx.hir_node(hir_id); - let mut collector = ConstCollector { tcx, preds: FxIndexSet::default() }; + let mut collector = ConstCollector { tcx, clauses: FxIndexSet::default() }; - for (clause, _sp) in predicates { + for (clause, _sp) in clauses { clause.visit_with(&mut collector); } @@ -488,26 +485,26 @@ fn const_evaluatable_predicates_of<'tcx>( fn_sig.visit_with(&mut collector); } - collector.preds + collector.clauses } -pub(super) fn trait_explicit_predicates_and_bounds( +pub(super) fn trait_explicit_clauses_and_bounds( tcx: TyCtxt<'_>, def_id: LocalDefId, -) -> ty::GenericPredicates<'_> { +) -> ty::GenericClauses<'_> { assert_eq!(tcx.def_kind(def_id), DefKind::Trait); - gather_explicit_predicates_of(tcx, def_id) + gather_explicit_clauses_of(tcx, def_id) } -pub(super) fn explicit_predicates_of<'tcx>( +pub(super) fn explicit_clauses_of<'tcx>( tcx: TyCtxt<'tcx>, def_id: LocalDefId, -) -> ty::GenericPredicates<'tcx> { +) -> ty::GenericClauses<'tcx> { let def_kind = tcx.def_kind(def_id); if let DefKind::Trait = def_kind { - // Remove bounds on associated types from the predicates, they will be + // Remove bounds on associated types from the clauses, they will be // returned by `explicit_item_bounds`. - let predicates_and_bounds = tcx.trait_explicit_predicates_and_bounds(def_id); + let clauses_and_bounds = tcx.trait_explicit_clauses_and_bounds(def_id); let trait_identity_args = ty::GenericArgs::identity_for_item(tcx, def_id); let is_assoc_item_ty = |ty: Ty<'tcx>| { @@ -534,11 +531,11 @@ pub(super) fn explicit_predicates_of<'tcx>( } }; - let predicates: Vec<_> = predicates_and_bounds - .predicates + let clauses: Vec<_> = clauses_and_bounds + .clauses .iter() .copied() - .filter(|(pred, _)| match pred.kind().skip_binder() { + .filter(|(clause, _)| match clause.kind().skip_binder() { ty::ClauseKind::Trait(tr) => !is_assoc_item_ty(tr.self_ty()), ty::ClauseKind::Projection(proj) => { !is_assoc_item_ty(proj.projection_term.self_ty()) @@ -547,12 +544,12 @@ pub(super) fn explicit_predicates_of<'tcx>( _ => true, }) .collect(); - if predicates.len() == predicates_and_bounds.predicates.len() { - predicates_and_bounds + if clauses.len() == clauses_and_bounds.clauses.len() { + clauses_and_bounds } else { - ty::GenericPredicates { - parent: predicates_and_bounds.parent, - predicates: tcx.arena.alloc_slice(&predicates), + ty::GenericClauses { + parent: clauses_and_bounds.parent, + clauses: tcx.arena.alloc_slice(&clauses), } } } else { @@ -562,28 +559,28 @@ pub(super) fn explicit_predicates_of<'tcx>( tcx.hir_opt_const_param_default_param_def_id(tcx.local_def_id_to_hir_id(def_id)) { // In `generics_of` we set the generics' parent to be our parent's parent which means that - // we lose out on the predicates of our actual parent if we dont return those predicates here. + // we lose out on the clauses of our actual parent if we dont return those clauses here. // (See comment in `generics_of` for more information on why the parent shenanigans is necessary) // // struct Foo::ASSOC }>(T) where T: Trait; // ^^^ ^^^^^^^^^^^^^^^^^^^^^^^ the def id we are calling - // ^^^ explicit_predicates_of on + // ^^^ explicit_clauses_of on // parent item we dont have set as the // parent of generics returned by `generics_of` // - // In the above code we want the anon const to have predicates in its param env for `T: Trait` - // and we would be calling `explicit_predicates_of(Foo)` here + // In the above code we want the anon const to have clauses in its param env for `T: Trait` + // and we would be calling `explicit_clauses_of(Foo)` here let parent_def_id = tcx.local_parent(def_id); - let parent_preds = tcx.explicit_predicates_of(parent_def_id); + let parent_clauses = tcx.explicit_clauses_of(parent_def_id); - // If we dont filter out `ConstArgHasType` predicates then every single defaulted const parameter + // If we dont filter out `ConstArgHasType` clauses then every single defaulted const parameter // will ICE because of #106994. FIXME(generic_const_exprs): remove this when a more general solution // to #106994 is implemented. - let filtered_predicates = parent_preds - .predicates + let filtered_clauses = parent_clauses + .clauses .into_iter() - .filter(|(pred, _)| { - if let ty::ClauseKind::ConstArgHasType(ct, _) = pred.kind().skip_binder() { + .filter(|(clause, _)| { + if let ty::ClauseKind::ConstArgHasType(ct, _) = clause.kind().skip_binder() { match ct.kind() { ty::ConstKind::Param(param_const) => { let defaulted_param_idx = tcx @@ -591,51 +588,50 @@ pub(super) fn explicit_predicates_of<'tcx>( .param_def_id_to_index[&defaulted_param_def_id.to_def_id()]; param_const.index < defaulted_param_idx } - _ => bug!( - "`ConstArgHasType` in `predicates_of`\ - that isn't a `Param` const" - ), + _ => { + bug!("`ConstArgHasType` in `clauses_of` that isn't a `Param` const") + } } } else { true } }) .cloned(); - return GenericPredicates { - parent: parent_preds.parent, - predicates: { tcx.arena.alloc_from_iter(filtered_predicates) }, + return GenericClauses { + parent: parent_clauses.parent, + clauses: { tcx.arena.alloc_from_iter(filtered_clauses) }, }; } - gather_explicit_predicates_of(tcx, def_id) + gather_explicit_clauses_of(tcx, def_id) } } -/// Ensures that the super-predicates of the trait with a `DefId` +/// Ensures that the super-clauses of the trait with a `DefId` /// of `trait_def_id` are lowered and stored. This also ensures that -/// the transitive super-predicates are lowered. -pub(super) fn explicit_super_predicates_of<'tcx>( +/// the transitive super-clauses are lowered. +pub(super) fn explicit_super_clauses_of<'tcx>( tcx: TyCtxt<'tcx>, trait_def_id: LocalDefId, ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { - implied_predicates_with_filter(tcx, trait_def_id.to_def_id(), PredicateFilter::SelfOnly) + implied_clauses_with_filter(tcx, trait_def_id.to_def_id(), PredicateFilter::SelfOnly) } pub(super) fn explicit_supertraits_containing_assoc_item<'tcx>( tcx: TyCtxt<'tcx>, (trait_def_id, assoc_ident): (DefId, Ident), ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { - implied_predicates_with_filter( + implied_clauses_with_filter( tcx, trait_def_id, PredicateFilter::SelfTraitThatDefines(assoc_ident), ) } -pub(super) fn explicit_implied_predicates_of<'tcx>( +pub(super) fn explicit_implied_clauses_of<'tcx>( tcx: TyCtxt<'tcx>, trait_def_id: LocalDefId, ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { - implied_predicates_with_filter( + implied_clauses_with_filter( tcx, trait_def_id.to_def_id(), if tcx.is_trait_alias(trait_def_id.to_def_id()) { @@ -646,10 +642,10 @@ pub(super) fn explicit_implied_predicates_of<'tcx>( ) } -/// Ensures that the super-predicates of the trait with a `DefId` +/// Ensures that the super-clauses of the trait with a `DefId` /// of `trait_def_id` are lowered and stored. This also ensures that -/// the transitive super-predicates are lowered. -pub(super) fn implied_predicates_with_filter<'tcx>( +/// the transitive super-clauses are lowered. +pub(super) fn implied_clauses_with_filter<'tcx>( tcx: TyCtxt<'tcx>, trait_def_id: DefId, filter: PredicateFilter, @@ -658,7 +654,7 @@ pub(super) fn implied_predicates_with_filter<'tcx>( // if `assoc_ident` is None, then the query should've been redirected to an // external provider assert_matches!(filter, PredicateFilter::SelfTraitThatDefines(_)); - return tcx.explicit_super_predicates_of(trait_def_id); + return tcx.explicit_super_clauses_of(trait_def_id); }; let Node::Item(item) = tcx.hir_node_by_def_id(trait_def_id) else { @@ -668,7 +664,7 @@ pub(super) fn implied_predicates_with_filter<'tcx>( let (generics, superbounds) = match item.kind { hir::ItemKind::Trait { generics, bounds: supertraits, .. } => (generics, supertraits), hir::ItemKind::TraitAlias(_, _, generics, supertraits) => (generics, supertraits), - _ => span_bug!(item.span, "super_predicates invoked on non-trait"), + _ => span_bug!(item.span, "super_clauses invoked on non-trait"), }; let icx = ItemCtxt::new(tcx, trait_def_id); @@ -721,29 +717,29 @@ pub(super) fn implied_predicates_with_filter<'tcx>( // make sure we walk into associated type bounds. match filter { PredicateFilter::SelfOnly => { - for &(pred, span) in implied_bounds { - debug!("superbound: {:?}", pred); - if let ty::ClauseKind::Trait(bound) = pred.kind().skip_binder() + for &(clause, span) in implied_bounds { + debug!("superbound: {:?}", clause); + if let ty::ClauseKind::Trait(bound) = clause.kind().skip_binder() && bound.polarity == ty::PredicatePolarity::Positive { - tcx.at(span).explicit_super_predicates_of(bound.def_id()); + tcx.at(span).explicit_super_clauses_of(bound.def_id()); } } } PredicateFilter::All | PredicateFilter::SelfAndAssociatedTypeBounds => { - for &(pred, span) in implied_bounds { - debug!("superbound: {:?}", pred); - if let ty::ClauseKind::Trait(bound) = pred.kind().skip_binder() + for &(clause, span) in implied_bounds { + debug!("superbound: {:?}", clause); + if let ty::ClauseKind::Trait(bound) = clause.kind().skip_binder() && bound.polarity == ty::PredicatePolarity::Positive { - tcx.at(span).explicit_implied_predicates_of(bound.def_id()); + tcx.at(span).explicit_implied_clauses_of(bound.def_id()); } } } _ => {} } - assert_only_contains_predicates_from(filter, implied_bounds, tcx.types.self_param); + assert_only_contains_clauses_from(filter, implied_bounds, tcx.types.self_param); ty::EarlyBinder::bind_iter(implied_bounds) } @@ -751,7 +747,7 @@ pub(super) fn implied_predicates_with_filter<'tcx>( // Make sure when elaborating supertraits, probing for associated types, etc., // we really truly are elaborating clauses that have `ty` as their self type. // This is very important since downstream code relies on this being correct. -pub(super) fn assert_only_contains_predicates_from<'tcx>( +pub(super) fn assert_only_contains_clauses_from<'tcx>( filter: PredicateFilter, bounds: &'tcx [(ty::Clause<'tcx>, Span)], ty: Ty<'tcx>, @@ -883,16 +879,16 @@ pub(super) fn assert_only_contains_predicates_from<'tcx>( } } -/// Returns the predicates defined on `item_def_id` of the form +/// Returns the clauses defined on `item_def_id` of the form /// `X: Foo` where `X` is the type parameter `def_id`. #[instrument(level = "trace", skip(tcx))] -pub(super) fn type_param_predicates<'tcx>( +pub(super) fn type_param_clauses<'tcx>( tcx: TyCtxt<'tcx>, (item_def_id, def_id, assoc_ident): (LocalDefId, LocalDefId, Ident), ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { match tcx.opt_rpitit_info(item_def_id.to_def_id()) { Some(ty::ImplTraitInTraitData::Trait { opaque_def_id, .. }) => { - return tcx.type_param_predicates((opaque_def_id.expect_local(), def_id, assoc_ident)); + return tcx.type_param_clauses((opaque_def_id.expect_local(), def_id, assoc_ident)); } Some(ty::ImplTraitInTraitData::Impl { .. }) => { unreachable!("should not be lowering bounds on RPITIT in impl") @@ -940,16 +936,16 @@ pub(super) fn type_param_predicates<'tcx>( } let icx = ItemCtxt::new(tcx, item_def_id); - let extra_predicates = extend.into_iter().chain(icx.probe_ty_param_bounds_in_generics( + let extra_clauses = extend.into_iter().chain(icx.probe_ty_param_bounds_in_generics( hir_generics, def_id, PredicateFilter::SelfTraitThatDefines(assoc_ident), )); let bounds = - &*tcx.arena.alloc_from_iter(result.skip_binder().iter().copied().chain(extra_predicates)); + &*tcx.arena.alloc_from_iter(result.skip_binder().iter().copied().chain(extra_clauses)); - // Double check that the bounds *only* contain `SelfTy: Trait` preds. + // Double check that the bounds *only* contain `SelfTy: Trait` clauses. let self_ty = match tcx.def_kind(def_id) { DefKind::TyParam => Ty::new_param( tcx, @@ -961,7 +957,7 @@ pub(super) fn type_param_predicates<'tcx>( DefKind::Trait | DefKind::TraitAlias => tcx.types.self_param, _ => unreachable!(), }; - assert_only_contains_predicates_from( + assert_only_contains_clauses_from( PredicateFilter::SelfTraitThatDefines(assoc_ident), bounds, self_ty, @@ -1193,7 +1189,7 @@ pub(super) fn explicit_implied_const_bounds<'tcx>( Node::Item(hir::Item { kind: hir::ItemKind::Trait { .. } | hir::ItemKind::TraitAlias(..), .. - }) => implied_predicates_with_filter( + }) => implied_clauses_with_filter( tcx, def_id.to_def_id(), PredicateFilter::SelfConstIfConst, diff --git a/compiler/rustc_hir_analysis/src/collect/dump.rs b/compiler/rustc_hir_analysis/src/collect/dump.rs index 09ec1084e9055..66968826e5275 100644 --- a/compiler/rustc_hir_analysis/src/collect/dump.rs +++ b/compiler/rustc_hir_analysis/src/collect/dump.rs @@ -45,23 +45,23 @@ pub(crate) fn opaque_hidden_types(tcx: TyCtxt<'_>) { } } -pub(crate) fn predicates_and_item_bounds(tcx: TyCtxt<'_>) { +pub(crate) fn clauses_and_item_bounds(tcx: TyCtxt<'_>) { for id in tcx.hir_crate_items(()).owners() { #[expect(deprecated)] // we don't want to unnecessarily retrieve the attrs twice in a row. let attrs = tcx.get_all_attrs(id); if find_attr!(attrs, RustcDumpPredicates) { - let preds = tcx - .predicates_of(id) + let clauses = tcx + .clauses_of(id) .instantiate_identity(tcx) - .predicates + .clauses .into_iter() .map(Unnormalized::skip_norm_wip); let span = tcx.def_span(id); let mut diag = tcx.dcx().struct_span_err(span, sym::rustc_dump_predicates.as_str()); - for pred in preds { - diag.note(format!("{pred:?}")); + for clause in clauses { + diag.note(format!("{clause:?}")); } diag.emit(); } diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs index 0bdaa3dd10183..a986ae3964e26 100644 --- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs @@ -138,8 +138,8 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { // the def id of the `{ N + 1 }` anon const // struct Foo; // - // This has some implications for how we get the predicates available to the anon const - // see `explicit_predicates_of` for more information on this + // This has some implications for how we get the clauses available to the anon const + // see `explicit_clauses_of` for more information on this let generics = tcx.generics_of(parent_did); let param_def_idx = generics.param_def_id_to_index[¶m_id.to_def_id()]; // In the above example this would be .params[..N#0] diff --git a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs index 46007503539ca..4874eacd79b63 100644 --- a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs +++ b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs @@ -11,7 +11,7 @@ use rustc_span::def_id::{DefId, LocalDefId}; use tracing::{debug, instrument}; use super::ItemCtxt; -use super::predicates_of::assert_only_contains_predicates_from; +use super::clauses_of::assert_only_contains_clauses_from; use crate::hir_ty_lowering::{ HirTyLowerer, ImpliedBoundsContext, OverlappingAsssocItemConstraints, PredicateFilter, }; @@ -72,11 +72,11 @@ fn associated_type_bounds<'tcx>( // Also collect `where Self::Assoc: Trait` from the parent trait's where clauses. let trait_def_id = tcx.local_parent(assoc_item_def_id); - let trait_predicates = tcx.trait_explicit_predicates_and_bounds(trait_def_id); + let trait_clauses = tcx.trait_explicit_clauses_and_bounds(trait_def_id); let item_trait_ref = ty::TraitRef::identity(tcx, tcx.parent(assoc_item_def_id.to_def_id())); - bounds.extend(trait_predicates.predicates.iter().copied().filter_map( + bounds.extend(trait_clauses.clauses.iter().copied().filter_map( |(clause, span)| { remap_gat_vars_and_recurse_into_nested_projections( tcx, @@ -94,8 +94,8 @@ fn associated_type_bounds<'tcx>( // FIXME(const_trait_impl): We *could* uplift the // `where Self::Assoc: [const] Trait` bounds from the parent trait // here too, but we'd need to split `const_conditions` into two - // queries (like we do for `trait_explicit_predicates_and_bounds`) - // since we need to also filter the predicates *out* of the const + // queries (like we do for `trait_explicit_clauses_and_bounds`) + // since we need to also filter the clauses *out* of the const // conditions or they lead to cycles in the trait solver when // utilizing these bounds. For now, let's do nothing. } @@ -108,7 +108,7 @@ fn associated_type_bounds<'tcx>( bounds ); - assert_only_contains_predicates_from(filter, bounds, item_ty); + assert_only_contains_clauses_from(filter, bounds, item_ty); bounds }) @@ -465,7 +465,7 @@ pub(super) fn explicit_item_bounds_with_filter( .to_vec() .fold_with(&mut AssocTyToOpaque { tcx, fn_def_id: parent.to_def_id() }), ); - assert_only_contains_predicates_from(filter, bounds, item_ty); + assert_only_contains_clauses_from(filter, bounds, item_ty); bounds } rustc_hir::OpaqueTyOrigin::FnReturn { @@ -480,7 +480,7 @@ pub(super) fn explicit_item_bounds_with_filter( let args = GenericArgs::identity_for_item(tcx, def_id); let item_ty = Ty::new_opaque(tcx, ty::IsRigid::No, def_id.to_def_id(), args); let bounds = opaque_type_bounds(tcx, def_id, bounds, item_ty, *span, filter); - assert_only_contains_predicates_from(filter, bounds, item_ty); + assert_only_contains_clauses_from(filter, bounds, item_ty); bounds } }, diff --git a/compiler/rustc_hir_analysis/src/constrained_generic_params.rs b/compiler/rustc_hir_analysis/src/constrained_generic_params.rs index a392ff5d3a552..36777359076c3 100644 --- a/compiler/rustc_hir_analysis/src/constrained_generic_params.rs +++ b/compiler/rustc_hir_analysis/src/constrained_generic_params.rs @@ -109,22 +109,22 @@ impl<'tcx> TypeVisitor> for ParameterCollector { pub(crate) fn identify_constrained_generic_params<'tcx>( tcx: TyCtxt<'tcx>, - predicates: ty::GenericPredicates<'tcx>, + gen_clauses: ty::GenericClauses<'tcx>, impl_trait_ref: Option>, input_parameters: &mut FxHashSet, ) { - let mut predicates = predicates.predicates.to_vec(); - setup_constraining_predicates(tcx, &mut predicates, impl_trait_ref, input_parameters); + let mut clauses = gen_clauses.clauses.to_vec(); + setup_constraining_clauses(tcx, &mut clauses, impl_trait_ref, input_parameters); } -/// Order the predicates in `predicates` such that each parameter is +/// Order the clauses in `clauses` such that each parameter is /// constrained before it is used, if that is possible, and add the /// parameters so constrained to `input_parameters`. For example, /// imagine the following impl: /// ```ignore (illustrative) /// impl> Trait for U /// ``` -/// The impl's predicates are collected from left to right. Ignoring +/// The impl's clauses are collected from left to right. Ignoring /// the implicit `Sized` bounds, these are /// * `T: Debug` /// * `U: Iterator` @@ -135,9 +135,9 @@ pub(crate) fn identify_constrained_generic_params<'tcx>( /// variables and match them with the impl trait-ref, so we know that /// `$U = IntoIter`. /// -/// However, in order to process the `$T: Debug` predicate, we must first +/// However, in order to process the `$T: Debug` clause, we must first /// know the value of `$T` - which is only given by processing the -/// projection. As we occasionally want to process predicates in a single +/// projection. As we occasionally want to process clauses in a single /// pass, we want the projection to come first. In fact, as projections /// can (acyclically) depend on one another - see RFC447 for details - we /// need to topologically sort them. @@ -161,9 +161,9 @@ pub(crate) fn identify_constrained_generic_params<'tcx>( /// which is determined by 1, which requires `U`, that is determined /// by 0. I should probably pick a less tangled example, but I can't /// think of any. -pub(crate) fn setup_constraining_predicates<'tcx>( +pub(crate) fn setup_constraining_clauses<'tcx>( tcx: TyCtxt<'tcx>, - predicates: &mut [(ty::Clause<'tcx>, Span)], + clauses: &mut [(ty::Clause<'tcx>, Span)], impl_trait_ref: Option>, input_parameters: &mut FxHashSet, ) { @@ -192,19 +192,18 @@ pub(crate) fn setup_constraining_predicates<'tcx>( // * T: Debug // * U: Iterator debug!( - "setup_constraining_predicates: predicates={:?} \ - impl_trait_ref={:?} input_parameters={:?}", - predicates, impl_trait_ref, input_parameters + "setup_constraining_clauses: clauses={:?} impl_trait_ref={:?} input_parameters={:?}", + clauses, impl_trait_ref, input_parameters ); let mut i = 0; let mut changed = true; while changed { changed = false; - for j in i..predicates.len() { + for j in i..clauses.len() { // Note that we don't have to care about binders here, // as the impl trait ref never contains any late-bound regions. - if let ty::ClauseKind::Projection(projection) = predicates[j].0.kind().skip_binder() && + if let ty::ClauseKind::Projection(projection) = clauses[j].0.kind().skip_binder() && // Special case: watch out for some kind of sneaky attempt to // project out an associated type defined by this very trait. @@ -219,15 +218,15 @@ pub(crate) fn setup_constraining_predicates<'tcx>( { input_parameters.extend(parameters_for(tcx, projection.term, false)); - predicates.swap(i, j); + clauses.swap(i, j); i += 1; changed = true; } } debug!( - "setup_constraining_predicates: predicates={:?} \ + "setup_constraining_clauses: clauses={:?} \ i={} impl_trait_ref={:?} input_parameters={:?}", - predicates, i, impl_trait_ref, input_parameters + clauses, i, impl_trait_ref, input_parameters ); } } diff --git a/compiler/rustc_hir_analysis/src/delegation.rs b/compiler/rustc_hir_analysis/src/delegation.rs index 99480251e19ec..d33a1cf736738 100644 --- a/compiler/rustc_hir_analysis/src/delegation.rs +++ b/compiler/rustc_hir_analysis/src/delegation.rs @@ -405,35 +405,35 @@ fn create_generic_args<'tcx>( (args, delegation_parent_args) } -pub(crate) fn inherit_predicates_for_delegation_item<'tcx>( +pub(crate) fn inherit_clauses_for_delegation_item<'tcx>( tcx: TyCtxt<'tcx>, def_id: LocalDefId, sig_id: DefId, -) -> ty::GenericPredicates<'tcx> { - struct PredicatesCollector<'tcx> { +) -> ty::GenericClauses<'tcx> { + struct ClausesCollector<'tcx> { tcx: TyCtxt<'tcx>, - preds: Vec<(ty::Clause<'tcx>, Span)>, + clauses: Vec<(ty::Clause<'tcx>, Span)>, args: Vec>, folder: ParamIndexRemapper<'tcx>, - filter_self_preds: bool, + filter_self_clauses: bool, } - impl<'tcx> PredicatesCollector<'tcx> { - fn with_own_preds( + impl<'tcx> ClausesCollector<'tcx> { + fn with_own_clauses( mut self, - f: impl Fn(DefId) -> ty::GenericPredicates<'tcx>, + f: impl Fn(DefId) -> ty::GenericClauses<'tcx>, def_id: DefId, ) -> Self { - let preds = f(def_id); + let clauses = f(def_id); let args = self.args.as_slice(); - for pred in preds.predicates { + for clause in clauses.clauses { // If self ty is specified then there will be no generic param `Self`, - // so we do not need its predicates. - if self.filter_self_preds - && let Some(trait_pred) = pred.0.as_trait_clause() + // so we do not need its clauses. + if self.filter_self_clauses + && let Some(trait_clause) = clause.0.as_trait_clause() // Rely that `Self` has zero index. - && trait_pred.self_ty().skip_binder().is_param(0) + && trait_clause.self_ty().skip_binder().is_param(0) { continue; } @@ -446,27 +446,27 @@ pub(crate) fn inherit_predicates_for_delegation_item<'tcx>( // reuse Trait::, N>::foo; // } // ``` - // Then if we inherit const predicate from `Trait` then we end up with + // Then if we inherit const clause from `Trait` then we end up with // two `ConstArgHasType` for `N` constant: // 1) ConstArgHasType(N/#0, bool) from `Trait` // 2) ConstArgHasType(N/#0, usize) from delegation parent // So in case the constant came from delegation parent we will not inherit // ConstArgHasType from signature. // The check is so complicated because we build generic args for signature - // and predicates inheritance, for the example above it will be + // and clauses inheritance, for the example above it will be // `args = [S, N/#0, S, N/#0]`, where // args[0] - Self type, args[1] - delegation parent const, args[2] - first // arg of callee path, args[3] - second arg of callee path. - // When processing predicate ConstArgHasType(B/#2, bool) + // When processing clause ConstArgHasType(B/#2, bool) // from delegation signature (`Trait::foo`), we need to map `B/#2` into some // arg from `args`. The mapping which is built by `create_mapping` function is: // `{0: 0, 2: 3, 1: 2}`, so as `B/#2` has index `2` it is mapped into third // arg from `args` - `N/#0`. After we obtained mapped const param, we check if // it came from delegation parent, and if so we do not process its `ConstArgHasType` - // predicate. + // clause. // (Issue #158675). if let ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, _)) = - pred.0.as_predicate().fold_with(&mut self.folder).kind().skip_binder() + clause.0.as_predicate().fold_with(&mut self.folder).kind().skip_binder() { let unnorm_const = EarlyBinder::bind(self.tcx, ct).instantiate(self.tcx, args); if let ty::ConstKind::Param(param) = unnorm_const.skip_norm_wip().kind() @@ -476,60 +476,58 @@ pub(crate) fn inherit_predicates_for_delegation_item<'tcx>( } } - let new_pred = pred.0.fold_with(&mut self.folder); - self.preds.push(( - EarlyBinder::bind(self.tcx, new_pred) + let new_clause = clause.0.fold_with(&mut self.folder); + self.clauses.push(( + EarlyBinder::bind(self.tcx, new_clause) .instantiate(self.tcx, args) .skip_norm_wip(), - pred.1, + clause.1, )); } self } - fn with_preds( + fn with_clauses( mut self, - f: impl Fn(DefId) -> ty::GenericPredicates<'tcx> + Copy, + f: impl Fn(DefId) -> ty::GenericClauses<'tcx> + Copy, def_id: DefId, ) -> Self { let preds = f(def_id); if let Some(parent_def_id) = preds.parent { - self = self.with_own_preds(f, parent_def_id); + self = self.with_own_clauses(f, parent_def_id); } - self.with_own_preds(f, def_id) + self.with_own_clauses(f, def_id) } } let (parent_args, child_args) = tcx.delegation_user_specified_args(def_id); let (folder, args) = create_folder_and_args(tcx, def_id, sig_id, parent_args, child_args); let self_pos_kind = create_self_position_kind(tcx, def_id, sig_id); - let filter_self_preds = matches!( + let filter_self_clauses = matches!( self_pos_kind, SelfPositionKind::AfterLifetimes(Some(DelegationSelfTyPropagationKind::SelfTy(..))) ); - let collector = PredicatesCollector { tcx, preds: vec![], args, folder, filter_self_preds }; + let collector = ClausesCollector { tcx, clauses: vec![], args, folder, filter_self_clauses }; let (parent, inh_kind) = get_parent_and_inheritance_kind(tcx, def_id, sig_id); - // `explicit_predicates_of` is used here to avoid copying `Self: Trait` predicate. - // Note: `predicates_of` query can also add inferred outlives predicates, but that + // `explicit_clauses_of` is used here to avoid copying `Self: Trait` clause. + // Note: `clauses_of` query can also add inferred outlives clauses, but that // is not the case here as `sig_id` is either a trait or a function. - let preds = match inh_kind { + let clauses = match inh_kind { InheritanceKind::WithParent(false) => { - collector.with_preds(|def_id| tcx.explicit_predicates_of(def_id), sig_id) + collector.with_clauses(|def_id| tcx.explicit_clauses_of(def_id), sig_id) } InheritanceKind::WithParent(true) => { - collector.with_preds(|def_id| tcx.predicates_of(def_id), sig_id) - } - InheritanceKind::Own => { - collector.with_own_preds(|def_id| tcx.predicates_of(def_id), sig_id) + collector.with_clauses(|def_id| tcx.clauses_of(def_id), sig_id) } + InheritanceKind::Own => collector.with_own_clauses(|def_id| tcx.clauses_of(def_id), sig_id), } - .preds; + .clauses; - ty::GenericPredicates { parent, predicates: tcx.arena.alloc_from_iter(preds) } + ty::GenericClauses { parent, clauses: tcx.arena.alloc_from_iter(clauses) } } fn create_folder_and_args<'tcx>( diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check.rs b/compiler/rustc_hir_analysis/src/impl_wf_check.rs index 9e4a06e95fd1f..e1a91292abe21 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check.rs @@ -86,7 +86,7 @@ pub(crate) fn enforce_impl_lifetime_params_are_constrained( impl_self_ty.error_reported()?; let impl_generics = tcx.generics_of(impl_def_id); - let impl_predicates = tcx.predicates_of(impl_def_id); + let impl_clauses = tcx.clauses_of(impl_def_id); let impl_trait_ref = of_trait.then(|| tcx.impl_trait_ref(impl_def_id).instantiate_identity().skip_norm_wip()); @@ -95,7 +95,7 @@ pub(crate) fn enforce_impl_lifetime_params_are_constrained( let mut input_parameters = cgp::parameters_for_impl(tcx, impl_self_ty, impl_trait_ref); cgp::identify_constrained_generic_params( tcx, - impl_predicates, + impl_clauses, impl_trait_ref, &mut input_parameters, ); @@ -201,7 +201,7 @@ pub(crate) fn enforce_impl_non_lifetime_params_are_constrained( impl_self_ty.error_reported()?; let impl_generics = tcx.generics_of(impl_def_id); - let impl_predicates = tcx.predicates_of(impl_def_id); + let impl_clauses = tcx.clauses_of(impl_def_id); let impl_trait_ref = tcx .impl_opt_trait_ref(impl_def_id) .map(ty::EarlyBinder::instantiate_identity) @@ -212,7 +212,7 @@ pub(crate) fn enforce_impl_non_lifetime_params_are_constrained( let mut input_parameters = cgp::parameters_for_impl(tcx, impl_self_ty, impl_trait_ref); cgp::identify_constrained_generic_params( tcx, - impl_predicates, + impl_clauses, impl_trait_ref, &mut input_parameters, ); diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs index d6166cf8ef42a..999105640fce2 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs @@ -213,7 +213,7 @@ fn unconstrained_parent_impl_args<'tcx>( impl_def_id: DefId, impl_args: GenericArgsRef<'tcx>, ) -> Vec> { - let impl_generic_predicates = tcx.predicates_of(impl_def_id); + let impl_generic_clauses = tcx.clauses_of(impl_def_id); let mut unconstrained_parameters = FxHashSet::default(); let mut constrained_params = FxHashSet::default(); let impl_trait_ref = tcx.impl_trait_ref(impl_def_id).instantiate_identity().skip_norm_wip(); @@ -222,7 +222,7 @@ fn unconstrained_parent_impl_args<'tcx>( // what we want here. We want only a list of constrained parameters while // the functions in `cgp` add the constrained parameters to a list of // unconstrained parameters. - for (clause, _) in impl_generic_predicates.predicates.iter() { + for (clause, _) in impl_generic_clauses.clauses.iter() { if let ty::ClauseKind::Projection(proj) = clause.kind().skip_binder() { let unbound_trait_ref = proj.projection_term.trait_ref(tcx); if unbound_trait_ref == impl_trait_ref { @@ -327,7 +327,7 @@ fn check_predicates<'tcx>( ) -> Result<(), ErrorGuaranteed> { let impl1_clauses: Vec<(ty::Clause<'_>, _)> = traits::elaborate( tcx, - tcx.predicates_of(impl1_def_id) + tcx.clauses_of(impl1_def_id) .instantiate(tcx, impl1_args) .into_iter() .map(|(c, s)| (c.skip_norm_wip(), s)), @@ -341,7 +341,7 @@ fn check_predicates<'tcx>( } else { traits::elaborate( tcx, - tcx.predicates_of(impl2_node.def_id()) + tcx.clauses_of(impl2_node.def_id()) .instantiate(tcx, impl2_args) .into_iter() .map(|(c, _s)| c.skip_norm_wip()), diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 9ec74543719dc..1473b0d108fb3 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -209,7 +209,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) { variance::dump::variances(tcx); collect::dump::generics(tcx); collect::dump::opaque_hidden_types(tcx); - collect::dump::predicates_and_item_bounds(tcx); + collect::dump::clauses_and_item_bounds(tcx); collect::dump::def_parents(tcx); collect::dump::vtables(tcx); }); diff --git a/compiler/rustc_hir_analysis/src/outlives/explicit.rs b/compiler/rustc_hir_analysis/src/outlives/explicit.rs index 97ef6a2461495..fddb9182710d3 100644 --- a/compiler/rustc_hir_analysis/src/outlives/explicit.rs +++ b/compiler/rustc_hir_analysis/src/outlives/explicit.rs @@ -14,22 +14,22 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> { ExplicitPredicatesMap { map: FxIndexMap::default() } } - pub(crate) fn explicit_predicates_of( + pub(crate) fn explicit_clauses_of( &mut self, tcx: TyCtxt<'tcx>, def_id: DefId, ) -> &ty::EarlyBinder<'tcx, RequiredPredicates<'tcx>> { self.map.entry(def_id).or_insert_with(|| { - let predicates = if def_id.is_local() { - tcx.explicit_predicates_of(def_id) + let gen_clauses = if def_id.is_local() { + tcx.explicit_clauses_of(def_id) } else { - tcx.predicates_of(def_id) + tcx.clauses_of(def_id) }; let mut required_predicates = RequiredPredicates::default(); - // process predicates and convert to `RequiredPredicates` entry, see below - for &(predicate, span) in predicates.predicates { - match predicate.kind().skip_binder() { + // Process clauses and convert to `RequiredPredicates` entry, see below. + for &(clause, span) in gen_clauses.clauses { + match clause.kind().skip_binder() { ty::ClauseKind::TypeOutlives(OutlivesPredicate(ty, reg)) => { insert_outlives_predicate( tcx, diff --git a/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs b/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs index 239a900afb4cf..8780d877dde50 100644 --- a/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs +++ b/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs @@ -255,23 +255,22 @@ fn check_explicit_predicates<'tcx>( explicit_map: &mut ExplicitPredicatesMap<'tcx>, ignore_preds_refing_self: IgnorePredicatesReferencingSelf, ) { - let explicit_predicates = explicit_map.explicit_predicates_of(tcx, def_id); + let explicit_clauses = explicit_map.explicit_clauses_of(tcx, def_id); - for (&predicate @ ty::OutlivesPredicate(arg, _), &span) in - explicit_predicates.as_ref().skip_binder() + for (&clause @ ty::OutlivesPredicate(arg, _), &span) in explicit_clauses.as_ref().skip_binder() { - debug!(?predicate); + debug!(?clause); if let IgnorePredicatesReferencingSelf::Yes = ignore_preds_refing_self && arg.walk().any(|arg| arg == tcx.types.self_param.into()) { - debug!("ignoring predicate since it references `Self`"); + debug!("ignoring clause since it references `Self`"); continue; } - let predicate @ ty::OutlivesPredicate(arg, region) = - explicit_predicates.rebind(predicate).instantiate(tcx, args).skip_norm_wip(); - debug!(?predicate); + let clause @ ty::OutlivesPredicate(arg, region) = + explicit_clauses.rebind(clause).instantiate(tcx, args).skip_norm_wip(); + debug!(?clause); insert_outlives_predicate(tcx, arg, region, span, required_predicates); } diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 1ba299df23613..288a1903bf675 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -559,23 +559,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // `#[rustc_evaluate_where_clauses]` trigger special output // to let us test the trait evaluation system. if self.has_rustc_attrs && find_attr!(self.tcx, def_id, RustcEvaluateWhereClauses) { - let predicates = self.tcx.predicates_of(def_id); - let predicates = predicates.instantiate(self.tcx, args); - for (predicate, predicate_span) in predicates { - let predicate = predicate.skip_norm_wip(); + let clauses = self.tcx.clauses_of(def_id); + let clauses = clauses.instantiate(self.tcx, args); + for (clause, clause_span) in clauses { + let clause = clause.skip_norm_wip(); let obligation = Obligation::new( self.tcx, ObligationCause::dummy_with_span(callee_expr.span), self.param_env, - predicate, + clause, ); let result = self.evaluate_obligation(&obligation); self.dcx() .struct_span_err( callee_expr.span, - format!("evaluate({predicate:?}) = {result:?}"), + format!("evaluate({clause:?}) = {result:?}"), ) - .with_span_label(predicate_span, "predicate") + .with_span_label(clause_span, "predicate") .emit(); } } diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 6ffbbed8fd642..c5fb813274992 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -3561,8 +3561,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Register the impl's predicates. One of these predicates // must be unsatisfied, or else we wouldn't have gotten here // in the first place. - let unnormalized_predicates = - self.tcx.predicates_of(impl_def_id).instantiate(self.tcx, impl_args); + let unnormalized_clauses = + self.tcx.clauses_of(impl_def_id).instantiate(self.tcx, impl_args); ocx.register_obligations(traits::predicates_for_generics( |idx, span| { cause.clone().derived_cause( @@ -3574,15 +3574,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ObligationCauseCode::ImplDerived(Box::new(traits::ImplDerivedCause { derived, impl_or_alias_def_id: impl_def_id, - impl_def_predicate_index: Some(idx), + impl_def_clause_index: Some(idx), span, })) }, ) }, - |pred| ocx.normalize(&cause, self.param_env, pred), + |clause| ocx.normalize(&cause, self.param_env, clause), self.param_env, - unnormalized_predicates, + unnormalized_clauses, )); // Normalize the output type, which we can use later on as the diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index b413d0c0bb2de..1886888c476a0 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -567,9 +567,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - let mut clauses = CollectClauses { clauses: vec![], fcx: self }; - clauses.visit_ty_unambig(hir_ty); - self.tcx.mk_clauses(&clauses.clauses) + let mut collect_clauses = CollectClauses { clauses: vec![], fcx: self }; + collect_clauses.visit_ty_unambig(hir_ty); + self.tcx.mk_clauses(&collect_clauses.clauses) } #[instrument(level = "debug", skip_all)] @@ -1470,11 +1470,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) { let param_env = self.param_env; - let bounds = self.tcx.predicates_of(def_id).instantiate(self.tcx, args); + let bounds = self.tcx.clauses_of(def_id).instantiate(self.tcx, args); for obligation in traits::predicates_for_generics( - |idx, predicate_span| self.cause(span, code(idx, predicate_span)), - |pred| self.normalize(span, pred), + |idx, clause_span| self.cause(span, code(idx, clause_span)), + |clause| self.normalize(span, clause), param_env, bounds, ) { diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs index 5a1bab56b91f2..c0ec4249087c3 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs @@ -14,9 +14,9 @@ use rustc_trait_selection::traits; use crate::FnCtxt; enum ClauseFlavor { - /// Predicate comes from `predicates_of`. + /// Clause comes from `clauses_of`. Where, - /// Predicate comes from `const_conditions`. + /// Clause comes from `const_conditions`. Const, } @@ -54,17 +54,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { _ => return false, }; - let uninstantiated_pred = match flavor { + let uninstantiated_clause = match flavor { ClauseFlavor::Where - if let Some(pred) = self + if let Some(clause) = self .tcx - .predicates_of(def_id) + .clauses_of(def_id) .instantiate_identity(self.tcx) - .predicates + .clauses .into_iter() .nth(idx) => { - pred + clause } ClauseFlavor::Const if let Some((pred, _)) = self @@ -81,7 +81,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let generics = self.tcx.generics_of(def_id); let (predicate_args, predicate_self_type_to_point_at) = - match uninstantiated_pred.kind().skip_binder() { + match uninstantiated_clause.kind().skip_binder() { ty::ClauseKind::Trait(pred) => { (pred.trait_ref.args.to_vec(), Some(pred.self_ty().into())) } @@ -831,19 +831,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // We only really care about the `Self` type itself, which we extract from the ref. let impl_self_ty: Ty<'tcx> = impl_trait_self_ref.self_ty(); - let impl_predicates: ty::GenericPredicates<'tcx> = - self.tcx.predicates_of(obligation.impl_or_alias_def_id); - let Some(impl_predicate_index) = obligation.impl_def_predicate_index else { + let impl_clauses: ty::GenericClauses<'tcx> = + self.tcx.clauses_of(obligation.impl_or_alias_def_id); + let Some(impl_clause_index) = obligation.impl_def_clause_index else { // We don't have the index, so we can only guess. return Err(expr); }; - if impl_predicate_index >= impl_predicates.predicates.len() { - // This shouldn't happen, but since this is only a diagnostic improvement, avoid breaking things. + if impl_clause_index >= impl_clauses.clauses.len() { + // This shouldn't happen, but since this is only a diagnostic improvement, avoid + // breaking things. return Err(expr); } - match impl_predicates.predicates[impl_predicate_index].0.kind().skip_binder() { + match impl_clauses.clauses[impl_clause_index].0.kind().skip_binder() { ty::ClauseKind::Trait(broken_trait) => { // ... self.blame_specific_part_of_expr_corresponding_to_generic_param( diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index c76febd539ef8..9d300a86f9e12 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -1636,14 +1636,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // and point at that. let instantiated = self .tcx - .explicit_predicates_of(self.body_def_id) + .explicit_clauses_of(self.body_def_id) .instantiate_identity(self.tcx); // FIXME(compiler-errors): This could be problematic if something has two // fn-like predicates with different args, but callable types really never // do that, so it's OK. - for (predicate, span) in instantiated { + for (clause, span) in instantiated { if let ty::ClauseKind::Trait(pred) = - predicate.skip_norm_wip().kind().skip_binder() + clause.skip_norm_wip().kind().skip_binder() && pred.self_ty().peel_refs() == callee_ty && self.tcx.is_fn_trait(pred.def_id()) { diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs index b255951baefa6..287e3857087e7 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs @@ -335,10 +335,10 @@ impl<'tcx> HirTyLowerer<'tcx> for FnCtxt<'_, 'tcx> { } // Check whether the impl imposes obligations we have to worry about. - let impl_bounds = tcx.predicates_of(impl_).instantiate(tcx, impl_args); + let impl_bounds = tcx.clauses_of(impl_).instantiate(tcx, impl_args); let impl_obligations = traits::predicates_for_generics( |_, _| ObligationCause::dummy(), - |pred| ocx.normalize(&ObligationCause::dummy(), self.param_env, pred), + |clause| ocx.normalize(&ObligationCause::dummy(), self.param_env, clause), self.param_env, impl_bounds, ); diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index d5dc17837f1ed..05463cd9ae3f7 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -115,7 +115,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { debug!("rcvr_args={rcvr_args:?}, all_args={all_args:?}"); // Create the final signature for the method, replacing late-bound regions. - let (method_sig, method_predicates) = self.instantiate_method_sig(pick, all_args); + let (method_sig, method_clauses) = self.instantiate_method_sig(pick, all_args); // If there is a `Self: Sized` bound and `Self` is a trait object, it is possible that // something which derefs to `Self` actually implements the trait and the caller @@ -127,8 +127,8 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { // appropriate hint suggesting to import the trait. let filler_args = rcvr_args .extend_to(self.tcx, pick.item.def_id, |def, _| self.tcx.mk_param_from_def(def)); - let illegal_sized_bound = self.predicates_require_illegal_sized_bound( - self.tcx.predicates_of(pick.item.def_id).instantiate(self.tcx, filler_args), + let illegal_sized_bound = self.clauses_require_illegal_sized_bound( + self.tcx.clauses_of(pick.item.def_id).instantiate(self.tcx, filler_args), ); // Unify the (adjusted) self type with what the method expects. @@ -140,8 +140,8 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { let method_sig_rcvr = self.normalize(self.span, Unnormalized::new_wip(method_sig.inputs()[0])); debug!( - "confirm: self_ty={:?} method_sig_rcvr={:?} method_sig={:?} method_predicates={:?}", - self_ty, method_sig_rcvr, method_sig, method_predicates + "confirm: self_ty={:?} method_sig_rcvr={:?} method_sig={:?} method_clauses={:?}", + self_ty, method_sig_rcvr, method_sig, method_clauses ); self.unify_receivers(self_ty, method_sig_rcvr, pick); @@ -160,7 +160,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { // 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.is_none() { - self.add_obligations(method_sig, all_args, method_predicates, pick.item.def_id); + self.add_obligations(method_sig, all_args, method_clauses, pick.item.def_id); } // Create the final `MethodCallee`. @@ -595,16 +595,16 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { &mut self, pick: &probe::Pick<'tcx>, all_args: GenericArgsRef<'tcx>, - ) -> (ty::FnSig<'tcx>, ty::InstantiatedPredicates<'tcx>) { + ) -> (ty::FnSig<'tcx>, ty::InstantiatedClauses<'tcx>) { debug!("instantiate_method_sig(pick={:?}, all_args={:?})", pick, all_args); // Instantiate the bounds on the method with the // type/early-bound-regions instantiations performed. There can // be no late-bound regions appearing here. let def_id = pick.item.def_id; - let method_predicates = self.tcx.predicates_of(def_id).instantiate(self.tcx, all_args); + let method_clauses = self.tcx.clauses_of(def_id).instantiate(self.tcx, all_args); - debug!("method_predicates after instantiation = {:?}", method_predicates); + debug!("method_clauses after instantiation = {:?}", method_clauses); let sig = self.tcx.fn_sig(def_id).instantiate(self.tcx, all_args).skip_norm_wip(); debug!("type scheme instantiated, sig={:?}", sig); @@ -612,22 +612,22 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { let sig = self.instantiate_binder_with_fresh_vars(sig); debug!("late-bound lifetimes from method instantiated, sig={:?}", sig); - (sig, method_predicates) + (sig, method_clauses) } fn add_obligations( &mut self, sig: ty::FnSig<'tcx>, all_args: GenericArgsRef<'tcx>, - method_predicates: ty::InstantiatedPredicates<'tcx>, + method_clauses: ty::InstantiatedClauses<'tcx>, def_id: DefId, ) { debug!( - "add_obligations: sig={:?} all_args={:?} method_predicates={:?} def_id={:?}", - sig, all_args, method_predicates, def_id + "add_obligations: sig={:?} all_args={:?} method_clauses={:?} def_id={:?}", + sig, all_args, method_clauses, def_id ); - // FIXME: could replace with the following, but we already calculated `method_predicates`, + // FIXME: could replace with the following, but we already calculated `method_clauses`, // so we just call `predicates_for_generics` directly to avoid redoing work. // `self.add_required_obligations(self.span, def_id, &all_args);` for obligation in traits::predicates_for_generics( @@ -640,9 +640,9 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { ); self.cause(self.span, code) }, - |pred| self.normalize(self.call_expr.span, pred), + |clause| self.normalize(self.call_expr.span, clause), self.param_env, - method_predicates, + method_clauses, ) { self.register_predicate(obligation); } @@ -666,22 +666,24 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { /////////////////////////////////////////////////////////////////////////// // MISCELLANY - fn predicates_require_illegal_sized_bound( + fn clauses_require_illegal_sized_bound( &self, - predicates: ty::InstantiatedPredicates<'tcx>, + inst_clauses: ty::InstantiatedClauses<'tcx>, ) -> Option { let sized_def_id = self.tcx.lang_items().sized_trait()?; traits::elaborate( self.tcx, - predicates.predicates.iter().copied().map(Unnormalized::skip_norm_wip), + inst_clauses.clauses.iter().copied().map(Unnormalized::skip_norm_wip), ) // We don't care about regions here. - .filter_map(|pred| match pred.kind().skip_binder() { + .filter_map(|clause| match clause.kind().skip_binder() { ty::ClauseKind::Trait(trait_pred) if trait_pred.def_id() == sized_def_id => { - let span = predicates + let span = inst_clauses .iter() - .find_map(|(p, span)| if p.skip_norm_wip() == pred { Some(span) } else { None }) + .find_map( + |(c, span)| if c.skip_norm_wip() == clause { Some(span) } else { None }, + ) .unwrap_or(DUMMY_SP); Some((trait_pred, span)) } diff --git a/compiler/rustc_hir_typeck/src/method/mod.rs b/compiler/rustc_hir_typeck/src/method/mod.rs index dd8ffc5a7fd46..3425ba5d747d6 100644 --- a/compiler/rustc_hir_typeck/src/method/mod.rs +++ b/compiler/rustc_hir_typeck/src/method/mod.rs @@ -440,15 +440,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // // Note that as the method comes from a trait, it should not have // any late-bound regions appearing in its bounds. - let bounds = self.tcx.predicates_of(def_id).instantiate(self.tcx, args); + let bounds = self.tcx.clauses_of(def_id).instantiate(self.tcx, args); let predicates_cause = obligation.cause.clone(); let mut normalization_obligations = PredicateObligations::new(); obligations.extend(traits::predicates_for_generics( move |_, _| predicates_cause.clone(), - |pred| { + |clause| { let InferOk { value: pred, obligations: o } = - self.at(&obligation.cause, self.param_env).normalize(pred); + self.at(&obligation.cause, self.param_env).normalize(clause); normalization_obligations.extend(o); assert!(!pred.has_escaping_bound_vars()); pred diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index dfb4647b5e6e2..eab4e1990455c 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -2037,7 +2037,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { // Check whether the impl imposes obligations we have to worry about. let impl_def_id = probe.item.container_id(self.tcx); let impl_bounds = - self.tcx.predicates_of(impl_def_id).instantiate(self.tcx, impl_args); + self.tcx.clauses_of(impl_def_id).instantiate(self.tcx, impl_args); // Convert the bounds into obligations. ocx.register_obligations(traits::predicates_for_generics( |idx, span| { @@ -2049,7 +2049,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { ); self.cause(self.span, code) }, - |pred| ocx.normalize(cause, self.param_env, pred), + |clause| ocx.normalize(cause, self.param_env, clause), self.param_env, impl_bounds, )); diff --git a/compiler/rustc_incremental/src/persist/clean.rs b/compiler/rustc_incremental/src/persist/clean.rs index a8eb1ff3d5a42..d3a04ab5946b7 100644 --- a/compiler/rustc_incremental/src/persist/clean.rs +++ b/compiler/rustc_incremental/src/persist/clean.rs @@ -45,7 +45,7 @@ const BASE_FN: &[&str] = &[ // Callers will depend on the signature of these items, so we better test label_strs::fn_sig, label_strs::generics_of, - label_strs::predicates_of, + label_strs::clauses_of, label_strs::type_of, // And a big part of compilation (that we eventually want to cache) is type inference // information: @@ -71,7 +71,7 @@ const BASE_MIR: &[&str] = &[label_strs::optimized_mir, label_strs::promoted_mir] /// Note that changing the type of a field does not change the type of the struct or enum, but /// adding/removing fields or changing a fields name or visibility does. const BASE_STRUCT: &[&str] = - &[label_strs::generics_of, label_strs::predicates_of, label_strs::type_of]; + &[label_strs::generics_of, label_strs::clauses_of, label_strs::type_of]; /// Trait definition `DepNode`s. /// Extra `DepNode`s for functions and methods. @@ -105,7 +105,7 @@ const LABELS_HIR_ONLY: &[&[&str]] = &[BASE_HIR]; /// Impl `DepNode`s. const LABELS_TRAIT: &[&[&str]] = &[ BASE_HIR, - &[label_strs::associated_item_def_ids, label_strs::predicates_of, label_strs::generics_of], + &[label_strs::associated_item_def_ids, label_strs::clauses_of, label_strs::generics_of], ]; /// Impl `DepNode`s. diff --git a/compiler/rustc_infer/src/traits/util.rs b/compiler/rustc_infer/src/traits/util.rs index 49e8d9a1f44fb..2630c8b125418 100644 --- a/compiler/rustc_infer/src/traits/util.rs +++ b/compiler/rustc_infer/src/traits/util.rs @@ -88,7 +88,7 @@ impl<'tcx> Elaboratable> for PredicateObligation<'tcx> { ObligationCauseCode::ImplDerived(Box::new(traits::ImplDerivedCause { derived, impl_or_alias_def_id: parent_trait_pred.def_id(), - impl_def_predicate_index: Some(index), + impl_def_clause_index: Some(index), span, })) }); diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index dd56b13cb2f5e..3506868402c99 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -1450,9 +1450,9 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints { use rustc_middle::ty::ClauseKind; if cx.tcx.features().trivial_bounds() { - let predicates = cx.tcx.predicates_of(item.owner_id); - for &(predicate, span) in predicates.predicates { - let predicate_kind_name = match predicate.kind().skip_binder() { + let gen_clauses = cx.tcx.clauses_of(item.owner_id); + for &(clause, span) in gen_clauses.clauses { + let clause_kind_name = match clause.kind().skip_binder() { ClauseKind::Trait(..) => "trait", ClauseKind::TypeOutlives(..) | ClauseKind::RegionOutlives(..) => "lifetime", @@ -1469,11 +1469,11 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints { // Users don't write this directly, only via another trait ref. | ty::ClauseKind::HostEffect(..) => continue, }; - if predicate.is_global() { + if clause.is_global() { cx.emit_span_lint( TRIVIAL_BOUNDS, span, - BuiltinTrivialBounds { predicate_kind_name, predicate }, + BuiltinTrivialBounds { clause_kind_name, clause }, ); } } diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index f8f229a372ceb..b2c063922e90e 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -129,19 +129,22 @@ fn has_unstable_into_iter_predicate<'tcx>( let Some(into_iter_fn_def_id) = cx.tcx.lang_items().into_iter_fn() else { return false; }; - let predicates = cx.tcx.predicates_of(callee_def_id).instantiate(cx.tcx, generic_args); - for (predicate, _) in predicates { - let Some(trait_pred) = predicate.as_trait_clause() else { + let clauses = cx.tcx.clauses_of(callee_def_id).instantiate(cx.tcx, generic_args); + for (clause, _) in clauses { + let Some(trait_clause) = clause.as_trait_clause() else { continue; }; - if trait_pred.def_id() != into_iterator_def_id - || trait_pred.polarity() != PredicatePolarity::Positive + if trait_clause.def_id() != into_iterator_def_id + || trait_clause.polarity() != PredicatePolarity::Positive { continue; } // `IntoIterator::into_iter` has no additional method args. - let into_iter_fn_args = - cx.tcx.instantiate_bound_regions_with_erased(trait_pred.skip_norm_wip()).trait_ref.args; + let into_iter_fn_args = cx + .tcx + .instantiate_bound_regions_with_erased(trait_clause.skip_norm_wip()) + .trait_ref + .args; let Ok(Some(instance)) = ty::Instance::try_resolve( cx.tcx, cx.typing_env(), diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index d7852fc0e4f69..7e947962b7459 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -384,12 +384,10 @@ impl<'a> Diagnostic<'a, ()> for BuiltinTypeAliasBounds<'_> { } #[derive(Diagnostic)] -#[diag( - "{$predicate_kind_name} bound {$predicate} does not depend on any type or lifetime parameters" -)] +#[diag("{$clause_kind_name} bound {$clause} does not depend on any type or lifetime parameters")] pub(crate) struct BuiltinTrivialBounds<'a> { - pub predicate_kind_name: &'a str, - pub predicate: Clause<'a>, + pub clause_kind_name: &'a str, + pub clause: Clause<'a>, } #[derive(Diagnostic)] @@ -1888,7 +1886,7 @@ pub(crate) struct RedundantSemicolonsSuggestion { // traits.rs pub(crate) struct DropTraitConstraintsDiag<'a> { - pub predicate: Clause<'a>, + pub clause: Clause<'a>, pub tcx: TyCtxt<'a>, pub def_id: DefId, } @@ -1896,8 +1894,8 @@ pub(crate) struct DropTraitConstraintsDiag<'a> { // Needed for def_path_str impl<'a> Diagnostic<'a, ()> for DropTraitConstraintsDiag<'_> { fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { - Diag::new(dcx, level, msg!("bounds on `{$predicate}` are most likely incorrect, consider instead using `{$needs_drop}` to detect whether a type can be trivially dropped")) - .with_arg("predicate", self.predicate) + Diag::new(dcx, level, msg!("bounds on `{$clause}` are most likely incorrect, consider instead using `{$needs_drop}` to detect whether a type can be trivially dropped")) + .with_arg("clause", self.clause) .with_arg("needs_drop", self.tcx.def_path_str(self.def_id)) } } diff --git a/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs b/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs index be6bd68c8140f..7f0c615923ef1 100644 --- a/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs +++ b/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs @@ -45,10 +45,10 @@ impl<'tcx> LateLintPass<'tcx> for MultipleSupertraitUpcastable { { let direct_super_traits_iter = cx .tcx - .explicit_super_predicates_of(def_id) + .explicit_super_clauses_of(def_id) .iter_identity_copied() .map(Unnormalized::skip_norm_wip) - .filter_map(|(pred, _)| pred.as_trait_clause()) + .filter_map(|(clause, _)| clause.as_trait_clause()) .filter(|pred| !cx.tcx.is_lang_item(pred.def_id(), hir::LangItem::MetaSized)) .filter(|pred| !cx.tcx.is_default_trait(pred.def_id())); if direct_super_traits_iter.count() > 1 { diff --git a/compiler/rustc_lint/src/traits.rs b/compiler/rustc_lint/src/traits.rs index 9c2aada46c415..f5b21792af3ce 100644 --- a/compiler/rustc_lint/src/traits.rs +++ b/compiler/rustc_lint/src/traits.rs @@ -89,9 +89,9 @@ impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints { fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) { use rustc_middle::ty::ClauseKind; - let predicates = cx.tcx.explicit_predicates_of(item.owner_id); - for &(predicate, span) in predicates.predicates { - let ClauseKind::Trait(trait_predicate) = predicate.kind().skip_binder() else { + let gen_clauses = cx.tcx.explicit_clauses_of(item.owner_id); + for &(clause, span) in gen_clauses.clauses { + let ClauseKind::Trait(trait_predicate) = clause.kind().skip_binder() else { continue; }; let def_id = trait_predicate.trait_ref.def_id; @@ -104,7 +104,7 @@ impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints { cx.emit_span_lint( DROP_BOUNDS, span, - DropTraitConstraintsDiag { predicate, tcx: cx.tcx, def_id }, + DropTraitConstraintsDiag { clause, tcx: cx.tcx, def_id }, ); } } diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index 9acebc1a4822f..ca78640f135f4 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -230,11 +230,11 @@ impl IntoArgs for (CrateNum, SimplifiedType) { provide! { tcx, def_id, other, cdata, explicit_item_bounds => { table_defaulted_array } explicit_item_self_bounds => { table_defaulted_array } - explicit_predicates_of => { table } + explicit_clauses_of => { table } generics_of => { table } inferred_outlives_of => { table_defaulted_array } - explicit_super_predicates_of => { table_defaulted_array } - explicit_implied_predicates_of => { table_defaulted_array } + explicit_super_clauses_of => { table_defaulted_array } + explicit_implied_clauses_of => { table_defaulted_array } type_of => { table } type_alias_is_checked => { table_direct } variances_of => { table } diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 602c5ee0201dd..30a02223e6372 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1481,7 +1481,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { if should_encode_generics(def_kind) { let g = tcx.generics_of(def_id); record!(self.tables.generics_of[def_id] <- g); - record!(self.tables.explicit_predicates_of[def_id] <- self.tcx.explicit_predicates_of(def_id)); + record!(self.tables.explicit_clauses_of[def_id] <- self.tcx.explicit_clauses_of(def_id)); let inferred_outlives = self.tcx.inferred_outlives_of(def_id); record_defaulted_array!(self.tables.inferred_outlives_of[def_id] <- inferred_outlives); @@ -1516,10 +1516,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { } if let DefKind::Trait = def_kind { record!(self.tables.trait_def[def_id] <- self.tcx.trait_def(def_id)); - record_defaulted_array!(self.tables.explicit_super_predicates_of[def_id] <- - self.tcx.explicit_super_predicates_of(def_id).skip_binder()); - record_defaulted_array!(self.tables.explicit_implied_predicates_of[def_id] <- - self.tcx.explicit_implied_predicates_of(def_id).skip_binder()); + record_defaulted_array!(self.tables.explicit_super_clauses_of[def_id] <- + self.tcx.explicit_super_clauses_of(def_id).skip_binder()); + record_defaulted_array!(self.tables.explicit_implied_clauses_of[def_id] <- + self.tcx.explicit_implied_clauses_of(def_id).skip_binder()); let module_children = self.tcx.module_children_local(local_id); record_array!(self.tables.module_children_non_reexports[def_id] <- module_children.iter().map(|child| child.res.def_id().index)); @@ -1530,10 +1530,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { } if let DefKind::TraitAlias = def_kind { record!(self.tables.trait_def[def_id] <- self.tcx.trait_def(def_id)); - record_defaulted_array!(self.tables.explicit_super_predicates_of[def_id] <- - self.tcx.explicit_super_predicates_of(def_id).skip_binder()); - record_defaulted_array!(self.tables.explicit_implied_predicates_of[def_id] <- - self.tcx.explicit_implied_predicates_of(def_id).skip_binder()); + record_defaulted_array!(self.tables.explicit_super_clauses_of[def_id] <- + self.tcx.explicit_super_clauses_of(def_id).skip_binder()); + record_defaulted_array!(self.tables.explicit_implied_clauses_of[def_id] <- + self.tcx.explicit_implied_clauses_of(def_id).skip_binder()); } if let DefKind::Trait | DefKind::Impl { .. } = def_kind { let associated_item_def_ids = self.tcx.associated_item_def_ids(def_id); diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index 237672878bb4c..63096ecd2c636 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -397,8 +397,8 @@ define_tables! { explicit_item_bounds: Table, Span)>>, explicit_item_self_bounds: Table, Span)>>, inferred_outlives_of: Table, Span)>>, - explicit_super_predicates_of: Table, Span)>>, - explicit_implied_predicates_of: Table, Span)>>, + explicit_super_clauses_of: Table, Span)>>, + explicit_implied_clauses_of: Table, Span)>>, explicit_implied_const_bounds: Table, Span)>>, inherent_impls: Table>, opt_rpitit_info: Table>>, @@ -429,7 +429,7 @@ define_tables! { lookup_const_stability: Table>, lookup_default_body_stability: Table>, lookup_deprecation_entry: Table>, - explicit_predicates_of: Table>>, + explicit_clauses_of: Table>>, generics_of: Table>, type_of: Table>>>, variances_of: Table>, diff --git a/compiler/rustc_metadata/src/rmeta/parameterized.rs b/compiler/rustc_metadata/src/rmeta/parameterized.rs index feb6859eabd5b..a156dbb21d6ba 100644 --- a/compiler/rustc_metadata/src/rmeta/parameterized.rs +++ b/compiler/rustc_metadata/src/rmeta/parameterized.rs @@ -168,7 +168,7 @@ parameterized_over_tcx! { rustc_middle::ty::Const, rustc_middle::ty::ConstConditions, rustc_middle::ty::FnSig, - rustc_middle::ty::GenericPredicates, + rustc_middle::ty::GenericClauses, rustc_middle::ty::ImplTraitHeader, rustc_middle::ty::TraitRef, rustc_middle::ty::Ty, diff --git a/compiler/rustc_middle/src/mono.rs b/compiler/rustc_middle/src/mono.rs index 00bb3a2ee66a4..dc9a94f79aa0f 100644 --- a/compiler/rustc_middle/src/mono.rs +++ b/compiler/rustc_middle/src/mono.rs @@ -278,7 +278,7 @@ impl<'tcx> MonoItem<'tcx> { MonoItem::GlobalAsm(..) => return true, }; - !tcx.instantiate_and_check_impossible_predicates((def_id, &args)) + !tcx.instantiate_and_check_impossible_clauses((def_id, &args)) } pub fn local_span(&self, tcx: TyCtxt<'tcx>) -> Option { diff --git a/compiler/rustc_middle/src/queries.rs b/compiler/rustc_middle/src/queries.rs index b19a54ff52eb5..c2effee6c348f 100644 --- a/compiler/rustc_middle/src/queries.rs +++ b/compiler/rustc_middle/src/queries.rs @@ -414,15 +414,15 @@ rustc_queries! { feedable } - /// Returns the (elaborated) *predicates* of the definition given by `DefId` + /// Returns the (elaborated) *clauses* of the definition given by `DefId` /// that must be proven true at usage sites (and which can be assumed at definition site). /// - /// This is almost always *the* "predicates query" that you want. + /// This is almost always *the* predicates/clauses query that you want. /// /// **Tip**: You can use `#[rustc_dump_predicates]` on an item to basically print /// the result of this query for use in UI tests or for debugging purposes. - query predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> { - desc { "computing predicates of `{}`", tcx.def_path_str(key) } + query clauses_of(key: DefId) -> ty::GenericClauses<'tcx> { + desc { "computing clauses of `{}`", tcx.def_path_str(key) } } query opaque_types_defined_by( @@ -765,9 +765,9 @@ rustc_queries! { desc { "getting wasm import module map" } } - /// Returns the explicitly user-written *predicates and bounds* of the trait given by `DefId`. + /// Returns the explicitly user-written *clauses and bounds* of the trait given by `DefId`. /// - /// Traits are unusual, because predicates on associated types are + /// Traits are unusual, because clauses on associated types are /// converted into bounds on that type for backwards compatibility: /// /// ``` @@ -780,22 +780,22 @@ rustc_queries! { /// trait X { type U: Copy; } /// ``` /// - /// [`Self::explicit_predicates_of`] and [`Self::explicit_item_bounds`] will - /// then take the appropriate subsets of the predicates here. + /// [`Self::explicit_clauses_of`] and [`Self::explicit_item_bounds`] will + /// then take the appropriate subsets of the clauses here. /// /// # Panics /// /// This query will panic if the given definition is not a trait. - query trait_explicit_predicates_and_bounds(key: LocalDefId) -> ty::GenericPredicates<'tcx> { - desc { "computing explicit predicates of trait `{}`", tcx.def_path_str(key) } + query trait_explicit_clauses_and_bounds(key: LocalDefId) -> ty::GenericClauses<'tcx> { + desc { "computing explicit clauses of trait `{}`", tcx.def_path_str(key) } } - /// Returns the explicitly user-written *predicates* of the definition given by `DefId` + /// Returns the explicitly user-written *clauses* of the definition given by `DefId` /// that must be proven true at usage sites (and which can be assumed at definition site). /// - /// You should probably use [`TyCtxt::predicates_of`] unless you're looking for - /// predicates with explicit spans for diagnostics purposes. - query explicit_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> { + /// You should probably use [`TyCtxt::clauses_of`] unless you're looking for + /// clauses with explicit spans for diagnostics purposes. + query explicit_clauses_of(key: DefId) -> ty::GenericClauses<'tcx> { desc { "computing explicit predicates of `{}`", tcx.def_path_str(key) } cache_on_disk separate_provide_extern @@ -815,27 +815,27 @@ rustc_queries! { feedable } - /// Returns the explicitly user-written *super-predicates* of the trait given by `DefId`. + /// Returns the explicitly user-written *super-clauses* of the trait given by `DefId`. /// - /// These predicates are unelaborated and consequently don't contain transitive super-predicates. + /// These clauses are unelaborated and consequently don't contain transitive super-clauses. /// - /// This is a subset of the full list of predicates. We store these in a separate map + /// This is a subset of the full list of clauses. We store these in a separate map /// because we must evaluate them even during type conversion, often before the full - /// predicates are available (note that super-predicates must not be cyclic). - query explicit_super_predicates_of(key: DefId) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { - desc { "computing the super predicates of `{}`", tcx.def_path_str(key) } + /// clauses are available (note that super-clauses must not be cyclic). + query explicit_super_clauses_of(key: DefId) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { + desc { "computing the super clauses of `{}`", tcx.def_path_str(key) } cache_on_disk separate_provide_extern } - /// The predicates of the trait that are implied during elaboration. + /// The clauses of the trait that are implied during elaboration. /// - /// This is a superset of the super-predicates of the trait, but a subset of the predicates - /// of the trait. For regular traits, this includes all super-predicates and their + /// This is a superset of the super-clauses of the trait, but a subset of the clauses + /// of the trait. For regular traits, this includes all super-clauses and their /// associated type bounds. For trait aliases, currently, this includes all of the - /// predicates of the trait alias. - query explicit_implied_predicates_of(key: DefId) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { - desc { "computing the implied predicates of `{}`", tcx.def_path_str(key) } + /// clauses of the trait alias. + query explicit_implied_clauses_of(key: DefId) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { + desc { "computing the implied clauses of `{}`", tcx.def_path_str(key) } cache_on_disk separate_provide_extern } @@ -855,7 +855,7 @@ rustc_queries! { /// Compute the conditions that need to hold for a conditionally-const item to be const. /// That is, compute the set of `[const]` where clauses for a given item. /// - /// This can be thought of as the `[const]` equivalent of `predicates_of`. These are the + /// This can be thought of as the `[const]` equivalent of `clauses_of`. These are the /// predicates that need to be proven at usage sites, and can be assumed at definition. /// /// This query also computes the `[const]` where clauses for associated types, which are @@ -884,9 +884,9 @@ rustc_queries! { separate_provide_extern } - /// To avoid cycles within the predicates of a single item we compute - /// per-type-parameter predicates for resolving `T::AssocTy`. - query type_param_predicates( + /// To avoid cycles within the clauses of a single item we compute + /// per-type-parameter clauses for resolving `T::AssocTy`. + query type_param_clauses( key: (LocalDefId, LocalDefId, rustc_span::Ident) ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { desc { "computing the bounds for type parameter `{}`", tcx.hir_ty_param_name(key.1) } @@ -2603,9 +2603,9 @@ rustc_queries! { desc { "normalizing `{:?}`", goal.canonical.value.value.value.skip_normalization() } } - query instantiate_and_check_impossible_predicates(key: (DefId, GenericArgsRef<'tcx>)) -> bool { + query instantiate_and_check_impossible_clauses(key: (DefId, GenericArgsRef<'tcx>)) -> bool { desc { - "checking impossible instantiated predicates: `{}`", + "checking impossible instantiated clauses: `{}`", tcx.def_path_str(key.0) } } diff --git a/compiler/rustc_middle/src/query/erase.rs b/compiler/rustc_middle/src/query/erase.rs index 827ae5a8edbdf..9a6ab2732953a 100644 --- a/compiler/rustc_middle/src/query/erase.rs +++ b/compiler/rustc_middle/src/query/erase.rs @@ -242,7 +242,7 @@ impl_erasable_for_types_with_no_type_params! { rustc_middle::ty::ClosureTypeInfo<'_>, rustc_middle::ty::Const<'_>, rustc_middle::ty::ConstConditions<'_>, - rustc_middle::ty::GenericPredicates<'_>, + rustc_middle::ty::GenericClauses<'_>, rustc_middle::ty::ImplTraitHeader<'_>, rustc_middle::ty::ParamEnv<'_>, rustc_middle::ty::SymbolName<'_>, diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index 58a8eeeb242c0..4126531229b48 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -204,12 +204,12 @@ pub enum ObligationCauseCode<'tcx> { /// Like `WhereClause`, but also identifies the expression /// which requires the `where` clause to be proven, and also - /// identifies the index of the predicate in the `predicates_of` + /// identifies the index of the clause in the `clauses_of` /// list of the item. WhereClauseInExpr(DefId, Span, HirId, usize), /// Like `WhereClauseinExpr`, but indexes into the `const_conditions` - /// rather than the `predicates_of`. + /// rather than the `clauses_of`. HostEffectInExpr(DefId, Span, HirId, usize), /// A type like `&'a T` is WF only if `T: 'a`. @@ -592,8 +592,8 @@ pub struct ImplDerivedCause<'tcx> { /// impl, then this will be the `DefId` of that trait alias. Care should therefore be taken to /// handle that exceptional case where appropriate. pub impl_or_alias_def_id: DefId, - /// The index of the derived predicate in the parent impl's predicates. - pub impl_def_predicate_index: Option, + /// The index of the derived clause in the parent impl's clauses. + pub impl_def_clause_index: Option, pub span: Span, } diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs index 09177b12ddced..bf8b650f4594e 100644 --- a/compiler/rustc_middle/src/ty/adt.rs +++ b/compiler/rustc_middle/src/ty/adt.rs @@ -23,7 +23,7 @@ use rustc_type_ir::solve::AdtDestructorKind; use tracing::{debug, info, trace}; use super::{ - AsyncDestructor, Destructor, FieldDef, GenericPredicates, Ty, TyCtxt, VariantDef, VariantDiscr, + AsyncDestructor, Destructor, FieldDef, GenericClauses, Ty, TyCtxt, VariantDef, VariantDiscr, }; use crate::mir::interpret::ErrorHandled; use crate::ty::util::{Discr, IntTypeExt}; @@ -562,8 +562,8 @@ impl<'tcx> AdtDef<'tcx> { } #[inline] - pub fn predicates(self, tcx: TyCtxt<'tcx>) -> GenericPredicates<'tcx> { - tcx.predicates_of(self.did()) + pub fn clauses(self, tcx: TyCtxt<'tcx>) -> GenericClauses<'tcx> { + tcx.clauses_of(self.did()) } /// Returns an iterator over all fields contained diff --git a/compiler/rustc_middle/src/ty/context/impl_interner.rs b/compiler/rustc_middle/src/ty/context/impl_interner.rs index 26bed229f4d5a..c43768b139e34 100644 --- a/compiler/rustc_middle/src/ty/context/impl_interner.rs +++ b/compiler/rustc_middle/src/ty/context/impl_interner.rs @@ -388,42 +388,42 @@ impl<'tcx> Interner for TyCtxt<'tcx> { self.item_non_self_bounds(def_id).map_bound(IntoIterator::into_iter) } - fn predicates_of( + fn clauses_of( self, def_id: DefId, ) -> ty::EarlyBinder<'tcx, impl IntoIterator>> { ty::EarlyBinder::bind_iter( - self.predicates_of(def_id) + self.clauses_of(def_id) .instantiate_identity(self) - .predicates + .clauses .into_iter() .map(Unnormalized::skip_normalization), ) } - fn own_predicates_of( + fn own_clauses_of( self, def_id: DefId, ) -> ty::EarlyBinder<'tcx, impl IntoIterator>> { ty::EarlyBinder::bind_iter( - self.predicates_of(def_id) + self.clauses_of(def_id) .instantiate_own_identity() .map(|(clause, _)| clause.skip_normalization()), ) } - fn explicit_super_predicates_of( + fn explicit_super_clauses_of( self, def_id: DefId, ) -> ty::EarlyBinder<'tcx, impl IntoIterator, Span)>> { - self.explicit_super_predicates_of(def_id).map_bound(|preds| preds.into_iter().copied()) + self.explicit_super_clauses_of(def_id).map_bound(|preds| preds.into_iter().copied()) } - fn explicit_implied_predicates_of( + fn explicit_implied_clauses_of( self, def_id: DefId, ) -> ty::EarlyBinder<'tcx, impl IntoIterator, Span)>> { - self.explicit_implied_predicates_of(def_id).map_bound(|preds| preds.into_iter().copied()) + self.explicit_implied_clauses_of(def_id).map_bound(|preds| preds.into_iter().copied()) } fn impl_super_outlives( diff --git a/compiler/rustc_middle/src/ty/generics.rs b/compiler/rustc_middle/src/ty/generics.rs index 9a6b3dbea1ef3..0599f51305575 100644 --- a/compiler/rustc_middle/src/ty/generics.rs +++ b/compiler/rustc_middle/src/ty/generics.rs @@ -8,7 +8,7 @@ use rustc_span::{Span, Symbol, kw}; use rustc_type_ir::{TypeSuperVisitable as _, TypeVisitable, TypeVisitor}; use tracing::instrument; -use super::{Clause, InstantiatedPredicates, ParamConst, ParamTy, Ty, TyCtxt, Unnormalized}; +use super::{Clause, InstantiatedClauses, ParamConst, ParamTy, Ty, TyCtxt, Unnormalized}; use crate::ty::region::RegionExt; use crate::ty::{self, ClauseKind, EarlyBinder, GenericArgsRef, Region, RegionKind, TyKind}; @@ -383,18 +383,18 @@ impl<'tcx> Generics { /// Bounds on generics. #[derive(Copy, Clone, Default, Debug, TyEncodable, TyDecodable, StableHash)] -pub struct GenericPredicates<'tcx> { +pub struct GenericClauses<'tcx> { pub parent: Option, - pub predicates: &'tcx [(Clause<'tcx>, Span)], + pub clauses: &'tcx [(Clause<'tcx>, Span)], } -impl<'tcx> GenericPredicates<'tcx> { +impl<'tcx> GenericClauses<'tcx> { pub fn instantiate( self, tcx: TyCtxt<'tcx>, args: GenericArgsRef<'tcx>, - ) -> InstantiatedPredicates<'tcx> { - let mut instantiated = InstantiatedPredicates::empty(); + ) -> InstantiatedClauses<'tcx> { + let mut instantiated = InstantiatedClauses::empty(); self.instantiate_into(tcx, &mut instantiated, args); instantiated } @@ -407,7 +407,7 @@ impl<'tcx> GenericPredicates<'tcx> { + DoubleEndedIterator + ExactSizeIterator + Clone { - EarlyBinder::bind_iter(self.predicates).iter_instantiated_copied(tcx, args).map(|u| { + EarlyBinder::bind_iter(self.clauses).iter_instantiated_copied(tcx, args).map(|u| { let (clause, span) = u.unzip(); (clause, span.skip_normalization()) }) @@ -419,7 +419,7 @@ impl<'tcx> GenericPredicates<'tcx> { + DoubleEndedIterator + ExactSizeIterator + Clone { - EarlyBinder::bind_iter(self.predicates).iter_identity_copied().map(|u| { + EarlyBinder::bind_iter(self.clauses).iter_identity_copied().map(|u| { let (clause, span) = u.unzip(); (clause, span.skip_normalization()) }) @@ -429,20 +429,20 @@ impl<'tcx> GenericPredicates<'tcx> { fn instantiate_into( self, tcx: TyCtxt<'tcx>, - instantiated: &mut InstantiatedPredicates<'tcx>, + instantiated: &mut InstantiatedClauses<'tcx>, args: GenericArgsRef<'tcx>, ) { if let Some(def_id) = self.parent { - tcx.predicates_of(def_id).instantiate_into(tcx, instantiated, args); + tcx.clauses_of(def_id).instantiate_into(tcx, instantiated, args); } - instantiated.predicates.extend( - self.predicates.iter().map(|(p, _)| EarlyBinder::bind(tcx, *p).instantiate(tcx, args)), + instantiated.clauses.extend( + self.clauses.iter().map(|(p, _)| EarlyBinder::bind(tcx, *p).instantiate(tcx, args)), ); - instantiated.spans.extend(self.predicates.iter().map(|(_, sp)| *sp)); + instantiated.spans.extend(self.clauses.iter().map(|(_, sp)| *sp)); } - pub fn instantiate_identity(self, tcx: TyCtxt<'tcx>) -> InstantiatedPredicates<'tcx> { - let mut instantiated = InstantiatedPredicates::empty(); + pub fn instantiate_identity(self, tcx: TyCtxt<'tcx>) -> InstantiatedClauses<'tcx> { + let mut instantiated = InstantiatedClauses::empty(); self.instantiate_identity_into(tcx, &mut instantiated); instantiated } @@ -450,13 +450,13 @@ impl<'tcx> GenericPredicates<'tcx> { fn instantiate_identity_into( self, tcx: TyCtxt<'tcx>, - instantiated: &mut InstantiatedPredicates<'tcx>, + instantiated: &mut InstantiatedClauses<'tcx>, ) { if let Some(def_id) = self.parent { - tcx.predicates_of(def_id).instantiate_identity_into(tcx, instantiated); + tcx.clauses_of(def_id).instantiate_identity_into(tcx, instantiated); } - instantiated.predicates.extend(self.predicates.iter().map(|(p, _)| Unnormalized::new(*p))); - instantiated.spans.extend(self.predicates.iter().map(|(_, s)| s)); + instantiated.clauses.extend(self.clauses.iter().map(|(p, _)| Unnormalized::new(*p))); + instantiated.spans.extend(self.clauses.iter().map(|(_, s)| s)); } /// Allow simple where bounds like `T: Debug`, but prevent any kind of @@ -501,7 +501,7 @@ impl<'tcx> GenericPredicates<'tcx> { // Pessimistic: if any of the parameters have where bounds // don't allow this impl to be used. - self.predicates.iter().all(|(clause, _)| { + self.clauses.iter().all(|(clause, _)| { match clause.kind().skip_binder() { ClauseKind::Trait(trait_predicate) => { // In a `T: Trait`, if the rhs bound does not contain any generic params @@ -531,7 +531,7 @@ impl<'tcx> GenericPredicates<'tcx> { } /// `[const]` bounds for a given item. This is represented using a struct much like -/// `GenericPredicates`, where you can either choose to only instantiate the "own" +/// `GenericClauses`, where you can either choose to only instantiate the "own" /// bounds or all of the bounds including those from the parent. This distinction /// is necessary for code like `compare_method_predicate_entailment`. #[derive(Copy, Clone, Default, Debug, TyEncodable, TyDecodable, StableHash)] diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 151ca10b85ef6..9bac570fb2db1 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -846,11 +846,11 @@ impl<'tcx> TermKind<'tcx> { /// Represents the bounds declared on a particular set of type /// parameters. Should eventually be generalized into a flag list of -/// where-clauses. You can obtain an `InstantiatedPredicates` list from a -/// `GenericPredicates` by using the `instantiate` method. Note that this method -/// reflects an important semantic invariant of `InstantiatedPredicates`: while -/// the `GenericPredicates` are expressed in terms of the bound type -/// parameters of the impl/trait/whatever, an `InstantiatedPredicates` instance +/// where-clauses. You can obtain an `InstantiatedClauses` list from a +/// `GenericClauses` by using the `instantiate` method. Note that this method +/// reflects an important semantic invariant of `InstantiatedClauses`: while +/// the `GenericClauses` are expressed in terms of the bound type +/// parameters of the impl/trait/whatever, an `InstantiatedClauses` instance /// represented a set of bounds for some particular instantiation, /// meaning that the generic parameters have been instantiated with /// their values. @@ -859,23 +859,23 @@ impl<'tcx> TermKind<'tcx> { /// ```ignore (illustrative) /// struct Foo> { ... } /// ``` -/// Here, the `GenericPredicates` for `Foo` would contain a list of bounds like +/// Here, the `GenericClauses` for `Foo` would contain a list of bounds like /// `[[], [U:Bar]]`. Now if there were some particular reference -/// like `Foo`, then the `InstantiatedPredicates` would be `[[], +/// like `Foo`, then the `InstantiatedClauses` would be `[[], /// [usize:Bar]]`. #[derive(Clone, Debug)] -pub struct InstantiatedPredicates<'tcx> { - pub predicates: Vec>>, +pub struct InstantiatedClauses<'tcx> { + pub clauses: Vec>>, pub spans: Vec, } -impl<'tcx> InstantiatedPredicates<'tcx> { - pub fn empty() -> InstantiatedPredicates<'tcx> { - InstantiatedPredicates { predicates: vec![], spans: vec![] } +impl<'tcx> InstantiatedClauses<'tcx> { + pub fn empty() -> InstantiatedClauses<'tcx> { + InstantiatedClauses { clauses: vec![], spans: vec![] } } pub fn is_empty(&self) -> bool { - self.predicates.is_empty() + self.clauses.is_empty() } pub fn iter(&self) -> <&Self as IntoIterator>::IntoIter { @@ -883,7 +883,7 @@ impl<'tcx> InstantiatedPredicates<'tcx> { } } -impl<'tcx> IntoIterator for InstantiatedPredicates<'tcx> { +impl<'tcx> IntoIterator for InstantiatedClauses<'tcx> { type Item = (Unnormalized<'tcx, Clause<'tcx>>, Span); type IntoIter = std::iter::Zip< @@ -892,12 +892,12 @@ impl<'tcx> IntoIterator for InstantiatedPredicates<'tcx> { >; fn into_iter(self) -> Self::IntoIter { - debug_assert_eq!(self.predicates.len(), self.spans.len()); - std::iter::zip(self.predicates, self.spans) + debug_assert_eq!(self.clauses.len(), self.spans.len()); + std::iter::zip(self.clauses, self.spans) } } -impl<'a, 'tcx> IntoIterator for &'a InstantiatedPredicates<'tcx> { +impl<'a, 'tcx> IntoIterator for &'a InstantiatedClauses<'tcx> { type Item = (Unnormalized<'tcx, Clause<'tcx>>, Span); type IntoIter = std::iter::Zip< @@ -906,8 +906,8 @@ impl<'a, 'tcx> IntoIterator for &'a InstantiatedPredicates<'tcx> { >; fn into_iter(self) -> Self::IntoIter { - debug_assert_eq!(self.predicates.len(), self.spans.len()); - std::iter::zip(self.predicates.iter().copied(), self.spans.iter().copied()) + debug_assert_eq!(self.clauses.len(), self.spans.len()); + std::iter::zip(self.clauses.iter().copied(), self.spans.iter().copied()) } } diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 3614a67b71045..2ea99496c9949 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -869,9 +869,9 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { ty::Placeholder(placeholder) => placeholder.print(self)?, ty::Alias(_, ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) => { // We use verbose printing in 'NO_QUERIES' mode, to - // avoid needing to call `predicates_of`. This should + // avoid needing to call `clauses_of`. This should // only affect certain debug messages (e.g. messages printed - // from `rustc_middle::ty` during the computation of `tcx.predicates_of`), + // from `rustc_middle::ty` during the computation of `tcx.clauses_of`), // and should have no effect on any compiler output. // [Unless `-Zverbose-internals` is used, e.g. in the output of // `tests/ui/nll/ty-outlives/impl-trait-captures.rs`, for diff --git a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs index a2148b1b8e9e3..259b4b813f6a1 100644 --- a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs +++ b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs @@ -241,10 +241,10 @@ pub(crate) fn coroutine_by_move_body_def_id<'tcx>( body_def.coroutine_kind(tcx.coroutine_kind(coroutine_def_id)); body_def.def_ident_span(tcx.def_ident_span(coroutine_def_id)); body_def.def_span(tcx.def_span(coroutine_def_id)); - body_def.explicit_predicates_of(tcx.explicit_predicates_of(coroutine_def_id)); + body_def.explicit_clauses_of(tcx.explicit_clauses_of(coroutine_def_id)); body_def.generics_of(tcx.generics_of(coroutine_def_id).clone()); body_def.param_env(tcx.param_env(coroutine_def_id)); - body_def.explicit_predicates_of(tcx.explicit_predicates_of(coroutine_def_id)); + body_def.explicit_clauses_of(tcx.explicit_clauses_of(coroutine_def_id)); // The type of the coroutine is the `by_move_coroutine_ty`. body_def.type_of(ty::EarlyBinder::bind(tcx, by_move_coroutine_ty)); diff --git a/compiler/rustc_mir_transform/src/impossible_predicates.rs b/compiler/rustc_mir_transform/src/impossible_clauses.rs similarity index 73% rename from compiler/rustc_mir_transform/src/impossible_predicates.rs rename to compiler/rustc_mir_transform/src/impossible_clauses.rs index f255d424eb4c5..dbe4c9caf5036 100644 --- a/compiler/rustc_mir_transform/src/impossible_predicates.rs +++ b/compiler/rustc_mir_transform/src/impossible_clauses.rs @@ -47,7 +47,7 @@ fn is_structurally_unsized<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { } } -fn has_structurally_impossible_sized_predicate<'tcx>( +fn has_structurally_impossible_sized_clause<'tcx>( tcx: TyCtxt<'tcx>, sized_trait: DefId, predicate: ty::Clause<'tcx>, @@ -62,44 +62,47 @@ fn has_structurally_impossible_sized_predicate<'tcx>( && is_structurally_unsized(tcx, trait_predicate.self_ty()) } -pub(crate) struct ImpossiblePredicates; +pub(crate) struct ImpossibleClauses; -pub(crate) fn has_impossible_predicates<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool { - let predicates = tcx.predicates_of(def_id).instantiate_identity(tcx); - tracing::trace!(?predicates); +pub(crate) fn has_impossible_clauses<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool { + let clauses = tcx.clauses_of(def_id).instantiate_identity(tcx); + tracing::trace!(?clauses); - // Some `Sized` predicates that mention local generics are still impossible + // Some `Sized` clauses that mention local generics are still impossible // for every instantiation, e.g. `dyn Trait: Sized`. if let Some(sized_trait) = tcx.lang_items().sized_trait() { - if predicates.predicates.iter().copied().map(Unnormalized::skip_norm_wip).any(|predicate| { - has_structurally_impossible_sized_predicate(tcx, sized_trait, predicate) - }) { + if clauses + .clauses + .iter() + .copied() + .map(Unnormalized::skip_norm_wip) + .any(|clause| has_structurally_impossible_sized_clause(tcx, sized_trait, clause)) + { return true; } } - let predicates = - predicates.predicates.into_iter().map(Unnormalized::skip_norm_wip).filter(|p| { - !p.has_type_flags( - // Only consider global clauses to simplify. - TypeFlags::HAS_FREE_LOCAL_NAMES + let clauses = clauses.clauses.into_iter().map(Unnormalized::skip_norm_wip).filter(|c| { + !c.has_type_flags( + // Only consider global clauses to simplify. + TypeFlags::HAS_FREE_LOCAL_NAMES // Clauses that refer to alias constants as they cause cycles. | TypeFlags::HAS_CONST_ALIAS, - ) - }); - let predicates: Vec<_> = traits::elaborate(tcx, predicates).collect(); - tracing::trace!(?predicates); - predicates.references_error() || traits::impossible_predicates(tcx, predicates) + ) + }); + let clauses: Vec<_> = traits::elaborate(tcx, clauses).collect(); + tracing::trace!(?clauses); + clauses.references_error() || traits::impossible_clauses(tcx, clauses) } -impl<'tcx> MirPass<'tcx> for ImpossiblePredicates { +impl<'tcx> MirPass<'tcx> for ImpossibleClauses { #[tracing::instrument(level = "trace", skip(self, tcx, body))] fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { tracing::trace!(def_id = ?body.source.def_id()); - let impossible = body.tainted_by_errors.is_some() - || has_impossible_predicates(tcx, body.source.def_id()); + let impossible = + body.tainted_by_errors.is_some() || has_impossible_clauses(tcx, body.source.def_id()); if impossible { - trace!("found unsatisfiable predicates"); + trace!("found unsatisfiable clauses"); // Clear the body to only contain a single `unreachable` statement. let bbs = body.basic_blocks.as_mut(); bbs.raw.truncate(1); diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 905907aa279ea..b6aacb882b98f 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -154,7 +154,7 @@ declare_passes! { // Made public so that `mir_drops_elaborated_and_const_checked` can be overridden // by custom rustc drivers, running all the steps by themselves. See #114628. pub mod inline : Inline, ForceInline; - mod impossible_predicates : ImpossiblePredicates; + mod impossible_clauses : ImpossibleClauses; mod instsimplify : InstSimplify { BeforeInline, AfterSimplifyCfg }; mod jump_threading : JumpThreading; mod known_panics_lint : KnownPanicsLint; @@ -631,7 +631,7 @@ pub fn run_analysis_to_runtime_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<' /// After this series of passes, no lifetime analysis based on borrowing can be done. fn run_analysis_cleanup_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { let passes: &[&dyn MirPass<'tcx>] = &[ - &impossible_predicates::ImpossiblePredicates, + &impossible_clauses::ImpossibleClauses, &cleanup_post_borrowck::CleanupPostBorrowck, &remove_noop_landing_pads::RemoveNoopLandingPads, &simplify::SimplifyCfg::PostAnalysis, diff --git a/compiler/rustc_mir_transform/src/trivial_const.rs b/compiler/rustc_mir_transform/src/trivial_const.rs index e517d29d19320..9fb070750fd04 100644 --- a/compiler/rustc_mir_transform/src/trivial_const.rs +++ b/compiler/rustc_mir_transform/src/trivial_const.rs @@ -58,11 +58,11 @@ where _ => return None, } - // If there are impossible predicates then MIR passes will replace the body with + // If there are impossible clauses then MIR passes will replace the body with // `unreachable` causing const eval errors when trying to evaluate the body. For // now we avoid using trivial consts for such bodies so that the behaviour doesn't // change. - if crate::impossible_predicates::has_impossible_predicates(tcx, def.into()) { + if crate::impossible_clauses::has_impossible_clauses(tcx, def.into()) { return None; } diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 68d6c01f15e92..fae1ee7256683 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -1548,7 +1548,7 @@ impl<'v> RootCollector<'_, 'v> { // This type is impossible to instantiate, so we should not try to // generate a `drop_glue` instance for it. - if self.tcx.instantiate_and_check_impossible_predicates(( + if self.tcx.instantiate_and_check_impossible_clauses(( id.owner_id.to_def_id(), id_args, )) { @@ -1800,8 +1800,8 @@ fn create_mono_items_for_default_impls<'tcx>( // Even though this impl has no type or const generic parameters, because we don't // consider higher-ranked predicates such as `for<'a> &'a mut [u8]: Copy` to // be trivially false. We must now check that the impl has no impossible-to-satisfy - // predicates. - if tcx.instantiate_and_check_impossible_predicates((item.owner_id.to_def_id(), impl_args)) { + // clauses. + if tcx.instantiate_and_check_impossible_clauses((item.owner_id.to_def_id(), impl_args)) { return; } diff --git a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs index 406e5a172c96d..ae78d68865de3 100644 --- a/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs +++ b/compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs @@ -908,7 +908,7 @@ where // make impls coinductive always, since they'll always need to prove their supertraits. requirements.extend(elaborate::elaborate( cx, - cx.explicit_super_predicates_of(trait_ref.def_id) + cx.explicit_super_clauses_of(trait_ref.def_id) .iter_instantiated(cx, trait_ref.args) .map(Unnormalized::skip_norm_wip) .map(|(pred, _)| pred), diff --git a/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs b/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs index df9758d5d2ab7..c6dd456e3e39a 100644 --- a/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs +++ b/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs @@ -172,10 +172,10 @@ where ecx.eq(goal.param_env, goal.predicate.trait_ref, impl_trait_ref)?; let where_clause_bounds = cx - .predicates_of(impl_def_id.into()) + .clauses_of(impl_def_id.into()) .iter_instantiated(cx, impl_args) .map(Unnormalized::skip_norm_wip) - .map(|pred| goal.with(cx, pred)); + .map(|clause| goal.with(cx, clause)); ecx.add_goals(GoalSource::ImplWhereBound, where_clause_bounds)?; // For this impl to be `const`, we need to check its `[const]` bounds too. @@ -221,10 +221,10 @@ where ecx.probe_builtin_trait_candidate(BuiltinImplSource::Misc).enter(|ecx| { let where_clause_bounds = cx - .predicates_of(goal.predicate.def_id().into()) + .clauses_of(goal.predicate.def_id().into()) .iter_instantiated(cx, goal.predicate.trait_ref.args) .map(Unnormalized::skip_norm_wip) - .map(|p| goal.with(cx, p)); + .map(|c| goal.with(cx, c)); let const_conditions = cx .const_conditions(goal.predicate.def_id().into()) diff --git a/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs b/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs index 069102f3db50b..a6a25766d6591 100644 --- a/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs +++ b/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs @@ -219,10 +219,10 @@ where // FIXME: We don't need these, since these are the type's own WF obligations. ecx.add_goals( GoalSource::AliasWellFormed, - cx.own_predicates_of(goal.predicate.alias.expect_projection_def_id().into()) + cx.own_clauses_of(goal.predicate.alias.expect_projection_def_id().into()) .iter_instantiated(cx, goal.predicate.alias.args) .map(Unnormalized::skip_norm_wip) - .map(|pred| goal.with(cx, pred)), + .map(|clause| goal.with(cx, clause)), )?; then(ecx) @@ -285,10 +285,10 @@ where ecx.eq(goal.param_env, goal_trait_ref, impl_trait_ref)?; let where_clause_bounds = cx - .predicates_of(impl_def_id.into()) + .clauses_of(impl_def_id.into()) .iter_instantiated(cx, impl_args) .map(Unnormalized::skip_norm_wip) - .map(|pred| goal.with(cx, pred)); + .map(|clause| goal.with(cx, clause)); ecx.add_goals(GoalSource::ImplWhereBound, where_clause_bounds)?; // Bail if the nested goals don't hold here. This is to avoid unnecessarily @@ -302,10 +302,10 @@ where // see tests/ui/generic-associated-types/must-prove-where-clauses-on-norm.rs. ecx.add_goals( GoalSource::AliasWellFormed, - cx.own_predicates_of(alias_def_id.into()) + cx.own_clauses_of(alias_def_id.into()) .iter_instantiated(cx, goal.predicate.alias.args) .map(Unnormalized::skip_norm_wip) - .map(|pred| goal.with(cx, pred)), + .map(|clause| goal.with(cx, clause)), )?; let error_response = |ecx: &mut EvalCtxt<'_, D>, guar| { @@ -1119,10 +1119,10 @@ where // target impl's params. self.add_goals( GoalSource::Misc, - cx.predicates_of(target_container_def_id) + cx.clauses_of(target_container_def_id) .iter_instantiated(cx, target_args) .map(Unnormalized::skip_norm_wip) - .map(|pred| goal.with(cx, pred)), + .map(|clause| goal.with(cx, clause)), )?; goal.predicate.alias.args.rebase_onto(cx, impl_trait_ref.def_id.into(), target_args) }) diff --git a/compiler/rustc_next_trait_solver/src/solve/project_goals/free_alias.rs b/compiler/rustc_next_trait_solver/src/solve/project_goals/free_alias.rs index c1867a224ac84..7f5d258ccc706 100644 --- a/compiler/rustc_next_trait_solver/src/solve/project_goals/free_alias.rs +++ b/compiler/rustc_next_trait_solver/src/solve/project_goals/free_alias.rs @@ -25,10 +25,10 @@ where // Check where clauses self.add_goals( GoalSource::Misc, - cx.predicates_of(free_alias.expect_free_def_id().into()) + cx.clauses_of(free_alias.expect_free_def_id().into()) .iter_instantiated(cx, free_alias.args) .map(Unnormalized::skip_norm_wip) - .map(|pred| goal.with(cx, pred)), + .map(|clause| goal.with(cx, clause)), )?; let actual = match free_alias.kind { diff --git a/compiler/rustc_next_trait_solver/src/solve/project_goals/inherent.rs b/compiler/rustc_next_trait_solver/src/solve/project_goals/inherent.rs index f2cd91574d641..afdc0c20a7132 100644 --- a/compiler/rustc_next_trait_solver/src/solve/project_goals/inherent.rs +++ b/compiler/rustc_next_trait_solver/src/solve/project_goals/inherent.rs @@ -47,10 +47,10 @@ where // to be very careful when changing the impl where-clauses to be productive. self.add_goals( GoalSource::Misc, - cx.predicates_of(def_id.into()) + cx.clauses_of(def_id.into()) .iter_instantiated(cx, inherent_args) .map(Unnormalized::skip_norm_wip) - .map(|pred| goal.with(cx, pred)), + .map(|clause| goal.with(cx, clause)), )?; let normalized: I::Term = match inherent.kind { diff --git a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs index f29df578cd97b..ba5a809df5b0f 100644 --- a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs +++ b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs @@ -111,10 +111,10 @@ where ecx.eq(goal.param_env, goal.predicate.trait_ref, impl_trait_ref)?; let where_clause_bounds = cx - .predicates_of(impl_def_id.into()) + .clauses_of(impl_def_id.into()) .iter_instantiated(cx, impl_args) .map(Unnormalized::skip_norm_wip) - .map(|pred| goal.with(cx, pred)); + .map(|clause| goal.with(cx, clause)); ecx.add_goals(GoalSource::ImplWhereBound, where_clause_bounds)?; // We currently elaborate all supertrait outlives obligations from impls. @@ -287,10 +287,10 @@ where ecx.probe_builtin_trait_candidate(BuiltinImplSource::Misc).enter(|ecx| { let nested_obligations = cx - .predicates_of(goal.predicate.def_id().into()) + .clauses_of(goal.predicate.def_id().into()) .iter_instantiated(cx, goal.predicate.trait_ref.args) .map(Unnormalized::skip_norm_wip) - .map(|p| goal.with(cx, p)); + .map(|c| goal.with(cx, c)); // While you could think of trait aliases to have a single builtin impl // which uses its implied trait bounds as where-clauses, using // `GoalSource::ImplWhereClause` here would be incorrect, as we also diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 29ee27bc102f9..96fb0c81a92d6 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -87,8 +87,8 @@ pub trait DefIdVisitor<'tcx> { fn visit_trait(&mut self, trait_ref: TraitRef<'tcx>) -> Self::Result { self.skeleton().visit_trait(trait_ref) } - fn visit_predicates(&mut self, predicates: ty::GenericPredicates<'tcx>) -> Self::Result { - self.skeleton().visit_clauses(predicates.predicates) + fn visit_gen_clauses(&mut self, gen_clauses: ty::GenericClauses<'tcx>) -> Self::Result { + self.skeleton().visit_clauses(gen_clauses.clauses) } fn visit_clauses(&mut self, clauses: &[(ty::Clause<'tcx>, Span)]) -> Self::Result { self.skeleton().visit_clauses(clauses) @@ -563,7 +563,7 @@ impl<'tcx> EmbargoVisitor<'tcx> { let def_id = item.def_id.expect_local(); let tcx = self.tcx; let mut reach = self.reach(def_id, item_ev); - reach.generics().predicates(); + reach.generics().clauses(); if assoc_has_type_of(tcx, item) { reach.ty(); } @@ -590,12 +590,12 @@ impl<'tcx> EmbargoVisitor<'tcx> { | DefKind::Fn | DefKind::TyAlias => { if let Some(item_ev) = item_ev { - self.reach(def_id, item_ev).generics().predicates().ty(); + self.reach(def_id, item_ev).generics().clauses().ty(); } } DefKind::Trait => { if let Some(item_ev) = item_ev { - self.reach(def_id, item_ev).generics().predicates(); + self.reach(def_id, item_ev).generics().clauses(); for assoc_item in self.tcx.associated_items(def_id).in_definition_order() { let def_id = assoc_item.def_id.expect_local(); @@ -607,7 +607,7 @@ impl<'tcx> EmbargoVisitor<'tcx> { } DefKind::TraitAlias => { if let Some(item_ev) = item_ev { - self.reach(def_id, item_ev).generics().predicates(); + self.reach(def_id, item_ev).generics().clauses(); } } DefKind::Impl { of_trait } => { @@ -632,7 +632,7 @@ impl<'tcx> EmbargoVisitor<'tcx> { { let mut reach = self.reach(def_id, item_ev); - reach.generics().predicates().ty(); + reach.generics().clauses().ty(); if of_trait { reach.trait_ref(); } @@ -651,7 +651,7 @@ impl<'tcx> EmbargoVisitor<'tcx> { } DefKind::Enum => { if let Some(item_ev) = item_ev { - self.reach(def_id, item_ev).generics().predicates(); + self.reach(def_id, item_ev).generics().clauses(); } let def = self.tcx.adt_def(def_id); for variant in def.variants() { @@ -683,7 +683,7 @@ impl<'tcx> EmbargoVisitor<'tcx> { DefKind::Struct | DefKind::Union => { let def = self.tcx.adt_def(def_id).non_enum_variant(); if let Some(item_ev) = item_ev { - self.reach(def_id, item_ev).generics().predicates(); + self.reach(def_id, item_ev).generics().clauses(); for field in &def.fields { let field = field.did.expect_local(); self.update(field, item_ev, Level::Reachable); @@ -740,8 +740,8 @@ impl ReachEverythingInTheInterfaceVisitor<'_, '_> { self } - fn predicates(&mut self) -> &mut Self { - self.visit_predicates(self.ev.tcx.explicit_predicates_of(self.item_def_id)); + fn clauses(&mut self) -> &mut Self { + self.visit_gen_clauses(self.ev.tcx.explicit_clauses_of(self.item_def_id)); self } @@ -1377,15 +1377,15 @@ impl SearchInterfaceForPrivateItemsVisitor<'_> { self } - fn predicates(&mut self) -> &mut Self { + fn clauses(&mut self) -> &mut Self { self.in_primary_interface = false; - // N.B., we use `explicit_predicates_of` and not `predicates_of` + // N.B., we use `explicit_clauses_of` and not `clauses_of` // because we don't want to report privacy errors due to where // clauses that the compiler inferred. We only want to // consider the ones that the user wrote. This is important // for the inferred outlives rules; see // `tests/ui/rfc-2093-infer-outlives/privacy.rs`. - let _ = self.visit_predicates(self.tcx.explicit_predicates_of(self.item_def_id)); + let _ = self.visit_gen_clauses(self.tcx.explicit_clauses_of(self.item_def_id)); self } @@ -1584,7 +1584,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> { let is_assoc_ty = item.is_type(); check.hard_error = is_assoc_ty; - check.generics().predicates(); + check.generics().clauses(); if assoc_has_type_of(self.tcx, item) { check.ty(); } @@ -1612,7 +1612,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> { if let DefKind::TyAlias = def_kind { self.check_unnameable(def_id, effective_vis); } - self.check(def_id, item_visibility, effective_vis).generics().predicates().ty(); + self.check(def_id, item_visibility, effective_vis).generics().clauses().ty(); } DefKind::OpaqueTy => { // `ty()` for opaque types is the underlying type, @@ -1622,18 +1622,18 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> { DefKind::Trait => { self.check_unnameable(def_id, effective_vis); - self.check(def_id, item_visibility, effective_vis).generics().predicates(); + self.check(def_id, item_visibility, effective_vis).generics().clauses(); for assoc_item in tcx.associated_items(id.owner_id).in_definition_order() { self.check_assoc_item(assoc_item, item_visibility, effective_vis); } } DefKind::TraitAlias => { - self.check(def_id, item_visibility, effective_vis).generics().predicates(); + self.check(def_id, item_visibility, effective_vis).generics().clauses(); } DefKind::Enum => { self.check_unnameable(def_id, effective_vis); - self.check(def_id, item_visibility, effective_vis).generics().predicates(); + self.check(def_id, item_visibility, effective_vis).generics().clauses(); let adt = tcx.adt_def(id.owner_id); for field in adt.all_fields() { @@ -1643,7 +1643,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> { // Subitems of structs and unions have their own publicity. DefKind::Struct | DefKind::Union => { self.check_unnameable(def_id, effective_vis); - self.check(def_id, item_visibility, effective_vis).generics().predicates(); + self.check(def_id, item_visibility, effective_vis).generics().clauses(); let adt = tcx.adt_def(id.owner_id); for field in adt.all_fields() { @@ -1683,10 +1683,10 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> { let mut check = self.check(def_id, impl_vis, Some(impl_ev)); - // Generics and predicates of trait impls are intentionally not checked + // Generics and clauses of trait impls are intentionally not checked // for private components (#90586). if !of_trait { - check.generics().predicates(); + check.generics().clauses(); } // Skip checking private components in associated types, due to lack of full @@ -1729,7 +1729,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'_, 'tcx> { self.check_unnameable(def_id, effective_vis); } - self.check(def_id, item_visibility, effective_vis).generics().predicates().ty(); + self.check(def_id, item_visibility, effective_vis).generics().clauses().ty(); } } @@ -1825,11 +1825,7 @@ fn effective_visibilities(tcx: TyCtxt<'_>, (): ()) -> &EffectiveVisibilities { // in the reachability pass (`middle/reachable.rs`). Types are marked as link-time // reachable if they are returned via `impl Trait`, even from private functions. let pub_ev = EffectiveVisibility::from_vis(ty::Visibility::Public); - visitor - .reach_through_impl_trait(opaque.def_id, pub_ev) - .generics() - .predicates() - .ty(); + visitor.reach_through_impl_trait(opaque.def_id, pub_ev).generics().clauses().ty(); } } diff --git a/compiler/rustc_public/src/compiler_interface.rs b/compiler/rustc_public/src/compiler_interface.rs index 7abc07505d1fc..f11a592029367 100644 --- a/compiler/rustc_public/src/compiler_interface.rs +++ b/compiler/rustc_public/src/compiler_interface.rs @@ -19,7 +19,7 @@ use crate::target::{MachineInfo, MachineSize}; use crate::ty::{ AdtDef, AdtKind, Allocation, AssocItem, Asyncness, ClosureDef, ClosureKind, Constness, CoroutineDef, Discr, FieldDef, FloatTy, FnDef, ForeignDef, ForeignItemKind, ForeignModule, - ForeignModuleDef, GenericArgs, GenericPredicates, Generics, ImplDef, ImplTrait, IntrinsicDef, + ForeignModuleDef, GenericArgs, GenericClauses, Generics, ImplDef, ImplTrait, IntrinsicDef, LineInfo, MirConst, PolyFnSig, RigidTy, Span, TraitDecl, TraitDef, TraitRef, Ty, TyConst, TyConstId, TyKind, UintTy, VariantDef, VariantIdx, VtblEntry, }; @@ -218,13 +218,13 @@ impl<'tcx> CompilerInterface<'tcx> { }) } - pub(crate) fn predicates_of(&self, def_id: DefId) -> GenericPredicates { + pub(crate) fn clauses_of(&self, def_id: DefId) -> GenericClauses { self.with_cx(|tables, cx| { let did = tables[def_id]; - let (parent, kinds) = cx.predicates_of(did); - crate::ty::GenericPredicates { + let (parent, kinds) = cx.clauses_of(did); + crate::ty::GenericClauses { parent: parent.map(|did| tables.trait_def(did)), - predicates: kinds + clauses: kinds .iter() .map(|(kind, span)| (kind.stable(tables, cx), span.stable(tables, cx))) .collect(), @@ -232,13 +232,13 @@ impl<'tcx> CompilerInterface<'tcx> { }) } - pub(crate) fn explicit_predicates_of(&self, def_id: DefId) -> GenericPredicates { + pub(crate) fn explicit_clauses_of(&self, def_id: DefId) -> GenericClauses { self.with_cx(|tables, cx| { let did = tables[def_id]; - let (parent, kinds) = cx.explicit_predicates_of(did); - crate::ty::GenericPredicates { + let (parent, kinds) = cx.explicit_clauses_of(did); + crate::ty::GenericClauses { parent: parent.map(|did| tables.trait_def(did)), - predicates: kinds + clauses: kinds .iter() .map(|(kind, span)| (kind.stable(tables, cx), span.stable(tables, cx))) .collect(), diff --git a/compiler/rustc_public/src/ty.rs b/compiler/rustc_public/src/ty.rs index e9f2ff9a8bb3f..68fd152921cf7 100644 --- a/compiler/rustc_public/src/ty.rs +++ b/compiler/rustc_public/src/ty.rs @@ -1466,12 +1466,12 @@ impl TraitDecl { with(|cx| cx.generics_of(self.def_id.0)) } - pub fn predicates_of(&self) -> GenericPredicates { - with(|cx| cx.predicates_of(self.def_id.0)) + pub fn clauses_of(&self) -> GenericClauses { + with(|cx| cx.clauses_of(self.def_id.0)) } - pub fn explicit_predicates_of(&self) -> GenericPredicates { - with(|cx| cx.explicit_predicates_of(self.def_id.0)) + pub fn explicit_clauses_of(&self) -> GenericClauses { + with(|cx| cx.explicit_clauses_of(self.def_id.0)) } } @@ -1550,9 +1550,9 @@ pub struct GenericParamDef { pub kind: GenericParamDefKind, } -pub struct GenericPredicates { +pub struct GenericClauses { pub parent: Option, - pub predicates: Vec<(PredicateKind, Span)>, + pub clauses: Vec<(ClauseKind, Span)>, } #[derive(Clone, Debug, Eq, PartialEq, Serialize)] diff --git a/compiler/rustc_public_bridge/src/context/impls.rs b/compiler/rustc_public_bridge/src/context/impls.rs index 6b12da9d9c4ed..4a2fbb8f8b7af 100644 --- a/compiler/rustc_public_bridge/src/context/impls.rs +++ b/compiler/rustc_public_bridge/src/context/impls.rs @@ -214,31 +214,22 @@ impl<'tcx, B: Bridge> CompilerCtxt<'tcx, B> { self.tcx.generics_of(def_id) } - pub fn predicates_of( - &self, - def_id: DefId, - ) -> (Option, Vec<(ty::PredicateKind<'tcx>, Span)>) { - let ty::GenericPredicates { parent, predicates } = self.tcx.predicates_of(def_id); + pub fn clauses_of(&self, def_id: DefId) -> (Option, Vec<(ty::ClauseKind<'tcx>, Span)>) { + let ty::GenericClauses { parent, clauses } = self.tcx.clauses_of(def_id); ( parent, - predicates - .iter() - .map(|(clause, span)| (clause.as_predicate().kind().skip_binder(), *span)) - .collect(), + clauses.iter().map(|(clause, span)| (clause.kind().skip_binder(), *span)).collect(), ) } - pub fn explicit_predicates_of( + pub fn explicit_clauses_of( &self, def_id: DefId, - ) -> (Option, Vec<(ty::PredicateKind<'tcx>, Span)>) { - let ty::GenericPredicates { parent, predicates } = self.tcx.explicit_predicates_of(def_id); + ) -> (Option, Vec<(ty::ClauseKind<'tcx>, Span)>) { + let ty::GenericClauses { parent, clauses } = self.tcx.explicit_clauses_of(def_id); ( parent, - predicates - .iter() - .map(|(clause, span)| (clause.as_predicate().kind().skip_binder(), *span)) - .collect(), + clauses.iter().map(|(clause, span)| (clause.kind().skip_binder(), *span)).collect(), ) } diff --git a/compiler/rustc_query_impl/src/job.rs b/compiler/rustc_query_impl/src/job.rs index 5760f05c4a367..4922a17253c45 100644 --- a/compiler/rustc_query_impl/src/job.rs +++ b/compiler/rustc_query_impl/src/job.rs @@ -450,10 +450,10 @@ pub(crate) fn create_cycle_error<'tcx>( let is_all_def_kind = |def_kind| { // Trivial type alias and trait alias cycles consists of `type_of` and - // `explicit_implied_predicates_of` queries, so we just check just these here. + // `explicit_implied_clauses_of` queries, so we just check just these here. frames.iter().all(|frame| match frame.tagged_key { TaggedQueryKey::type_of(def_id) - | TaggedQueryKey::explicit_implied_predicates_of(def_id) + | TaggedQueryKey::explicit_implied_clauses_of(def_id) if tcx.def_kind(def_id) == def_kind => { true diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs index 2c959acbc2a86..e951ac7237e5f 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs @@ -450,7 +450,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { && let Some(def_id) = preds.principal_def_id() { for (clause, span) in - self.tcx.predicates_of(def_id).instantiate_identity(self.tcx).into_iter() + self.tcx.clauses_of(def_id).instantiate_identity(self.tcx).into_iter() { if let ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(a, b)) = clause.kind().skip_binder() @@ -610,11 +610,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let Ok(trait_predicates) = self .tcx - .explicit_predicates_of(trait_item_def_id) + .explicit_clauses_of(trait_item_def_id) .instantiate_own(self.tcx, trait_item_args) - .map(|(pred, _)| { - let pred = pred.skip_norm_wip(); - if pred.is_suggestable(self.tcx, false) { Ok(pred.to_string()) } else { Err(()) } + .map(|(clause, _)| { + let clause = clause.skip_norm_wip(); + if clause.is_suggestable(self.tcx, false) { + Ok(clause.to_string()) + } else { + Err(()) + } }) .collect::, ()>>() else { diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs index 5e2e9f67103dd..95c42b34499b6 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs @@ -74,15 +74,15 @@ pub fn compute_applicable_impls_for_diagnostics<'tcx>( if !ignore_predicates_of_impls { let obligations = tcx - .predicates_of(impl_def_id) + .clauses_of(impl_def_id) .instantiate(tcx, impl_args) .into_iter() - .map(|(predicate, _)| { + .map(|(clause, _)| { Obligation::new( tcx, ObligationCause::dummy(), param_env, - predicate.skip_norm_wip(), + clause.skip_norm_wip(), ) }) // Kinda hacky, but let's just throw away obligations that overflow. @@ -147,15 +147,15 @@ pub fn compute_applicable_impls_for_diagnostics<'tcx>( // If our `body_def_id` has been set (and isn't just from a dummy obligation cause), // then try to look for a param-env clause that would apply. The way we compute // this is somewhat manual, since we need the spans, so we elaborate this directly - // from `predicates_of` rather than actually looking at the param-env which + // from `clauses_of` rather than actually looking at the param-env which // otherwise would be more appropriate. let body_def_id = obligation.cause.body_def_id; if body_def_id != CRATE_DEF_ID { - let predicates = tcx.predicates_of(body_def_id.to_def_id()).instantiate_identity(tcx); - for (pred, span) in - elaborate(tcx, predicates.into_iter().map(|(c, s)| (c.skip_norm_wip(), s))) + let clauses = tcx.clauses_of(body_def_id.to_def_id()).instantiate_identity(tcx); + for (clause, span) in + elaborate(tcx, clauses.into_iter().map(|(c, s)| (c.skip_norm_wip(), s))) { - let kind = pred.kind(); + let kind = clause.kind(); if let ty::ClauseKind::Trait(trait_pred) = kind.skip_binder() && param_env_candidate_may_apply(kind.rebind(trait_pred)) { diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 5f456edb8d7f6..81f19529418a5 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -2155,7 +2155,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ocx.register_obligations( self.tcx - .predicates_of(single.impl_def_id) + .clauses_of(single.impl_def_id) .instantiate(self.tcx, impl_args) .into_iter() .map(|(clause, _)| { @@ -2357,7 +2357,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } ocx.register_obligations( self.tcx - .predicates_of(def_id) + .clauses_of(def_id) .instantiate(self.tcx, impl_args) .into_iter() .map(|(clause, span)| { @@ -2373,7 +2373,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { }) }; let failing_obligations = - if !self.tcx.predicates_of(def_id).predicates.is_empty() { + if !self.tcx.clauses_of(def_id).clauses.is_empty() { self.probe(|_| evaluate_obligations()) } else { Vec::new() diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs index b50ace11bbd75..b072c6d3565eb 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs @@ -489,15 +489,15 @@ pub(crate) fn to_pretty_impl_header(tcx: TyCtxt<'_>, impl_def_id: DefId) -> Opti ) .unwrap(); - let predicates = tcx.predicates_of(impl_def_id).predicates; - let mut pretty_predicates = Vec::with_capacity(predicates.len()); + let clauses = tcx.clauses_of(impl_def_id).clauses; + let mut pretty_clauses = Vec::with_capacity(clauses.len()); let sized_trait = tcx.lang_items().sized_trait(); let meta_sized_trait = tcx.lang_items().meta_sized_trait(); - for (p, _) in predicates { + for (c, _) in clauses { // Accumulate the sizedness bounds for each self ty. - if let Some(trait_clause) = p.as_trait_clause() { + if let Some(trait_clause) = c.as_trait_clause() { let self_ty = trait_clause.self_ty().skip_binder(); let sizedness_of = types_with_sizedness_bounds.entry(self_ty).or_default(); if Some(trait_clause.def_id()) == sized_trait { @@ -509,7 +509,7 @@ pub(crate) fn to_pretty_impl_header(tcx: TyCtxt<'_>, impl_def_id: DefId) -> Opti } } - pretty_predicates.push(p.to_string()); + pretty_clauses.push(c.to_string()); } for (ty, sizedness) in types_with_sizedness_bounds { @@ -517,22 +517,22 @@ pub(crate) fn to_pretty_impl_header(tcx: TyCtxt<'_>, impl_def_id: DefId) -> Opti if sizedness.sized { // Maybe a default bound, don't write anything. } else { - pretty_predicates.push(format!("{ty}: ?Sized")); + pretty_clauses.push(format!("{ty}: ?Sized")); } } else { if sizedness.sized { // Maybe a default bound, don't write anything. - pretty_predicates.push(format!("{ty}: Sized")); + pretty_clauses.push(format!("{ty}: Sized")); } else if sizedness.meta_sized { - pretty_predicates.push(format!("{ty}: MetaSized")); + pretty_clauses.push(format!("{ty}: MetaSized")); } else { - pretty_predicates.push(format!("{ty}: PointeeSized")); + pretty_clauses.push(format!("{ty}: PointeeSized")); } } } - if !pretty_predicates.is_empty() { - write!(w, "\n where {}", pretty_predicates.join(", ")).unwrap(); + if !pretty_clauses.is_empty() { + write!(w, "\n where {}", pretty_clauses.join(", ")).unwrap(); } w.push(';'); diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index b4f55e27048e2..8c72f0d90bb58 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -2875,49 +2875,50 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { cause: &ObligationCauseCode<'tcx>, err: &mut Diag<'_>, ) { - // First, look for an `WhereClauseInExpr`, which means we can get + // First, look for a `WhereClauseInExpr`, which means we can get // the uninstantiated predicate list of the called function. And check // that the predicate that we failed to satisfy is a `Fn`-like trait. if let ObligationCauseCode::WhereClauseInExpr(def_id, _, _, idx) = *cause - && let predicates = self.tcx.predicates_of(def_id).instantiate_identity(self.tcx) - && let Some(pred) = predicates.predicates.get(idx).map(|p| p.as_ref().skip_norm_wip()) - && let ty::ClauseKind::Trait(trait_pred) = pred.kind().skip_binder() + && let gen_clauses = self.tcx.clauses_of(def_id).instantiate_identity(self.tcx) + && let Some(clause) = gen_clauses.clauses.get(idx).map(|c| c.as_ref().skip_norm_wip()) + && let ty::ClauseKind::Trait(trait_pred) = clause.kind().skip_binder() && self.tcx.is_fn_trait(trait_pred.def_id()) { let expected_self = - self.tcx.anonymize_bound_vars(pred.kind().rebind(trait_pred.self_ty())); + self.tcx.anonymize_bound_vars(clause.kind().rebind(trait_pred.self_ty())); let expected_args = - self.tcx.anonymize_bound_vars(pred.kind().rebind(trait_pred.trait_ref.args)); + self.tcx.anonymize_bound_vars(clause.kind().rebind(trait_pred.trait_ref.args)); - // Find another predicate whose self-type is equal to the expected self type, + // Find another clause whose self-type is equal to the expected self type, // but whose args don't match. - let other_pred = predicates.into_iter().enumerate().find(|&(other_idx, (pred, _))| { - let pred = pred.skip_norm_wip(); - match pred.kind().skip_binder() { - ty::ClauseKind::Trait(trait_pred) - if self.tcx.is_fn_trait(trait_pred.def_id()) + let other_clause = + gen_clauses.into_iter().enumerate().find(|&(other_idx, (clause, _))| { + let clause = clause.skip_norm_wip(); + match clause.kind().skip_binder() { + ty::ClauseKind::Trait(trait_pred) + if self.tcx.is_fn_trait(trait_pred.def_id()) && other_idx != idx // Make sure that the self type matches // (i.e. constraining this closure) && expected_self == self.tcx.anonymize_bound_vars( - pred.kind().rebind(trait_pred.self_ty()), + clause.kind().rebind(trait_pred.self_ty()), ) // But the args don't match (i.e. incompatible args) && expected_args != self.tcx.anonymize_bound_vars( - pred.kind().rebind(trait_pred.trait_ref.args), + clause.kind().rebind(trait_pred.trait_ref.args), ) => - { - true + { + true + } + _ => false, } - _ => false, - } - }); + }); // If we found one, then it's very likely the cause of the error. - if let Some((_, (_, other_pred_span))) = other_pred { + if let Some((_, (_, other_clause_span))) = other_clause { err.span_note( - other_pred_span, + other_clause_span, "closure inferred to have a different signature due to this bound", ); } @@ -4897,9 +4898,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let mut type_diffs = vec![]; if let ObligationCauseCode::WhereClauseInExpr(def_id, _, _, idx) = *parent_code && let Some(node_args) = typeck_results.node_args_opt(call_hir_id) - && let where_clauses = - self.tcx.predicates_of(def_id).instantiate(self.tcx, node_args) - && let Some(where_pred) = where_clauses.predicates.get(idx) + && let where_clauses = self.tcx.clauses_of(def_id).instantiate(self.tcx, node_args) + && let Some(where_pred) = where_clauses.clauses.get(idx) { let where_pred = where_pred.as_ref().skip_norm_wip(); if let Some(where_pred) = where_pred.as_trait_clause() diff --git a/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs b/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs index 0c365e9dea707..18c228d5ddc55 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs @@ -576,13 +576,13 @@ fn derive_cause<'tcx>( result: _, } => { if let Some((_, span)) = - tcx.predicates_of(impl_def_id).instantiate_identity(tcx).iter().nth(idx) + tcx.clauses_of(impl_def_id).instantiate_identity(tcx).iter().nth(idx) { cause = cause.derived_cause(parent_trait_pred, |derived| { ObligationCauseCode::ImplDerived(Box::new(traits::ImplDerivedCause { derived, impl_or_alias_def_id: impl_def_id, - impl_def_predicate_index: Some(idx), + impl_def_clause_index: Some(idx), span, })) }) @@ -612,7 +612,7 @@ fn derive_host_cause<'tcx>( result: _, } => { if let Some((_, span)) = tcx - .predicates_of(impl_def_id) + .clauses_of(impl_def_id) .instantiate_identity(tcx) .into_iter() .chain(tcx.const_conditions(impl_def_id).instantiate_identity(tcx).into_iter().map( diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index 837be27bfba89..b21650da3b288 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -211,7 +211,7 @@ fn fresh_impl_header<'tcx>( trait_ref: is_of_trait .then(|| tcx.impl_trait_ref(impl_def_id).instantiate(tcx, impl_args).skip_norm_wip()), predicates: tcx - .predicates_of(impl_def_id) + .clauses_of(impl_def_id) .instantiate(tcx, impl_args) .iter() .map(|(c, _)| c.skip_norm_wip().as_predicate()) @@ -551,7 +551,7 @@ fn impl_intersection_has_negative_obligation( util::elaborate( tcx, - tcx.predicates_of(impl2_def_id) + tcx.clauses_of(impl2_def_id) .instantiate(tcx, impl2_header.impl_args) .into_iter() .map(|(c, s)| (c.skip_norm_wip(), s)), diff --git a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs index b8d0e31b55d3b..ab2965a345360 100644 --- a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs +++ b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs @@ -191,7 +191,7 @@ fn satisfied_from_param_env<'tcx>( // with its own `ConstEvaluatable` bound in the param env which we will visit separately. // // If we start allowing directly writing `ConstKind::Expr` without an intermediate anon const - // this will be incorrect. It might be worth investigating making `predicates_of` elaborate + // this will be incorrect. It might be worth investigating making `clauses_of` elaborate // all of the `ConstEvaluatable` bounds rather than having a visitor here. } } diff --git a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs index 7b45dfe48a7fe..76a9956619dae 100644 --- a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs +++ b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs @@ -174,14 +174,14 @@ fn predicates_reference_self( supertraits_only: bool, ) -> SmallVec<[Span; 1]> { let trait_ref = ty::Binder::dummy(ty::TraitRef::identity(tcx, trait_def_id)); - let predicates = if supertraits_only { - tcx.explicit_super_predicates_of(trait_def_id).skip_binder() + let clauses = if supertraits_only { + tcx.explicit_super_clauses_of(trait_def_id).skip_binder() } else { - tcx.predicates_of(trait_def_id).predicates + tcx.clauses_of(trait_def_id).clauses }; - predicates + clauses .iter() - .map(|&(predicate, sp)| (predicate.instantiate_supertrait(tcx, trait_ref), sp)) + .map(|&(clause, sp)| (clause.instantiate_supertrait(tcx, trait_ref), sp)) .filter_map(|(clause, sp)| { // Super predicates cannot allow self projections, since they're // impossible to make into existential bounds without eager resolution @@ -282,7 +282,7 @@ fn super_predicates_have_non_lifetime_binders( tcx: TyCtxt<'_>, trait_def_id: DefId, ) -> SmallVec<[Span; 1]> { - tcx.explicit_super_predicates_of(trait_def_id) + tcx.explicit_super_clauses_of(trait_def_id) .iter_identity_copied() .map(Unnormalized::skip_norm_wip) .filter_map(|(pred, span)| pred.has_non_region_bound_vars().then_some(span)) @@ -296,7 +296,7 @@ fn super_predicates_are_unconditionally_const( tcx: TyCtxt<'_>, trait_def_id: DefId, ) -> SmallVec<[Span; 1]> { - tcx.explicit_super_predicates_of(trait_def_id) + tcx.explicit_super_clauses_of(trait_def_id) .iter_identity_copied() .map(Unnormalized::skip_norm_wip) .filter_map(|(pred, span)| { @@ -318,15 +318,15 @@ fn generics_require_sized_self(tcx: TyCtxt<'_>, def_id: DefId) -> bool { return false; /* No Sized trait, can't require it! */ }; - // Search for a predicate like `Self: Sized` amongst the trait bounds. - let predicates: Vec<_> = tcx - .predicates_of(def_id) + // Search for a clause like `Self: Sized` amongst the trait bounds. + let clauses: Vec<_> = tcx + .clauses_of(def_id) .instantiate_identity(tcx) - .predicates + .clauses .into_iter() .map(Unnormalized::skip_norm_wip) .collect(); - elaborate(tcx, predicates).any(|pred| match pred.kind().skip_binder() { + elaborate(tcx, clauses).any(|pred| match pred.kind().skip_binder() { ty::ClauseKind::Trait(ref trait_pred) => { trait_pred.def_id() == sized_def_id && trait_pred.self_ty().is_param(0) } @@ -536,7 +536,7 @@ fn virtual_call_violations_for_method<'tcx>( // NOTE: This check happens last, because it results in a lint, and not a // hard error. - if tcx.predicates_of(method.def_id).predicates.iter().any(|&(pred, _span)| { + if tcx.clauses_of(method.def_id).clauses.iter().any(|&(clause, _span)| { // dyn Trait is okay: // // trait Trait { @@ -546,7 +546,7 @@ fn virtual_call_violations_for_method<'tcx>( // because a trait object can't claim to live longer than the concrete // type. If the lifetime bound holds on dyn Trait then it's guaranteed // to hold as well on the concrete type. - if pred.as_type_outlives_clause().is_some() { + if clause.as_type_outlives_clause().is_some() { return false; } @@ -566,7 +566,7 @@ fn virtual_call_violations_for_method<'tcx>( if let ty::ClauseKind::Trait(ty::TraitPredicate { trait_ref: pred_trait_ref, polarity: ty::PredicatePolarity::Positive, - }) = pred.kind().skip_binder() + }) = clause.kind().skip_binder() && pred_trait_ref.self_ty() == tcx.types.self_param && tcx.trait_is_auto(pred_trait_ref.def_id) { @@ -583,7 +583,7 @@ fn virtual_call_violations_for_method<'tcx>( return false; } - contains_illegal_self_type_reference(tcx, trait_def_id, pred, AllowSelfProjections::Yes) + contains_illegal_self_type_reference(tcx, trait_def_id, clause, AllowSelfProjections::Yes) }) { errors.push(MethodViolation::WhereClauseReferencesSelf); } @@ -703,10 +703,10 @@ fn receiver_is_dispatchable<'tcx>( // are not constructing a param-env for "inside" of the body of the defaulted // method, so we don't really care about projecting to a specific RPIT type, // and because RPITITs are not dyn compatible (yet). - let mut predicates: Vec<_> = tcx - .predicates_of(method.def_id) + let mut clauses: Vec<_> = tcx + .clauses_of(method.def_id) .instantiate_identity(tcx) - .predicates + .clauses .into_iter() .map(Unnormalized::skip_norm_wip) .collect(); @@ -714,7 +714,7 @@ fn receiver_is_dispatchable<'tcx>( // Self: Unsize let unsize_predicate = ty::TraitRef::new(tcx, unsize_did, [tcx.types.self_param, unsized_self_ty]); - predicates.push(unsize_predicate.upcast(tcx)); + clauses.push(unsize_predicate.upcast(tcx)); // U: Trait let trait_def_id = method.trait_container(tcx).unwrap(); @@ -722,17 +722,17 @@ fn receiver_is_dispatchable<'tcx>( if param.index == 0 { unsized_self_ty.into() } else { tcx.mk_param_from_def(param) } }); let trait_predicate = ty::TraitRef::new_from_args(tcx, trait_def_id, args); - predicates.push(trait_predicate.upcast(tcx)); + clauses.push(trait_predicate.upcast(tcx)); let meta_sized_predicate = { let meta_sized_did = tcx.require_lang_item(LangItem::MetaSized, DUMMY_SP); ty::TraitRef::new(tcx, meta_sized_did, [unsized_self_ty]).upcast(tcx) }; - predicates.push(meta_sized_predicate); + clauses.push(meta_sized_predicate); normalize_param_env_or_error( tcx, - ty::ParamEnv::new(tcx.mk_clauses(&predicates)), + ty::ParamEnv::new(tcx.mk_clauses(&clauses)), ObligationCause::dummy_with_span(tcx.def_span(method.def_id)), ) }; diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 919bc3cdcc3d9..f1b22f46d57b4 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -177,18 +177,18 @@ pub enum TraitQueryMode { } /// Creates predicate obligations from the generic bounds. -#[instrument(level = "debug", skip(cause, param_env, normalize_predicate))] +#[instrument(level = "debug", skip(cause, param_env, normalize_clause))] pub fn predicates_for_generics<'tcx>( cause: impl Fn(usize, Span) -> ObligationCause<'tcx>, - mut normalize_predicate: impl FnMut(Unnormalized<'tcx, Clause<'tcx>>) -> Clause<'tcx>, + mut normalize_clause: impl FnMut(Unnormalized<'tcx, Clause<'tcx>>) -> Clause<'tcx>, param_env: ty::ParamEnv<'tcx>, - generic_bounds: ty::InstantiatedPredicates<'tcx>, + generic_bounds: ty::InstantiatedClauses<'tcx>, ) -> impl Iterator> { generic_bounds.into_iter().enumerate().map(move |(idx, (clause, span))| Obligation { cause: cause(idx, span), recursion_depth: 0, param_env, - predicate: normalize_predicate(clause).as_predicate(), + predicate: normalize_clause(clause).as_predicate(), }) } @@ -270,11 +270,11 @@ fn set_projection_term_to_non_rigid<'tcx>( } #[instrument(level = "debug", skip(tcx, elaborated_env))] -fn do_normalize_predicates<'tcx>( +fn do_normalize_clauses<'tcx>( tcx: TyCtxt<'tcx>, cause: ObligationCause<'tcx>, elaborated_env: ty::ParamEnv<'tcx>, - predicates: Vec>, + clauses: Vec>, ) -> Result>, ErrorGuaranteed> { // FIXME. We should really... do something with these region // obligations. But this call just continues the older @@ -303,24 +303,24 @@ fn do_normalize_predicates<'tcx>( } else { elaborated_env }; - let predicates = ocx.normalize(&cause, elaborated_env, Unnormalized::new_wip(predicates)); - let predicates = if tcx.next_trait_solver_globally() { + let clauses = ocx.normalize(&cause, elaborated_env, Unnormalized::new_wip(clauses)); + let clauses = if tcx.next_trait_solver_globally() { if !tcx.disable_param_env_normalization_hack() { - let predicates: Vec<_> = set_projection_term_to_non_rigid(tcx, predicates).collect(); + let clauses: Vec<_> = set_projection_term_to_non_rigid(tcx, clauses).collect(); // FIXME(type_alias_impl_trait): opaque types in param env might be // in defining scope but we're using non body analysis here. // So the rigidness marker is wrong. - ty::set_opaques_to_non_rigid(tcx, predicates).skip_norm_wip() + ty::set_opaques_to_non_rigid(tcx, clauses).skip_norm_wip() } else { // Param env is used in different typing modes but itself // is normalized in `non_body_analysis`. // That not only makes the rigidness of opaques types wrong, // other aliases can be indirectly affected as well. // So we conservatively set everything to be non-rigid. - ty::set_aliases_to_non_rigid(tcx, predicates).skip_norm_wip() + ty::set_aliases_to_non_rigid(tcx, clauses).skip_norm_wip() } } else { - predicates + clauses }; let errors = ocx.evaluate_obligations_error_on_ambiguity(); @@ -329,7 +329,7 @@ fn do_normalize_predicates<'tcx>( return Err(reported); } - debug!("do_normalize_predicates: normalized predicates = {:?}", predicates); + debug!("do_normalize_clauses: normalized clauses = {:?}", clauses); // We can use the `elaborated_env` here; the region code only // cares about declarations like `'a: 'b`. @@ -347,8 +347,8 @@ fn do_normalize_predicates<'tcx>( // This is required by trait-system-refactor-initiative#166. The new solver encounters // this more frequently as we entirely ignore outlives predicates with the old solver. let _errors = infcx.resolve_regions(cause.body_def_id, elaborated_env, []); - match infcx.fully_resolve(predicates) { - Ok(predicates) => Ok(predicates), + match infcx.fully_resolve(clauses) { + Ok(clauses) => Ok(clauses), Err(fixup_err) => { // If we encounter a fixup error, it means that some type // variable wound up unconstrained. That can happen for @@ -385,7 +385,7 @@ pub fn normalize_param_env_or_error<'tcx>( // parameter environments once for every fn as it goes, // and errors will get reported then; so outside of type inference we // can be sure that no errors should occur. - let mut predicates: Vec<_> = util::elaborate( + let mut clauses: Vec<_> = util::elaborate( tcx, unnormalized_env.caller_bounds().into_iter().map(|clause| { if tcx.features().generic_const_exprs() || tcx.next_trait_solver_globally() { @@ -458,9 +458,9 @@ pub fn normalize_param_env_or_error<'tcx>( ) .collect(); - debug!("normalize_param_env_or_error: elaborated-predicates={:?}", predicates); + debug!("normalize_param_env_or_error: elaborated-clauses={:?}", clauses); - let elaborated_env = ty::ParamEnv::new(tcx.mk_clauses(&predicates)); + let elaborated_env = ty::ParamEnv::new(tcx.mk_clauses(&clauses)); if !elaborated_env.has_aliases() { return elaborated_env; } @@ -483,44 +483,43 @@ pub fn normalize_param_env_or_error<'tcx>( // // This works fairly well because trait matching does not actually care about param-env // TypeOutlives predicates - these are normally used by regionck. - let outlives_predicates: Vec<_> = predicates - .extract_if(.., |predicate| { - matches!(predicate.kind().skip_binder(), ty::ClauseKind::TypeOutlives(..)) + let outlives_clauses: Vec<_> = clauses + .extract_if(.., |clause| { + matches!(clause.kind().skip_binder(), ty::ClauseKind::TypeOutlives(..)) }) .collect(); debug!( "normalize_param_env_or_error: predicates=(non-outlives={:?}, outlives={:?})", - predicates, outlives_predicates + clauses, outlives_clauses ); - let Ok(non_outlives_predicates) = - do_normalize_predicates(tcx, cause.clone(), elaborated_env, predicates) + let Ok(non_outlives_clauses) = + do_normalize_clauses(tcx, cause.clone(), elaborated_env, clauses) else { // An unnormalized env is better than nothing. - debug!("normalize_param_env_or_error: errored resolving non-outlives predicates"); + debug!("normalize_param_env_or_error: errored resolving non-outlives clauses"); return elaborated_env; }; - debug!("normalize_param_env_or_error: non-outlives predicates={:?}", non_outlives_predicates); + debug!("normalize_param_env_or_error: non-outlives clauses={:?}", non_outlives_clauses); // Not sure whether it is better to include the unnormalized TypeOutlives predicates // here. I believe they should not matter, because we are ignoring TypeOutlives param-env // predicates here anyway. Keeping them here anyway because it seems safer. - let outlives_env = non_outlives_predicates.iter().chain(&outlives_predicates).cloned(); + let outlives_env = non_outlives_clauses.iter().chain(&outlives_clauses).cloned(); let outlives_env = ty::ParamEnv::new(tcx.mk_clauses_from_iter(outlives_env)); - let Ok(outlives_predicates) = - do_normalize_predicates(tcx, cause, outlives_env, outlives_predicates) + let Ok(outlives_clauses) = do_normalize_clauses(tcx, cause, outlives_env, outlives_clauses) else { // An unnormalized env is better than nothing. - debug!("normalize_param_env_or_error: errored resolving outlives predicates"); + debug!("normalize_param_env_or_error: errored resolving outlives clauses"); return elaborated_env; }; - debug!("normalize_param_env_or_error: outlives predicates={:?}", outlives_predicates); + debug!("normalize_param_env_or_error: outlives clauses={:?}", outlives_clauses); - let mut predicates = non_outlives_predicates; - predicates.extend(outlives_predicates); - debug!("normalize_param_env_or_error: final predicates={:?}", predicates); - ty::ParamEnv::new(tcx.mk_clauses(&predicates)) + let mut clauses = non_outlives_clauses; + clauses.extend(outlives_clauses); + debug!("normalize_param_env_or_error: final clauses={:?}", clauses); + ty::ParamEnv::new(tcx.mk_clauses(&clauses)) } #[derive(Debug)] @@ -780,12 +779,12 @@ fn replace_param_and_infer_args_with_placeholder<'tcx>( args.fold_with(&mut ReplaceParamAndInferWithPlaceholder { tcx, idx: ty::BoundVar::ZERO }) } -/// Normalizes the predicates and checks whether they hold in an empty environment. If this +/// Normalizes the clauses and checks whether they hold in an empty environment. If this /// returns true, then either normalize encountered an error or one of the predicates did not /// hold. Used when creating vtables to check for unsatisfiable methods. This should not be /// used during analysis. -pub fn impossible_predicates<'tcx>(tcx: TyCtxt<'tcx>, predicates: Vec>) -> bool { - debug!("impossible_predicates(predicates={:?})", predicates); +pub fn impossible_clauses<'tcx>(tcx: TyCtxt<'tcx>, clauses: Vec>) -> bool { + debug!("impossible_clauses(clauses={:?})", clauses); let (infcx, param_env) = tcx .infer_ctxt() .with_next_trait_solver(true) @@ -793,10 +792,10 @@ pub fn impossible_predicates<'tcx>(tcx: TyCtxt<'tcx>, predicates: Vec(tcx: TyCtxt<'tcx>, predicates: Vec( +fn instantiate_and_check_impossible_clauses<'tcx>( tcx: TyCtxt<'tcx>, key: (DefId, GenericArgsRef<'tcx>), ) -> bool { - debug!("instantiate_and_check_impossible_predicates(key={:?})", key); + debug!("instantiate_and_check_impossible_clauses(key={:?})", key); - let mut predicates: Vec<_> = tcx - .predicates_of(key.0) + let mut clauses: Vec<_> = tcx + .clauses_of(key.0) .instantiate(tcx, key.1) - .predicates + .clauses .into_iter() .map(Unnormalized::skip_norm_wip) .collect(); @@ -832,13 +831,13 @@ fn instantiate_and_check_impossible_predicates<'tcx>( // associated items. if let Some(trait_def_id) = tcx.trait_of_assoc(key.0) { let trait_ref = ty::TraitRef::from_assoc(tcx, trait_def_id, key.1); - predicates.push(trait_ref.upcast(tcx)); + clauses.push(trait_ref.upcast(tcx)); } - predicates.retain(|predicate| !predicate.has_param()); - let result = impossible_predicates(tcx, predicates); + clauses.retain(|clause| !clause.has_param()); + let result = impossible_clauses(tcx, clauses); - debug!("instantiate_and_check_impossible_predicates(key={:?}) = {:?}", key, result); + debug!("instantiate_and_check_impossible_clauses(key={:?}) = {:?}", key, result); result } @@ -888,7 +887,7 @@ fn is_impossible_associated_item( } let generics = tcx.generics_of(trait_item_def_id); - let predicates = tcx.predicates_of(trait_item_def_id); + let gen_clauses = tcx.clauses_of(trait_item_def_id); // Be conservative in cases where we have `W` and a method like `Self: Sized`, // since that method *may* have some substitutions where the predicates hold. @@ -907,13 +906,13 @@ fn is_impossible_associated_item( tcx.impl_trait_ref(impl_def_id).instantiate(tcx, fresh_args).skip_norm_wip(); let mut visitor = ReferencesOnlyParentGenerics { tcx, generics, trait_item_def_id }; - let predicates_for_trait = predicates.predicates.iter().filter_map(|(pred, span)| { - pred.visit_with(&mut visitor).is_continue().then(|| { + let predicates_for_trait = gen_clauses.clauses.iter().filter_map(|(clause, span)| { + clause.visit_with(&mut visitor).is_continue().then(|| { Obligation::new( tcx, ObligationCause::dummy_with_span(*span), param_env, - ty::EarlyBinder::bind(tcx, *pred) + ty::EarlyBinder::bind(tcx, *clause) .instantiate(tcx, impl_trait_ref.args) .skip_norm_wip(), ) @@ -932,7 +931,7 @@ pub fn provide(providers: &mut Providers) { specialization_graph_of: specialize::specialization_graph_provider, specializes: specialize::specializes, specialization_enabled_in: specialize::specialization_enabled_in, - instantiate_and_check_impossible_predicates, + instantiate_and_check_impossible_clauses, is_impossible_associated_item, live_args_for_alias_from_outlives_bounds: outlives_for_liveness::live_args_for_alias_from_outlives_bounds, diff --git a/compiler/rustc_trait_selection/src/traits/normalize.rs b/compiler/rustc_trait_selection/src/traits/normalize.rs index b822c713bfabb..dfdf99cc904c6 100644 --- a/compiler/rustc_trait_selection/src/traits/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/normalize.rs @@ -324,20 +324,20 @@ impl<'a, 'b, 'tcx> AssocTypeNormalizer<'a, 'b, 'tcx> { self.obligations.extend( infcx .tcx - .predicates_of(def_id) + .clauses_of(def_id) .instantiate_own(infcx.tcx, free.args) - .map(|(pred, span)| (pred.skip_norm_wip(), span)) - .map(|(mut predicate, span)| { + .map(|(clause, span)| (clause.skip_norm_wip(), span)) + .map(|(mut clause, span)| { if free.has_escaping_bound_vars() { - (predicate, ..) = BoundVarReplacer::replace_bound_vars( + (clause, ..) = BoundVarReplacer::replace_bound_vars( infcx, &mut self.universes, - predicate, + clause, ); } let mut cause = self.cause.clone(); cause.map_code(|code| ObligationCauseCode::TypeAlias(code, span, def_id)); - Obligation::new(infcx.tcx, cause, self.param_env, predicate) + Obligation::new(infcx.tcx, cause, self.param_env, clause) }), ); self.depth += 1; diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 79b531afbe2ae..71cbe0a28c780 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -549,14 +549,14 @@ pub fn normalize_inherent_projection<'a, 'b, 'tcx>( // Register the obligations arising from the impl and from the associated type itself. let def_id = alias_term.expect_inherent_def_id(); - let predicates = tcx.predicates_of(def_id).instantiate(tcx, args); - for (predicate, span) in predicates { - let predicate = normalize_with_depth_to( + let clauses = tcx.clauses_of(def_id).instantiate(tcx, args); + for (clause, span) in clauses { + let clause = normalize_with_depth_to( selcx, param_env, cause.clone(), depth + 1, - predicate, + clause, obligations, ); @@ -570,13 +570,7 @@ pub fn normalize_inherent_projection<'a, 'b, 'tcx>( ObligationCauseCode::WhereClause(def_id, span), ); - obligations.push(Obligation::with_depth( - tcx, - nested_cause, - depth + 1, - param_env, - predicate, - )); + obligations.push(Obligation::with_depth(tcx, nested_cause, depth + 1, param_env, clause)); } let term = if alias_term.kind.is_type() { @@ -2031,7 +2025,7 @@ fn confirm_impl_candidate<'cx, 'tcx>( // This means that the impl is missing a definition for the // associated type. This is either because the associate item - // has impossible-to-satisfy predicates (since those were + // has impossible-to-satisfy clauses (since those were // allowed in ), // or because the impl is literally missing the definition. if !assoc_term.item.defaultness(tcx).has_value() { @@ -2114,14 +2108,14 @@ fn assoc_term_own_obligations<'cx, 'tcx>( ) { let tcx = selcx.tcx(); let def_id = obligation.predicate.expect_projection_def_id(); - let predicates = tcx.predicates_of(def_id).instantiate_own(tcx, obligation.predicate.args); - for (predicate, span) in predicates { + let clauses = tcx.clauses_of(def_id).instantiate_own(tcx, obligation.predicate.args); + for (clause, span) in clauses { let normalized = normalize_with_depth_to( selcx, obligation.param_env, obligation.cause.clone(), obligation.recursion_depth + 1, - predicate, + clause, nested, ); diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs index 1d5c6be2687f0..4daffc6e1e0da 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs @@ -128,22 +128,22 @@ fn relate_mir_and_user_args<'tcx>( // Prove the predicates coming along with `def_id`. // - // Also, normalize the `instantiated_predicates` + // Also, normalize the `instantiated_clauses` // because otherwise we wind up with duplicate "type // outlives" error messages. - let instantiated_predicates = tcx.predicates_of(def_id).instantiate(tcx, args); + let instantiated_clauses = tcx.clauses_of(def_id).instantiate(tcx, args); - debug!(?instantiated_predicates); - for (instantiated_predicate, predicate_span) in instantiated_predicates { - let span = if span == DUMMY_SP { predicate_span } else { span }; + debug!(?instantiated_clauses); + for (instantiated_clause, clause_span) in instantiated_clauses { + let span = if span == DUMMY_SP { clause_span } else { span }; let cause = ObligationCause::new( span, CRATE_DEF_ID, - ObligationCauseCode::AscribeUserTypeProvePredicate(predicate_span), + ObligationCauseCode::AscribeUserTypeProvePredicate(clause_span), ); - let instantiated_predicate = ocx.normalize(&cause, param_env, instantiated_predicate); + let instantiated_clause = ocx.normalize(&cause, param_env, instantiated_clause); - ocx.register_obligation(Obligation::new(tcx, cause, param_env, instantiated_predicate)); + ocx.register_obligation(Obligation::new(tcx, cause, param_env, instantiated_clause)); } // Now prove the well-formedness of `def_id` with `args`. diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index d4027fcf388b1..84b51f42c411e 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -665,8 +665,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { return false; }; - for &(predicate, _) in self.tcx().predicates_of(impl_def_id).predicates { - let ty::ClauseKind::Trait(pred) = predicate.kind().skip_binder() else { continue }; + for &(clause, _) in self.tcx().clauses_of(impl_def_id).clauses { + let ty::ClauseKind::Trait(pred) = clause.kind().skip_binder() else { continue }; if fn_ptr_trait != pred.trait_ref.def_id { continue; } diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 49c277b39289b..22fb714cfd33c 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -539,7 +539,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // Check supertraits hold. This is so that their associated type bounds // will be checked in the code below. for supertrait in tcx - .explicit_super_predicates_of(trait_predicate.def_id()) + .explicit_super_clauses_of(trait_predicate.def_id()) .iter_instantiated_copied(tcx, trait_predicate.trait_ref.args) .map(|pred| pred.unzip().0) { diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 58f2d0c7f33ac..f3382df7c11da 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -2884,11 +2884,11 @@ impl<'tcx> SelectionContext<'_, 'tcx> { // obligation will normalize to `<$0 as Iterator>::Item = $1` and // `$1: Copy`, so we must ensure the obligations are emitted in // that order. - let predicates = tcx.predicates_of(def_id); - assert_eq!(predicates.parent, None); - let predicates = predicates.instantiate_own(tcx, args); - let mut obligations = PredicateObligations::with_capacity(predicates.len()); - for (index, (predicate, span)) in predicates.into_iter().enumerate() { + let clauses = tcx.clauses_of(def_id); + assert_eq!(clauses.parent, None); + let clauses = clauses.instantiate_own(tcx, args); + let mut obligations = PredicateObligations::with_capacity(clauses.len()); + for (index, (clause, span)) in clauses.into_iter().enumerate() { let cause = if tcx.is_lang_item(parent_trait_pred.def_id(), LangItem::CoerceUnsized) { cause.clone() } else { @@ -2896,7 +2896,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { ObligationCauseCode::ImplDerived(Box::new(ImplDerivedCause { derived, impl_or_alias_def_id: def_id, - impl_def_predicate_index: Some(index), + impl_def_clause_index: Some(index), span, })) }) @@ -2906,7 +2906,7 @@ impl<'tcx> SelectionContext<'_, 'tcx> { param_env, cause.clone(), recursion_depth, - predicate, + clause, &mut obligations, ); obligations.push(Obligation { diff --git a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs index 506d38c17bc9a..6abdaf404f103 100644 --- a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs @@ -187,12 +187,12 @@ fn fulfill_implication<'tcx>( // Now check that the source trait ref satisfies all the where clauses of the target impl. // This is not just for correctness; we also need this to constrain any params that may // only be referenced via projection predicates. - let predicates = infcx.tcx.predicates_of(target_impl).instantiate(infcx.tcx, target_args); + let clauses = infcx.tcx.clauses_of(target_impl).instantiate(infcx.tcx, target_args); let obligations = predicates_for_generics( |_, _| cause.clone(), - |pred| ocx.normalize(cause, param_env, pred), + |clause| ocx.normalize(cause, param_env, clause), param_env, - predicates, + clauses, ); ocx.register_obligations(obligations); @@ -318,13 +318,12 @@ pub(super) fn specializes( // Now check that the source trait ref satisfies all the where clauses of the target impl. // This is not just for correctness; we also need this to constrain any params that may // only be referenced via projection predicates. - let predicates = - infcx.tcx.predicates_of(parent_impl_def_id).instantiate(infcx.tcx, parent_args); + let clauses = infcx.tcx.clauses_of(parent_impl_def_id).instantiate(infcx.tcx, parent_args); let obligations = predicates_for_generics( |_, _| cause.clone(), - |pred| ocx.normalize(cause, param_env, pred), + |clause| ocx.normalize(cause, param_env, clause), param_env, - predicates, + clauses, ); ocx.register_obligations(obligations); diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs index e4da1fd1598f7..019214c210e7d 100644 --- a/compiler/rustc_trait_selection/src/traits/util.rs +++ b/compiler/rustc_trait_selection/src/traits/util.rs @@ -49,7 +49,7 @@ pub fn expand_trait_aliases<'tcx>( ty::ClauseKind::Trait(trait_pred) => { if tcx.is_trait_alias(trait_pred.def_id()) { queue.extend( - tcx.explicit_super_predicates_of(trait_pred.def_id()) + tcx.explicit_super_clauses_of(trait_pred.def_id()) .iter_identity_copied() .map(Unnormalized::skip_norm_wip) .map(|(super_clause, span)| { diff --git a/compiler/rustc_trait_selection/src/traits/vtable.rs b/compiler/rustc_trait_selection/src/traits/vtable.rs index 83d493f077539..7113169555d10 100644 --- a/compiler/rustc_trait_selection/src/traits/vtable.rs +++ b/compiler/rustc_trait_selection/src/traits/vtable.rs @@ -122,7 +122,7 @@ fn prepare_vtable_segments_inner<'tcx, T>( let &(inner_most_trait_ref, _, _) = stack.last().unwrap(); let mut direct_super_traits_iter = tcx - .explicit_super_predicates_of(inner_most_trait_ref.def_id) + .explicit_super_clauses_of(inner_most_trait_ref.def_id) .iter_identity_copied() .map(Unnormalized::skip_norm_wip) .filter_map(move |(pred, _)| { @@ -275,8 +275,8 @@ fn vtable_entries<'tcx>( // do not hold for this particular set of type parameters. // Note that this method could then never be called, so we // do not want to try and codegen it, in that case (see #23435). - if tcx.instantiate_and_check_impossible_predicates((def_id, args)) { - debug!("vtable_entries: predicates do not hold"); + if tcx.instantiate_and_check_impossible_clauses((def_id, args)) { + debug!("vtable_entries: clauses do not hold"); return VtblEntry::Vacant; } @@ -321,10 +321,9 @@ pub(crate) fn first_method_vtable_slot<'tcx>(tcx: TyCtxt<'tcx>, key: ty::TraitRe ); // We're monomorphizing a call to a dyn trait object that can never be constructed. - if tcx.instantiate_and_check_impossible_predicates(( - source_principal.def_id, - source_principal.args, - )) { + if tcx + .instantiate_and_check_impossible_clauses((source_principal.def_id, source_principal.args)) + { return 0; } @@ -390,10 +389,9 @@ pub(crate) fn supertrait_vtable_slot<'tcx>( ); // We're monomorphizing a dyn trait object upcast that can never be constructed. - if tcx.instantiate_and_check_impossible_predicates(( - source_principal.def_id, - source_principal.args, - )) { + if tcx + .instantiate_and_check_impossible_clauses((source_principal.def_id, source_principal.args)) + { return None; } diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index 95043385cf17a..6231f781db2c5 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -579,20 +579,20 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { return Default::default(); } - let predicates = self.tcx().predicates_of(def_id); - let mut origins = vec![def_id; predicates.predicates.len()]; - let mut head = predicates; + let gen_clauses = self.tcx().clauses_of(def_id); + let mut origins = vec![def_id; gen_clauses.clauses.len()]; + let mut head = gen_clauses; while let Some(parent) = head.parent { - head = self.tcx().predicates_of(parent); - origins.extend(iter::repeat(parent).take(head.predicates.len())); + head = self.tcx().clauses_of(parent); + origins.extend(iter::repeat(parent).take(head.clauses.len())); } - let predicates = predicates.instantiate(self.tcx(), args); - trace!("{:#?}", predicates); - debug_assert_eq!(predicates.predicates.len(), origins.len()); + let gen_clauses = gen_clauses.instantiate(self.tcx(), args); + trace!("{:#?}", gen_clauses); + debug_assert_eq!(gen_clauses.clauses.len(), origins.len()); - iter::zip(predicates, origins.into_iter().rev()) - .map(|((pred, span), origin_def_id)| { + iter::zip(gen_clauses, origins.into_iter().rev()) + .map(|((clause, span), origin_def_id)| { let code = ObligationCauseCode::WhereClause(origin_def_id, span); let cause = self.cause(code); traits::Obligation::with_depth( @@ -600,10 +600,10 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { cause, self.recursion_depth, self.param_env, - pred.skip_norm_wip(), + clause.skip_norm_wip(), ) }) - .filter(|pred| !pred.has_escaping_bound_vars()) + .filter(|clause| !clause.has_escaping_bound_vars()) .collect() } diff --git a/compiler/rustc_traits/src/normalize_projection_ty.rs b/compiler/rustc_traits/src/normalize_projection_ty.rs index 2b904c2710464..c6f759fb7937d 100644 --- a/compiler/rustc_traits/src/normalize_projection_ty.rs +++ b/compiler/rustc_traits/src/normalize_projection_ty.rs @@ -101,16 +101,15 @@ fn normalize_canonicalized_free_alias<'tcx>( &goal, |ocx, ParamEnvAnd { param_env, value: goal }| { let def_id = goal.expect_free_def_id(); - let obligations = tcx.predicates_of(def_id).instantiate_own(tcx, goal.args).map( - |(predicate, span)| { + let obligations = + tcx.clauses_of(def_id).instantiate_own(tcx, goal.args).map(|(predicate, span)| { traits::Obligation::new( tcx, ObligationCause::dummy_with_span(span), param_env, predicate.skip_norm_wip(), ) - }, - ); + }); ocx.register_obligations(obligations); let normalized_term: ty::Term<'tcx> = if goal.kind.is_type() { tcx.type_of(def_id).instantiate(tcx, goal.args).skip_norm_wip().into() diff --git a/compiler/rustc_ty_utils/src/implied_bounds.rs b/compiler/rustc_ty_utils/src/implied_bounds.rs index 7b36fcc483c58..c397982461a30 100644 --- a/compiler/rustc_ty_utils/src/implied_bounds.rs +++ b/compiler/rustc_ty_utils/src/implied_bounds.rs @@ -66,7 +66,7 @@ fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<' // // Side-note: We don't really need to do this remapping for early-bound // lifetimes because they're already "linked" by the bidirectional outlives - // predicates we insert in the `explicit_predicates_of` query for RPITITs. + // predicates we insert in the `explicit_clauses_of` query for RPITITs. let mut mapping = FxHashMap::default(); let generics = tcx.generics_of(def_id); diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index b5a82793dcc97..3862f043fea09 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -199,14 +199,12 @@ fn resolve_associated_item<'tcx>( // and const-prop (and also some lints). let self_ty = rcvr_args.type_at(0); if !self_ty.is_known_rigid() { - let predicates = tcx - .predicates_of(impl_data.impl_def_id) - .instantiate(tcx, impl_data.args) - .predicates; + let clauses = + tcx.clauses_of(impl_data.impl_def_id).instantiate(tcx, impl_data.args).clauses; let sized_def_id = tcx.lang_items().sized_trait(); // If we find a `Self: Sized` bound on the item, then we know // that `dyn Trait` can certainly never apply here. - if !predicates.into_iter().filter_map(|p| p.as_trait_clause()).any(|clause| { + if !clauses.into_iter().filter_map(|p| p.as_trait_clause()).any(|clause| { Some(clause.def_id()) == sized_def_id && clause.skip_binder().self_ty() == self_ty }) { diff --git a/compiler/rustc_ty_utils/src/sig_types.rs b/compiler/rustc_ty_utils/src/sig_types.rs index d46a280875f96..b010b6ec9144b 100644 --- a/compiler/rustc_ty_utils/src/sig_types.rs +++ b/compiler/rustc_ty_utils/src/sig_types.rs @@ -34,7 +34,7 @@ pub fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>( visitor.visit(ty.span, tcx.type_of(item).instantiate_identity().skip_norm_wip()) ); } - for (pred, span) in tcx.explicit_predicates_of(item).instantiate_identity(tcx) { + for (pred, span) in tcx.explicit_clauses_of(item).instantiate_identity(tcx) { try_visit!(visitor.visit(span, pred.skip_norm_wip())); } V::Result::output() @@ -55,8 +55,8 @@ pub fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>( for (hir, ty) in hir_sig.inputs.iter().zip(ty_sig.inputs().iter()) { try_visit!(visitor.visit(hir.span, ty.map_bound(|x| *x))); } - for (pred, span) in tcx.explicit_predicates_of(item).instantiate_identity(tcx) { - try_visit!(visitor.visit(span, pred.skip_norm_wip())); + for (clause, span) in tcx.explicit_clauses_of(item).instantiate_identity(tcx) { + try_visit!(visitor.visit(span, clause.skip_norm_wip())); } } // Walk over the type behind the alias or the type of the item @@ -96,8 +96,8 @@ pub fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>( let ty = field.ty(tcx, args); try_visit!(visitor.visit(span, ty)); } - for (pred, span) in tcx.explicit_predicates_of(item).instantiate_identity(tcx) { - try_visit!(visitor.visit(span, pred.skip_norm_wip())); + for (clause, span) in tcx.explicit_clauses_of(item).instantiate_identity(tcx) { + try_visit!(visitor.visit(span, clause.skip_norm_wip())); } } DefKind::Impl { of_trait } => { @@ -122,13 +122,13 @@ pub fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>( try_visit!( visitor.visit(span, tcx.type_of(item).instantiate_identity().skip_norm_wip()) ); - for (pred, span) in tcx.explicit_predicates_of(item).instantiate_identity(tcx) { - try_visit!(visitor.visit(span, pred.skip_norm_wip())); + for (clause, span) in tcx.explicit_clauses_of(item).instantiate_identity(tcx) { + try_visit!(visitor.visit(span, clause.skip_norm_wip())); } } DefKind::TraitAlias | DefKind::Trait => { - for (pred, span) in tcx.explicit_predicates_of(item).instantiate_identity(tcx) { - try_visit!(visitor.visit(span, pred.skip_norm_wip())); + for (clause, span) in tcx.explicit_clauses_of(item).instantiate_identity(tcx) { + try_visit!(visitor.visit(span, clause.skip_norm_wip())); } } DefKind::Variant diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index 8e67b97c4f21c..39f0da47942e4 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -134,9 +134,9 @@ fn adt_sizedness_constraint<'tcx>( // perf hack: if there is a `constraint_ty: {Meta,}Sized` bound, then we know // that the type is sized and do not need to check it on the impl. let sizedness_trait_def_id = sizedness.require_lang_item(tcx); - let predicates = tcx.predicates_of(def.did()).predicates; - if predicates.iter().any(|(p, _)| { - p.as_trait_clause().is_some_and(|trait_pred| { + let clauses = tcx.clauses_of(def.did()).clauses; + if clauses.iter().any(|(c, _)| { + c.as_trait_clause().is_some_and(|trait_pred| { trait_pred.def_id() == sizedness_trait_def_id && trait_pred.self_ty().skip_binder() == constraint_ty }) @@ -153,9 +153,8 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> { return tcx.param_env(tcx.typeck_root_def_id(def_id)); } // Compute the bounds on Self and the type parameters. - let ty::InstantiatedPredicates { predicates, .. } = - tcx.predicates_of(def_id).instantiate_identity(tcx); - let mut predicates: Vec<_> = predicates.into_iter().map(Unnormalized::skip_norm_wip).collect(); + let ty::InstantiatedClauses { clauses, .. } = tcx.clauses_of(def_id).instantiate_identity(tcx); + let mut clauses: Vec<_> = clauses.into_iter().map(Unnormalized::skip_norm_wip).collect(); // Finally, we have to normalize the bounds in the environment, in // case they contain any associated type projections. This process @@ -180,7 +179,7 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> { tcx, fn_def_id: def_id, bound_vars: sig.bound_vars(), - predicates: &mut predicates, + clauses: &mut clauses, seen: FxHashSet::default(), depth: ty::INNERMOST, }); @@ -189,7 +188,7 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> { // We extend the param-env of our item with the const conditions of the item, // since we're allowed to assume `[const]` bounds hold within the item itself. if tcx.is_conditionally_const(def_id) { - predicates.extend(tcx.const_conditions(def_id).instantiate_identity(tcx).into_iter().map( + clauses.extend(tcx.const_conditions(def_id).instantiate_identity(tcx).into_iter().map( |(trait_ref, _)| { trait_ref.to_host_effect_clause(tcx, ty::BoundConstness::Maybe).skip_norm_wip() }, @@ -198,7 +197,7 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> { let local_did = def_id.as_local().unwrap_or(CRATE_DEF_ID); - let unnormalized_env = ty::ParamEnv::new(tcx.mk_clauses(&predicates)); + let unnormalized_env = ty::ParamEnv::new(tcx.mk_clauses(&clauses)); let cause = traits::ObligationCause::misc(tcx.def_span(def_id), local_did); traits::normalize_param_env_or_error(tcx, unnormalized_env, cause) @@ -210,7 +209,7 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> { /// its corresponding opaque within the body of a default-body trait method. struct ImplTraitInTraitFinder<'a, 'tcx> { tcx: TyCtxt<'tcx>, - predicates: &'a mut Vec>, + clauses: &'a mut Vec>, fn_def_id: DefId, bound_vars: &'tcx ty::List>, seen: FxHashSet, @@ -261,7 +260,7 @@ impl<'tcx> TypeVisitor> for ImplTraitInTraitFinder<'_, 'tcx> { .instantiate(self.tcx, shifted_alias_ty.args) .skip_norm_wip(); - self.predicates.push( + self.clauses.push( ty::Binder::bind_with_vars( ty::ProjectionPredicate { projection_term: shifted_alias_ty.projection_to_alias_ty().into(), diff --git a/compiler/rustc_type_ir/src/binder.rs b/compiler/rustc_type_ir/src/binder.rs index c11532c798a42..4eb28bb1f8920 100644 --- a/compiler/rustc_type_ir/src/binder.rs +++ b/compiler/rustc_type_ir/src/binder.rs @@ -666,7 +666,7 @@ impl> ty::EarlyBinder { // is unnecessary. We may want to track explicitly whether `EarlyBinder` // contains something that has been normalized already. // Also do that for other types who have `instantiate_identity` method, - // e.g., `GenericPredicates` and `ConstConditions`. + // e.g., `GenericClauses` and `ConstConditions`. // // This is annoying, as e.g. `type_of` for opaque types is normalized, // while `type_of` for free type aliases is not. diff --git a/compiler/rustc_type_ir/src/elaborate.rs b/compiler/rustc_type_ir/src/elaborate.rs index 03d5fc1ff8330..0f050b0bed894 100644 --- a/compiler/rustc_type_ir/src/elaborate.rs +++ b/compiler/rustc_type_ir/src/elaborate.rs @@ -165,17 +165,18 @@ impl> Elaborator { ) }; - // Get predicates implied by the trait, or only super predicates if we only care about self predicates. + // Get predicates implied by the trait, or only super predicates if we only care + // about self predicates. match self.mode { Filter::All => self.extend_deduped( - cx.explicit_implied_predicates_of(data.def_id().into()) + cx.explicit_implied_clauses_of(data.def_id().into()) .iter_identity() .map(Unnormalized::skip_norm_wip) .enumerate() .map(map_to_child_clause), ), Filter::OnlySelf => self.extend_deduped( - cx.explicit_super_predicates_of(data.def_id()) + cx.explicit_super_clauses_of(data.def_id()) .iter_identity() .map(Unnormalized::skip_norm_wip) .enumerate() @@ -329,12 +330,12 @@ pub fn supertrait_def_ids( std::iter::from_fn(move || { let trait_def_id = stack.pop()?; - for (predicate, _) in cx - .explicit_super_predicates_of(trait_def_id) + for (clause, _) in cx + .explicit_super_clauses_of(trait_def_id) .iter_identity() .map(Unnormalized::skip_norm_wip) { - if let ty::ClauseKind::Trait(data) = predicate.kind().skip_binder() + if let ty::ClauseKind::Trait(data) = clause.kind().skip_binder() && set.insert(data.def_id()) { stack.push(data.def_id()); diff --git a/compiler/rustc_type_ir/src/interner.rs b/compiler/rustc_type_ir/src/interner.rs index 136a14ce8448a..1fa698a4faeaf 100644 --- a/compiler/rustc_type_ir/src/interner.rs +++ b/compiler/rustc_type_ir/src/interner.rs @@ -320,22 +320,22 @@ pub trait Interner: def_id: Self::DefId, ) -> ty::EarlyBinder>; - fn predicates_of( + fn clauses_of( self, def_id: Self::DefId, ) -> ty::EarlyBinder>; - fn own_predicates_of( + fn own_clauses_of( self, def_id: Self::DefId, ) -> ty::EarlyBinder>; - fn explicit_super_predicates_of( + fn explicit_super_clauses_of( self, def_id: Self::TraitId, ) -> ty::EarlyBinder>; - fn explicit_implied_predicates_of( + fn explicit_implied_clauses_of( self, def_id: Self::DefId, ) -> ty::EarlyBinder>; diff --git a/compiler/rustc_type_ir/src/unnormalized.rs b/compiler/rustc_type_ir/src/unnormalized.rs index a685f32bced2c..8ac567f7ef65b 100644 --- a/compiler/rustc_type_ir/src/unnormalized.rs +++ b/compiler/rustc_type_ir/src/unnormalized.rs @@ -40,7 +40,7 @@ pub struct Unnormalized { impl Unnormalized { /// Should only be used in limited situations where you produce an potentially - /// unnormalized value, like in (Early)Binder/GenericPredicates instantiation. + /// unnormalized value, like in (Early)Binder/GenericClauses instantiation. pub fn new(value: T) -> Unnormalized { Unnormalized { value, _tcx: PhantomData } } diff --git a/src/doc/rustc-dev-guide/src/compiler-debugging.md b/src/doc/rustc-dev-guide/src/compiler-debugging.md index 49a965d49df33..26b56688091e9 100644 --- a/src/doc/rustc-dev-guide/src/compiler-debugging.md +++ b/src/doc/rustc-dev-guide/src/compiler-debugging.md @@ -281,7 +281,7 @@ Here are some notable ones: | `rustc_dump_item_bounds` | Dumps the [`item_bounds`] of an item. | | `rustc_dump_layout` | [See this section](#debugging-type-layouts). | | `rustc_dump_object_lifetime_defaults` | Dumps the [object lifetime defaults] of an item. | -| `rustc_dump_predicates` | Dumps the [`predicates_of`] an item. | +| `rustc_dump_predicates` | Dumps the [`clauses_of`] an item. | | `rustc_dump_symbol_name` | Dumps the mangled & demangled [`symbol_name`] of an item. | | `rustc_dump_variances` | Dumps the [variances] of an item. | | `rustc_dump_vtable` | Dumps the vtable layout of an impl, or a type alias of a dyn type. | @@ -293,7 +293,7 @@ Right below you can find elaborate explainers on a selected few. [`def_path_str`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.def_path_str [`inferred_outlives_of`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.inferred_outlives_of [`item_bounds`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.item_bounds -[`predicates_of`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.predicates_of +[`clauses_of`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.clauses_of [`symbol_name`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.symbol_name [object lifetime defaults]: https://doc.rust-lang.org/reference/lifetime-elision.html#default-trait-object-lifetimes [opaq]: ./opaque-types-impl-trait-inference.md diff --git a/src/doc/rustc-dev-guide/src/effects.md b/src/doc/rustc-dev-guide/src/effects.md index edbb1688e3da5..4096c85a59f7a 100644 --- a/src/doc/rustc-dev-guide/src/effects.md +++ b/src/doc/rustc-dev-guide/src/effects.md @@ -9,22 +9,22 @@ Because `[const] Tr`, or rather `Maybe` bounds apply differently based on whichever contexts they are in, they have different behavior than normal bounds. Where normal trait bounds on a function such as -`T: Tr` are collected within the [`predicates_of`] query to be proven when a +`T: Tr` are collected within the [`clauses_of`] query to be proven when a function is called and to be assumed within the function, bounds such as `T: [const] Tr` will behave as a normal trait bound and add `T: Tr` to the result -from `predicates_of`, but also adds a `HostEffectPredicate` to the [`const_conditions`] query. +from `clauses_of`, but also adds a `HostEffectPredicate` to the [`const_conditions`] query. On the other hand, `T: const Tr` bounds do not change meaning across contexts, therefore they will result in `HostEffect(T: Tr, const)` being added to -`predicates_of`, and not `const_conditions`. +`clauses_of`, and not `const_conditions`. [`HostEffectPredicate`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_type_ir/predicate/struct.HostEffectPredicate.html -[`predicates_of`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.predicates_of +[`clauses_of`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.clauses_of [`const_conditions`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.const_conditions ## The `const_conditions` query -`predicates_of` represents a set of predicates that need to be proven to use an item. +`clauses_of` represents a set of clauses that need to be proven to use an item. For example, to use `foo` in the example below: ```rust diff --git a/src/doc/rustc-dev-guide/src/return-position-impl-trait-in-trait.md b/src/doc/rustc-dev-guide/src/return-position-impl-trait-in-trait.md index 85cece2acd445..e82a0bdbf4be2 100644 --- a/src/doc/rustc-dev-guide/src/return-position-impl-trait-in-trait.md +++ b/src/doc/rustc-dev-guide/src/return-position-impl-trait-in-trait.md @@ -47,7 +47,7 @@ The main addition for RPITITs is that during lowering we track the relationship between the captured lifetimes and the corresponding duplicated lifetimes in an additional field, [`OpaqueTy::lifetime_mapping`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.OpaqueTy.html#structfield.lifetime_mapping). -We use this lifetime mapping later on in `predicates_of` to install +We use this lifetime mapping later on in `clauses_of` to install bounds that enforce equality between these duplicated lifetimes and their source lifetimes in order to properly typecheck these GATs, which will be discussed below. @@ -171,18 +171,18 @@ perhaps by a interested new contributor. ##### `opt_rpitit_info` Some queries rely on computing information that would result in cycles -if we were to feed them eagerly, like `explicit_predicates_of`. -Therefore we defer to the `predicates_of` provider to return the right +if we were to feed them eagerly, like `explicit_clauses_of`. +Therefore we defer to the `clauses_of` provider to return the right value for our RPITIT's GAT. We do this by detecting early on in the query if the associated type is synthetic by using [`opt_rpitit_info`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.opt_rpitit_info), which returns `Some` if the associated type is synthetic. -Then, during a query like `explicit_predicates_of`, we can detect if an +Then, during a query like `explicit_clauses_of`, we can detect if an associated type is synthetic like: ```rust -fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ... { +fn explicit_clauses_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ... { if let Some(rpitit_info) = tcx.opt_rpitit_info(def_id) { // Do something special for RPITITs... return ...; @@ -192,7 +192,7 @@ fn explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ... { } ``` -##### `explicit_predicates_of` +##### `explicit_clauses_of` RPITITs begin by copying the predicates of the method that defined it, both on the trait and impl side. @@ -378,7 +378,7 @@ error[E0308]: mismatched types We check well-formedness of RPITITs just like regular associated types. -Since we added lifetime bounds in `predicates_of` that link the +Since we added lifetime bounds in `clauses_of` that link the duplicated early-bound lifetimes to their original lifetimes, and we implemented `assumed_wf_types` which inherits the WF types of the method from which the RPITIT originates ([#113704]), we have no issues diff --git a/src/doc/rustc-dev-guide/src/traits/implied-bounds.md b/src/doc/rustc-dev-guide/src/traits/implied-bounds.md index cdcb90d3e2edf..3a419dd1193cd 100644 --- a/src/doc/rustc-dev-guide/src/traits/implied-bounds.md +++ b/src/doc/rustc-dev-guide/src/traits/implied-bounds.md @@ -4,7 +4,7 @@ We currently add implied region bounds to avoid explicit annotations. e.g. `fn foo<'a, T>(x: &'a T)` can freely assume that `T: 'a` holds without specifying it. There are two kinds of implied bounds: explicit and implicit. Explicit implied bounds -get added to the `fn predicates_of` of the relevant item while implicit ones are +get added to the `fn clauses_of` of the relevant item while implicit ones are handled... well... implicitly. ## explicit implied bounds @@ -18,7 +18,7 @@ This function computes the outlives bounds for each component of the field using separate implementation. For ADTs, trait objects, and associated types the initially required predicates are -computed in [`fn check_explicit_predicates`]. This simply uses `fn explicit_predicates_of` +computed in [`fn check_explicit_predicates`]. This simply uses `fn explicit_clauses_of` without elaborating them. Region predicates are added via [`fn insert_outlives_predicate`]. This function takes @@ -65,7 +65,7 @@ lexical region resolution [only uses the unnormalized types][notnorm]. ### proving implicit implied bounds -As the implicit implied bounds are not included in `fn predicates_of` we have to +As the implicit implied bounds are not included in `fn clauses_of` we have to separately make sure they actually hold. We generally handle this by checking that all used types are well formed by emitting `WellFormed` predicates. diff --git a/src/doc/rustc-dev-guide/src/typing-parameter-envs.md b/src/doc/rustc-dev-guide/src/typing-parameter-envs.md index db9f369d2659e..f5a19ea328696 100644 --- a/src/doc/rustc-dev-guide/src/typing-parameter-envs.md +++ b/src/doc/rustc-dev-guide/src/typing-parameter-envs.md @@ -20,7 +20,7 @@ whereas different `ParamEnv`s can be used on a per-goal basis. The [`ParamEnv`][penv] is a list of in-scope where-clauses, it typically corresponds to a specific item's where clauses. -Some clauses are not explicitly written but are instead implicitly added in the [`predicates_of`][predicates_of] query, +Some clauses are not explicitly written but are instead implicitly added in the [`clauses_of`][clauses_of] query, such as `ConstArgHasType` or (some) implied bounds. In most cases `ParamEnv`s are initially created via the [`param_env` query][query] which returns a `ParamEnv` derived from the provided item's where clauses. @@ -75,7 +75,7 @@ fn foo2(a: T) { } ``` -[predicates_of]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/collect/predicates_of/fn.predicates_of.html +[clauses_of]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/collect/clauses_of/fn.clauses_of.html [method_pred_entailment]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/check/compare_impl_item/fn.compare_method_predicate_entailment.html [query]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.param_env [normalization]: normalization.md diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index f759cd9a0b0a8..75f6db0400edd 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -10,7 +10,7 @@ use rustc_trait_selection::traits::auto_trait::{self, RegionTarget}; use tracing::{debug, instrument}; use crate::clean::{ - self, Lifetime, clean_generic_param_def, clean_middle_ty, clean_predicate, + self, Lifetime, clean_clause, clean_generic_param_def, clean_middle_ty, clean_trait_ref_with_constraints, clean_ty_generics_inner, simplify, }; use crate::core::DocContext; @@ -104,7 +104,7 @@ fn synthesize_auto_trait_impl<'tcx>( let mut generics = clean_ty_generics_inner( cx, tcx.generics_of(item_def_id), - ty::GenericPredicates::default(), + ty::GenericClauses::default(), ); generics.where_predicates.clear(); @@ -200,7 +200,7 @@ fn clean_param_env<'tcx>( } }) }) - .flat_map(|clause| clean_predicate(clause, cx)) + .flat_map(|clause| clean_clause(clause, cx)) .chain(clean_region_outlives_constraints(®ion_data, generics)) .collect() }); diff --git a/src/librustdoc/clean/blanket_impl.rs b/src/librustdoc/clean/blanket_impl.rs index 6cf7c553c76bb..7b4af6ac0dbcb 100644 --- a/src/librustdoc/clean/blanket_impl.rs +++ b/src/librustdoc/clean/blanket_impl.rs @@ -59,19 +59,19 @@ pub(crate) fn synthesize_blanket_impls( // FIXME(eddyb) ignoring `obligations` might cause false positives. drop(obligations); - let predicates = tcx - .predicates_of(impl_def_id) + let clauses = tcx + .clauses_of(impl_def_id) .instantiate(tcx, impl_args) - .predicates + .clauses .into_iter() .map(Unnormalized::skip_norm_wip) .chain(Some(impl_trait_ref.upcast(tcx))); - for predicate in predicates { + for clause in clauses { let obligation = traits::Obligation::new( tcx, traits::ObligationCause::dummy(), param_env, - predicate, + clause, ); match infcx.evaluate_obligation(&obligation) { Ok(eval_result) if eval_result.may_apply() => {} diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index a81d56e708173..d03bf56fb9c33 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -425,19 +425,19 @@ fn clean_where_predicate<'tcx>( }) } -pub(crate) fn clean_predicate<'tcx>( - predicate: ty::Clause<'tcx>, +pub(crate) fn clean_clause<'tcx>( + clause: ty::Clause<'tcx>, cx: &mut DocContext<'tcx>, ) -> Option { - let bound_predicate = predicate.kind(); - match bound_predicate.skip_binder() { - ty::ClauseKind::Trait(pred) => clean_poly_trait_predicate(bound_predicate.rebind(pred), cx), + let bound_clause = clause.kind(); + match bound_clause.skip_binder() { + ty::ClauseKind::Trait(pred) => clean_poly_trait_predicate(bound_clause.rebind(pred), cx), ty::ClauseKind::RegionOutlives(pred) => Some(clean_region_outlives_predicate(pred, cx.tcx)), ty::ClauseKind::TypeOutlives(pred) => { - Some(clean_type_outlives_predicate(bound_predicate.rebind(pred), cx)) + Some(clean_type_outlives_predicate(bound_clause.rebind(pred), cx)) } ty::ClauseKind::Projection(pred) => { - Some(clean_projection_predicate(bound_predicate.rebind(pred), cx)) + Some(clean_projection_predicate(bound_clause.rebind(pred), cx)) } // FIXME(generic_const_exprs): should this do something? ty::ClauseKind::ConstEvaluatable(..) @@ -855,13 +855,13 @@ pub(crate) fn clean_generics<'tcx>( } fn clean_ty_generics<'tcx>(cx: &mut DocContext<'tcx>, def_id: DefId) -> Generics { - clean_ty_generics_inner(cx, cx.tcx.generics_of(def_id), cx.tcx.explicit_predicates_of(def_id)) + clean_ty_generics_inner(cx, cx.tcx.generics_of(def_id), cx.tcx.explicit_clauses_of(def_id)) } fn clean_ty_generics_inner<'tcx>( cx: &mut DocContext<'tcx>, gens: &ty::Generics, - preds: ty::GenericPredicates<'tcx>, + gen_clauses: ty::GenericClauses<'tcx>, ) -> Generics { // Don't populate `cx.impl_trait_bounds` before cleaning where clauses, // since `clean_predicate` would consume them. @@ -892,14 +892,14 @@ fn clean_ty_generics_inner<'tcx>( let mut impl_trait_proj = FxHashMap::>)>>::default(); - let where_predicates = preds - .predicates + let where_clauses = gen_clauses + .clauses .iter() - .flat_map(|(pred, _)| { + .flat_map(|(clause, _)| { let mut proj_pred = None; let param_idx = { - let bound_p = pred.kind(); - match bound_p.skip_binder() { + let bound_c = clause.kind(); + match bound_c.skip_binder() { ty::ClauseKind::Trait(pred) if let ty::Param(param) = pred.self_ty().kind() => { Some(param.index) } @@ -911,7 +911,7 @@ fn clean_ty_generics_inner<'tcx>( ty::ClauseKind::Projection(p) if let ty::Param(param) = p.projection_term.self_ty().kind() => { - proj_pred = Some(bound_p.rebind(p)); + proj_pred = Some(bound_c.rebind(p)); Some(param.index) } _ => None, @@ -921,9 +921,9 @@ fn clean_ty_generics_inner<'tcx>( if let Some(param_idx) = param_idx && let Some(bounds) = impl_trait.get_mut(¶m_idx) { - let pred = clean_predicate(*pred, cx)?; + let clause = clean_clause(*clause, cx)?; - bounds.extend(pred.get_bounds().into_iter().flatten().cloned()); + bounds.extend(clause.get_bounds().into_iter().flatten().cloned()); if let Some(pred) = proj_pred { let lhs = clean_projection(pred.map_bound(|p| p.projection_term), cx, None); @@ -937,7 +937,7 @@ fn clean_ty_generics_inner<'tcx>( return None; } - Some(pred) + Some(clause) }) .collect::>(); @@ -980,8 +980,7 @@ fn clean_ty_generics_inner<'tcx>( // Now that `cx.impl_trait_bounds` is populated, we can process // remaining predicates which could contain `impl Trait`. - let where_predicates = - where_predicates.into_iter().flat_map(|p| clean_predicate(*p, cx)).collect(); + let where_predicates = where_clauses.into_iter().flat_map(|c| clean_clause(*c, cx)).collect(); let mut generics = Generics { params, where_predicates }; simplify::sizedness_bounds(cx, &mut generics); @@ -1469,18 +1468,18 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo } } - let mut predicates = tcx.explicit_predicates_of(assoc_item.def_id).predicates; + let mut clauses = tcx.explicit_clauses_of(assoc_item.def_id).clauses; if let ty::AssocContainer::Trait = assoc_item.container { let bounds = tcx .explicit_item_bounds(assoc_item.def_id) .iter_identity_copied() .map(Unnormalized::skip_norm_wip); - predicates = tcx.arena.alloc_from_iter(bounds.chain(predicates.iter().copied())); + clauses = tcx.arena.alloc_from_iter(bounds.chain(clauses.iter().copied())); } let mut generics = clean_ty_generics_inner( cx, tcx.generics_of(assoc_item.def_id), - ty::GenericPredicates { parent: None, predicates }, + ty::GenericClauses { parent: None, clauses }, ); simplify::move_bounds_to_generic_parameters(&mut generics); diff --git a/src/librustdoc/clean/simplify.rs b/src/librustdoc/clean/simplify.rs index fecbc913771b2..3b00e2b3ac48b 100644 --- a/src/librustdoc/clean/simplify.rs +++ b/src/librustdoc/clean/simplify.rs @@ -113,7 +113,7 @@ fn trait_is_same_or_supertrait(tcx: TyCtxt<'_>, child: DefId, trait_: DefId) -> if child == trait_ { return true; } - let predicates = tcx.explicit_super_predicates_of(child); + let predicates = tcx.explicit_super_clauses_of(child); predicates .iter_identity_copied() .map(Unnormalized::skip_norm_wip) diff --git a/src/tools/clippy/clippy_lints/src/derive/derive_partial_eq_without_eq.rs b/src/tools/clippy/clippy_lints/src/derive/derive_partial_eq_without_eq.rs index 612d552a75408..1056929405035 100644 --- a/src/tools/clippy/clippy_lints/src/derive/derive_partial_eq_without_eq.rs +++ b/src/tools/clippy/clippy_lints/src/derive/derive_partial_eq_without_eq.rs @@ -65,9 +65,9 @@ fn typing_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) -> .map(|p| (p, matches!(p.kind, GenericParamDefKind::Type { .. }))) .collect::>(); - let ty_predicates = tcx.predicates_of(did).predicates; - for (p, _) in ty_predicates { - if let ClauseKind::Trait(p) = p.kind().skip_binder() + let ty_clauses = tcx.clauses_of(did).clauses; + for (c, _) in ty_clauses { + if let ClauseKind::Trait(p) = c.kind().skip_binder() && p.trait_ref.def_id == eq_trait_id && let ty::Param(self_ty) = p.trait_ref.self_ty().kind() { @@ -76,7 +76,7 @@ fn typing_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) -> } } - let param_env = ParamEnv::new(tcx.mk_clauses_from_iter(ty_predicates.iter().map(|&(p, _)| p).chain( + let param_env = ParamEnv::new(tcx.mk_clauses_from_iter(ty_clauses.iter().map(|&(c, _)| c).chain( params.iter().filter(|&&(_, needs_eq)| needs_eq).map(|&(param, _)| { ClauseKind::Trait(TraitPredicate { trait_ref: ty::TraitRef::new(tcx, eq_trait_id, [tcx.mk_param_from_def(param)]), diff --git a/src/tools/clippy/clippy_lints/src/implied_bounds_in_impls.rs b/src/tools/clippy/clippy_lints/src/implied_bounds_in_impls.rs index 780c789d4fe38..04a7c6a74e3c7 100644 --- a/src/tools/clippy/clippy_lints/src/implied_bounds_in_impls.rs +++ b/src/tools/clippy/clippy_lints/src/implied_bounds_in_impls.rs @@ -241,7 +241,7 @@ fn collect_supertrait_bounds<'tcx>(cx: &LateContext<'tcx>, bounds: GenericBounds && let [.., path] = poly_trait.trait_ref.path.segments && poly_trait.bound_generic_params.is_empty() && let Some(trait_def_id) = path.res.opt_def_id() - && let predicates = cx.tcx.explicit_super_predicates_of(trait_def_id).skip_binder() + && let predicates = cx.tcx.explicit_super_clauses_of(trait_def_id).skip_binder() // If the trait has no supertrait, there is no need to collect anything from that bound && !predicates.is_empty() { diff --git a/src/tools/clippy/clippy_lints/src/inherent_impl.rs b/src/tools/clippy/clippy_lints/src/inherent_impl.rs index 7475897852177..7f653d08a66f5 100644 --- a/src/tools/clippy/clippy_lints/src/inherent_impl.rs +++ b/src/tools/clippy/clippy_lints/src/inherent_impl.rs @@ -101,21 +101,21 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl { InherentImplLintScope::Crate => Criterion::Crate, }; let is_test = is_cfg_test(cx.tcx, hir_id) || is_in_cfg_test(cx.tcx, hir_id); - let predicates = { - // Gets the predicates (bounds) for the given impl block, + let clauses = { + // Gets the clauses (bounds) for the given impl block, // sorted for consistent comparison to allow distinguishing between impl blocks // with different generic bounds. - let mut predicates = cx + let mut clauses = cx .tcx - .predicates_of(impl_id) - .predicates + .clauses_of(impl_id) + .clauses .iter() .map(|(clause, _)| *clause) .collect::>(); - predicates.sort_by_key(|c| format!("{c:?}")); - predicates + clauses.sort_by_key(|c| format!("{c:?}")); + clauses }; - match type_map.entry((impl_ty, predicates, criterion, is_test)) { + match type_map.entry((impl_ty, clauses, criterion, is_test)) { Entry::Vacant(e) => { // Store the id for the first impl block of this type. The span is retrieved lazily. e.insert(IdOrSpan::Id(impl_id)); diff --git a/src/tools/clippy/clippy_lints/src/large_stack_frames.rs b/src/tools/clippy/clippy_lints/src/large_stack_frames.rs index dec3f3bcae895..bf4d37ad570e0 100644 --- a/src/tools/clippy/clippy_lints/src/large_stack_frames.rs +++ b/src/tools/clippy/clippy_lints/src/large_stack_frames.rs @@ -3,7 +3,7 @@ use std::{fmt, ops}; use clippy_config::Conf; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::SpanExt; -use clippy_utils::{fn_has_unsatisfiable_preds, is_entrypoint_fn, is_in_test}; +use clippy_utils::{fn_has_unsatisfiable_clauses, is_entrypoint_fn, is_in_test}; use rustc_errors::Diag; use rustc_hir::def_id::LocalDefId; use rustc_hir::intravisit::FnKind; @@ -148,7 +148,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackFrames { ) { let def_id = local_def_id.to_def_id(); // Building MIR for `fn`s with unsatisfiable preds results in ICE. - if fn_has_unsatisfiable_preds(cx, def_id) { + if fn_has_unsatisfiable_clauses(cx, def_id) { return; } diff --git a/src/tools/clippy/clippy_lints/src/methods/iter_on_single_or_empty_collections.rs b/src/tools/clippy/clippy_lints/src/methods/iter_on_single_or_empty_collections.rs index a69671faae783..88ef6d28dac39 100644 --- a/src/tools/clippy/clippy_lints/src/methods/iter_on_single_or_empty_collections.rs +++ b/src/tools/clippy/clippy_lints/src/methods/iter_on_single_or_empty_collections.rs @@ -44,9 +44,9 @@ fn is_arg_ty_unified_in_fn<'tcx>( fn_sig .predicates_id() - .map(|def_id| cx.tcx.predicates_of(def_id)) + .map(|def_id| cx.tcx.clauses_of(def_id)) .is_some_and(|generics| { - generics.predicates.iter().any(|(clause, _)| { + generics.clauses.iter().any(|(clause, _)| { clause .as_projection_clause() .and_then(|p| p.map_bound(|p| p.term.as_type()).transpose()) diff --git a/src/tools/clippy/clippy_lints/src/methods/type_id_on_box.rs b/src/tools/clippy/clippy_lints/src/methods/type_id_on_box.rs index 3e4eae9e53668..2ffe364ff3fed 100644 --- a/src/tools/clippy/clippy_lints/src/methods/type_id_on_box.rs +++ b/src/tools/clippy/clippy_lints/src/methods/type_id_on_box.rs @@ -25,7 +25,7 @@ fn is_subtrait_of_any(cx: &LateContext<'_>, ty: Ty<'_>) -> bool { cx.tcx.is_diagnostic_item(sym::Any, tr.def_id) || cx .tcx - .explicit_super_predicates_of(tr.def_id) + .explicit_super_clauses_of(tr.def_id) .iter_identity_copied() .map(Unnormalized::skip_norm_wip) .any(|(clause, _)| { diff --git a/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs b/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs index 9c6f307cc6594..c454c9e87a3f2 100644 --- a/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs +++ b/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs @@ -737,8 +737,8 @@ fn check_borrow_predicate<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>) { && let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) && cx.tcx.trait_of_assoc(method_def_id).is_none() && let Some(borrow_id) = cx.tcx.get_diagnostic_item(sym::Borrow) - && cx.tcx.predicates_of(method_def_id).predicates.iter().any(|(pred, _)| { - if let ClauseKind::Trait(trait_pred) = pred.kind().skip_binder() + && cx.tcx.clauses_of(method_def_id).clauses.iter().any(|(clause, _)| { + if let ClauseKind::Trait(trait_pred) = clause.kind().skip_binder() && trait_pred.polarity == ty::PredicatePolarity::Positive && trait_pred.trait_ref.def_id == borrow_id { diff --git a/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs b/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs index 743b5123fed6d..d032d53b69902 100644 --- a/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs +++ b/src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs @@ -2,7 +2,7 @@ use clippy_config::Conf; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::msrvs::{self, Msrv}; use clippy_utils::qualify_min_const_fn::is_min_const_fn; -use clippy_utils::{fn_has_unsatisfiable_preds, is_entrypoint_fn, is_from_proc_macro, is_in_test, trait_ref_of_method}; +use clippy_utils::{fn_has_unsatisfiable_clauses, is_entrypoint_fn, is_from_proc_macro, is_in_test, trait_ref_of_method}; use rustc_abi::ExternAbi; use rustc_errors::Applicability; use rustc_hir::def_id::CRATE_DEF_ID; @@ -104,7 +104,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn { } // Building MIR for `fn`s with unsatisfiable preds results in ICE. - if fn_has_unsatisfiable_preds(cx, def_id.to_def_id()) { + if fn_has_unsatisfiable_clauses(cx, def_id.to_def_id()) { return; } diff --git a/src/tools/clippy/clippy_lints/src/missing_const_for_thread_local.rs b/src/tools/clippy/clippy_lints/src/missing_const_for_thread_local.rs index bb5396c7cac91..a7be1e4760230 100644 --- a/src/tools/clippy/clippy_lints/src/missing_const_for_thread_local.rs +++ b/src/tools/clippy/clippy_lints/src/missing_const_for_thread_local.rs @@ -4,7 +4,7 @@ use clippy_utils::macros::macro_backtrace; use clippy_utils::msrvs::{self, Msrv}; use clippy_utils::qualify_min_const_fn::is_min_const_fn; use clippy_utils::source::snippet; -use clippy_utils::{fn_has_unsatisfiable_preds, peel_blocks, sym}; +use clippy_utils::{fn_has_unsatisfiable_clauses, peel_blocks, sym}; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, intravisit}; use rustc_lint::{LateContext, LateLintPass}; @@ -90,7 +90,7 @@ fn is_unreachable(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { #[inline] fn initializer_can_be_made_const(cx: &LateContext<'_>, defid: rustc_span::def_id::DefId, msrv: Msrv) -> bool { // Building MIR for `fn`s with unsatisfiable preds results in ICE. - if !fn_has_unsatisfiable_preds(cx, defid) + if !fn_has_unsatisfiable_clauses(cx, defid) && let mir = cx.tcx.optimized_mir(defid) && let Ok(()) = is_min_const_fn(cx, mir, msrv) { diff --git a/src/tools/clippy/clippy_lints/src/needless_maybe_sized.rs b/src/tools/clippy/clippy_lints/src/needless_maybe_sized.rs index 600e4beba7d2f..b8e40cbf05049 100644 --- a/src/tools/clippy/clippy_lints/src/needless_maybe_sized.rs +++ b/src/tools/clippy/clippy_lints/src/needless_maybe_sized.rs @@ -94,7 +94,7 @@ fn path_to_sized_bound(cx: &LateContext<'_>, trait_bound: &PolyTraitRef<'_>) -> for (predicate, _) in cx .tcx - .explicit_super_predicates_of(trait_def_id) + .explicit_super_clauses_of(trait_def_id) .iter_identity_copied() .map(Unnormalized::skip_norm_wip) { diff --git a/src/tools/clippy/clippy_lints/src/redundant_clone.rs b/src/tools/clippy/clippy_lints/src/redundant_clone.rs index db3be9e64f147..e2fddfd50279c 100644 --- a/src/tools/clippy/clippy_lints/src/redundant_clone.rs +++ b/src/tools/clippy/clippy_lints/src/redundant_clone.rs @@ -3,7 +3,7 @@ use clippy_utils::mir::{LocalUsage, PossibleBorrowerMap, visit_local_usage}; use clippy_utils::res::MaybeDef; use clippy_utils::source::SpanExt; use clippy_utils::ty::{has_drop, is_copy, peel_and_count_ty_refs}; -use clippy_utils::{fn_has_unsatisfiable_preds, sym}; +use clippy_utils::{fn_has_unsatisfiable_clauses, sym}; use rustc_errors::Applicability; use rustc_hir::intravisit::FnKind; use rustc_hir::{Body, FnDecl, LangItem, def_id}; @@ -74,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClone { def_id: LocalDefId, ) { // Building MIR for `fn`s with unsatisfiable preds results in ICE. - if fn_has_unsatisfiable_preds(cx, def_id.to_def_id()) { + if fn_has_unsatisfiable_clauses(cx, def_id.to_def_id()) { return; } diff --git a/src/tools/clippy/clippy_lints/src/unit_return_expecting_ord.rs b/src/tools/clippy/clippy_lints/src/unit_return_expecting_ord.rs index 13baa378910d9..66f5bad854027 100644 --- a/src/tools/clippy/clippy_lints/src/unit_return_expecting_ord.rs +++ b/src/tools/clippy/clippy_lints/src/unit_return_expecting_ord.rs @@ -3,7 +3,7 @@ use rustc_hir::def_id::DefId; use rustc_hir::{Closure, Expr, ExprKind, StmtKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; -use rustc_middle::ty::{ClauseKind, GenericPredicates, ProjectionPredicate, TraitPredicate}; +use rustc_middle::ty::{ClauseKind, GenericClauses, ProjectionPredicate, TraitPredicate}; use rustc_session::declare_lint_pass; use rustc_span::{BytePos, Span, Symbol, sym}; @@ -36,19 +36,18 @@ declare_clippy_lint! { declare_lint_pass!(UnitReturnExpectingOrd => [UNIT_RETURN_EXPECTING_ORD]); -// For each fn get_trait_predicates_for_trait_ids<'tcx>( cx: &LateContext<'tcx>, - generics: GenericPredicates<'tcx>, + generics: GenericClauses<'tcx>, trait_ids: &[Option], // At least 2 ids ) -> [Vec>; 3] { debug_assert!(trait_ids.len() >= 2); let mut preds = [Vec::new(), Vec::new(), Vec::new()]; - for (pred, _) in generics.predicates { - if let ClauseKind::Trait(poly_trait_pred) = pred.kind().skip_binder() { + for (clause, _) in generics.clauses { + if let ClauseKind::Trait(poly_trait_pred) = clause.kind().skip_binder() { let trait_pred = cx .tcx - .instantiate_bound_regions_with_erased(pred.kind().rebind(poly_trait_pred)); + .instantiate_bound_regions_with_erased(clause.kind().rebind(poly_trait_pred)); for (i, tid) in trait_ids.iter().enumerate() { if let Some(tid) = tid && *tid == trait_pred.trait_ref.def_id @@ -63,14 +62,14 @@ fn get_trait_predicates_for_trait_ids<'tcx>( fn get_projection_pred<'tcx>( cx: &LateContext<'tcx>, - generics: GenericPredicates<'tcx>, + generics: GenericClauses<'tcx>, trait_pred: TraitPredicate<'tcx>, ) -> Option> { - generics.predicates.iter().find_map(|(proj_pred, _)| { - if let ClauseKind::Projection(pred) = proj_pred.kind().skip_binder() { + generics.clauses.iter().find_map(|(clause, _)| { + if let ClauseKind::Projection(pred) = clause.kind().skip_binder() { let projection_pred = cx .tcx - .instantiate_bound_regions_with_erased(proj_pred.kind().rebind(pred)); + .instantiate_bound_regions_with_erased(clause.kind().rebind(pred)); if projection_pred.projection_term.args == trait_pred.trait_ref.args { return Some(projection_pred); } @@ -90,7 +89,7 @@ fn get_args_to_check<'tcx>( let mut args_to_check = Vec::new(); if let Some(def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) { let fn_sig = cx.tcx.fn_sig(def_id).instantiate_identity().skip_norm_wip(); - let generics = cx.tcx.predicates_of(def_id); + let generics = cx.tcx.clauses_of(def_id); let [fn_mut_preds, ord_preds, partial_ord_preds] = get_trait_predicates_for_trait_ids(cx, generics, &[Some(fn_mut_trait), ord_trait, partial_ord_trait]); if fn_mut_preds.is_empty() { diff --git a/src/tools/clippy/clippy_lints/src/useless_conversion.rs b/src/tools/clippy/clippy_lints/src/useless_conversion.rs index 2961ee7081533..e2dd0a8d2f3dd 100644 --- a/src/tools/clippy/clippy_lints/src/useless_conversion.rs +++ b/src/tools/clippy/clippy_lints/src/useless_conversion.rs @@ -90,8 +90,8 @@ fn into_iter_bound<'tcx>( ) -> Option { let mut into_iter_span = None; - for (pred, span) in cx.tcx.explicit_predicates_of(fn_did).predicates { - if let ty::ClauseKind::Trait(tr) = pred.kind().skip_binder() + for (clause, span) in cx.tcx.explicit_clauses_of(fn_did).clauses { + if let ty::ClauseKind::Trait(tr) = clause.kind().skip_binder() && tr.self_ty().is_param(param_index) { if tr.def_id() == into_iter_did { diff --git a/src/tools/clippy/clippy_utils/src/consts.rs b/src/tools/clippy/clippy_utils/src/consts.rs index b6dc5dc38cd17..cb04f4373ec4f 100644 --- a/src/tools/clippy/clippy_utils/src/consts.rs +++ b/src/tools/clippy/clippy_utils/src/consts.rs @@ -893,7 +893,7 @@ impl<'tcx> ConstEvalCtxt<'tcx> { // Don't try to fully evaluate consts inside code whose bounds can't be satisfied. if self .tcx - .instantiate_and_check_impossible_predicates((owner_def_id, identity_args)) + .instantiate_and_check_impossible_clauses((owner_def_id, identity_args)) { return None; } diff --git a/src/tools/clippy/clippy_utils/src/eager_or_lazy.rs b/src/tools/clippy/clippy_utils/src/eager_or_lazy.rs index 1c133fccdb308..9e9ae945ee16f 100644 --- a/src/tools/clippy/clippy_utils/src/eager_or_lazy.rs +++ b/src/tools/clippy/clippy_utils/src/eager_or_lazy.rs @@ -11,7 +11,7 @@ use crate::consts::{ConstEvalCtxt, FullInt}; use crate::sym; -use crate::ty::all_predicates_of; +use crate::ty::all_clauses_of; use crate::visitors::is_const_evaluatable; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; @@ -78,7 +78,7 @@ fn fn_eagerness(tcx: TyCtxt<'_>, fn_id: DefId, name: Symbol, have_one_arg: bool) .kind(), ty::Param(_) ) - }) && all_predicates_of(tcx, fn_id).all(|(pred, _)| match pred.kind().skip_binder() { + }) && all_clauses_of(tcx, fn_id).all(|(pred, _)| match pred.kind().skip_binder() { ty::ClauseKind::Trait(pred) => tcx.trait_def(pred.trait_ref.def_id).is_marker, _ => true, }) && subs.types().all(|x| matches!(x.peel_refs().kind(), ty::Param(_))) diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index 82752b3d73766..969f083041485 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -2093,15 +2093,15 @@ pub fn is_trait_impl_item(cx: &LateContext<'_>, hir_id: HirId) -> bool { /// for _ in 2i32 {} /// } /// ``` -pub fn fn_has_unsatisfiable_preds(cx: &LateContext<'_>, did: DefId) -> bool { +pub fn fn_has_unsatisfiable_clauses(cx: &LateContext<'_>, did: DefId) -> bool { use rustc_trait_selection::traits; - let predicates = cx + let clauses = cx .tcx - .predicates_of(did) - .predicates + .clauses_of(did) + .clauses .iter() - .filter_map(|(p, _)| if p.is_global() { Some(*p) } else { None }); - traits::impossible_predicates(cx.tcx, traits::elaborate(cx.tcx, predicates).collect::>()) + .filter_map(|(c, _)| if c.is_global() { Some(*c) } else { None }); + traits::impossible_clauses(cx.tcx, traits::elaborate(cx.tcx, clauses).collect::>()) } /// Returns the `DefId` of the callee if the given expression is a function or method call. diff --git a/src/tools/clippy/clippy_utils/src/ty/mod.rs b/src/tools/clippy/clippy_utils/src/ty/mod.rs index f9a21deeca19d..1ce756da41afc 100644 --- a/src/tools/clippy/clippy_utils/src/ty/mod.rs +++ b/src/tools/clippy/clippy_utils/src/ty/mod.rs @@ -617,13 +617,13 @@ fn is_uninit_value_valid_for_ty_fallback<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'t } /// Gets an iterator over all predicates which apply to the given item. -pub fn all_predicates_of(tcx: TyCtxt<'_>, id: DefId) -> impl Iterator, Span)> { +pub fn all_clauses_of(tcx: TyCtxt<'_>, id: DefId) -> impl Iterator, Span)> { let mut next_id = Some(id); iter::from_fn(move || { next_id.take().map(|id| { - let preds = tcx.predicates_of(id); - next_id = preds.parent; - preds.predicates.iter() + let gen_clauses = tcx.clauses_of(id); + next_id = gen_clauses.parent; + gen_clauses.clauses.iter() }) }) .flatten() diff --git a/tests/codegen-units/item-collection/drop-glue-eager.rs b/tests/codegen-units/item-collection/drop-glue-eager.rs index ae9536887917e..7039dbbbe679a 100644 --- a/tests/codegen-units/item-collection/drop-glue-eager.rs +++ b/tests/codegen-units/item-collection/drop-glue-eager.rs @@ -45,7 +45,7 @@ struct StructWithDropAndLt<'a> { x: &'a i32, } -// Make sure we don't ICE when checking impossible predicates for the struct. +// Make sure we don't ICE when checking impossible clauses for the struct. // Regression test for . //~ MONO_ITEM fn std::ptr::drop_glue::> - shim(Some(StructWithLtAndPredicate<'_>)) struct StructWithLtAndPredicate<'a: 'a> { diff --git a/tests/incremental/clean.rs b/tests/incremental/clean.rs index 1ec34ff9c9046..64db90210ebc7 100644 --- a/tests/incremental/clean.rs +++ b/tests/incremental/clean.rs @@ -27,13 +27,13 @@ mod y { use x; #[rustc_clean( - except="hir_owner,generics_of,predicates_of,type_of,fn_sig", + except="hir_owner,generics_of,clauses_of,type_of,fn_sig", cfg="bfail2", )] pub fn y() { //[bfail2]~^ ERROR `hir_owner(y)` should be dirty but is not //[bfail2]~| ERROR `generics_of(y)` should be dirty but is not - //[bfail2]~| ERROR `predicates_of(y)` should be dirty but is not + //[bfail2]~| ERROR `clauses_of(y)` should be dirty but is not //[bfail2]~| ERROR `type_of(y)` should be dirty but is not //[bfail2]~| ERROR `fn_sig(y)` should be dirty but is not //[bfail2]~| ERROR `typeck_root(y)` should be clean but is not diff --git a/tests/incremental/cyclic-trait-hierarchy.rs b/tests/incremental/cyclic-trait-hierarchy.rs index 4b0570361c1b7..68a65715a8624 100644 --- a/tests/incremental/cyclic-trait-hierarchy.rs +++ b/tests/incremental/cyclic-trait-hierarchy.rs @@ -6,7 +6,7 @@ pub trait T2 {} #[cfg(bfail2)] pub trait T2: T1 {} -//[bfail2]~^ ERROR cycle detected when computing the super predicates of `T2` +//[bfail2]~^ ERROR cycle detected when computing the super clauses of `T2` pub trait T1: T2 {} diff --git a/tests/incremental/hashes/enum_defs.rs b/tests/incremental/hashes/enum_defs.rs index ed239b301a36d..93b90ab5b5653 100644 --- a/tests/incremental/hashes/enum_defs.rs +++ b/tests/incremental/hashes/enum_defs.rs @@ -412,9 +412,9 @@ enum EnumChangeNameOfTypeParameter { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(cfg="bpass2", except="hir_owner,generics_of,predicates_of,type_of")] +#[rustc_clean(cfg="bpass2", except="hir_owner,generics_of,clauses_of,type_of")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner,generics_of,predicates_of,type_of")] +#[rustc_clean(cfg="bpass5", except="hir_owner,generics_of,clauses_of,type_of")] #[rustc_clean(cfg="bpass6")] enum EnumChangeNameOfTypeParameter { Variant1(T), @@ -430,9 +430,9 @@ enum EnumAddTypeParameter { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(cfg="bpass2", except="hir_owner,generics_of,predicates_of,type_of")] +#[rustc_clean(cfg="bpass2", except="hir_owner,generics_of,clauses_of,type_of")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner,generics_of,predicates_of,type_of")] +#[rustc_clean(cfg="bpass5", except="hir_owner,generics_of,clauses_of,type_of")] #[rustc_clean(cfg="bpass6")] enum EnumAddTypeParameter { Variant1(S), @@ -485,9 +485,9 @@ enum EnumAddLifetimeParameterBound<'a, 'b> { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(cfg="bpass2", except="hir_owner,predicates_of")] +#[rustc_clean(cfg="bpass2", except="hir_owner,clauses_of")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner,predicates_of")] +#[rustc_clean(cfg="bpass5", except="hir_owner,clauses_of")] #[rustc_clean(cfg="bpass6")] enum EnumAddLifetimeParameterBound<'a, 'b: 'a> { Variant1(&'a u32), @@ -502,9 +502,9 @@ enum EnumAddLifetimeBoundToParameter<'a, T> { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(cfg="bpass2", except="hir_owner,predicates_of")] +#[rustc_clean(cfg="bpass2", except="hir_owner,clauses_of")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner,predicates_of")] +#[rustc_clean(cfg="bpass5", except="hir_owner,clauses_of")] #[rustc_clean(cfg="bpass6")] enum EnumAddLifetimeBoundToParameter<'a, T: 'a> { Variant1(T), @@ -520,9 +520,9 @@ enum EnumAddTraitBound { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(cfg="bpass2", except="hir_owner,generics_of,predicates_of,type_of")] +#[rustc_clean(cfg="bpass2", except="hir_owner,generics_of,clauses_of,type_of")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner,generics_of,predicates_of,type_of")] +#[rustc_clean(cfg="bpass5", except="hir_owner,generics_of,clauses_of,type_of")] #[rustc_clean(cfg="bpass6")] enum EnumAddTraitBound { Variant1(T), @@ -538,9 +538,9 @@ enum EnumAddLifetimeParameterBoundWhere<'a, 'b> { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(cfg="bpass2", except="hir_owner,predicates_of")] +#[rustc_clean(cfg="bpass2", except="hir_owner,clauses_of")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner,predicates_of")] +#[rustc_clean(cfg="bpass5", except="hir_owner,clauses_of")] #[rustc_clean(cfg="bpass6")] enum EnumAddLifetimeParameterBoundWhere<'a, 'b> where 'b: 'a { Variant1(&'a u32), @@ -557,9 +557,9 @@ enum EnumAddLifetimeBoundToParameterWhere<'a, T> { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(cfg="bpass2", except="hir_owner,predicates_of")] +#[rustc_clean(cfg="bpass2", except="hir_owner,clauses_of")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner,predicates_of")] +#[rustc_clean(cfg="bpass5", except="hir_owner,clauses_of")] #[rustc_clean(cfg="bpass6")] enum EnumAddLifetimeBoundToParameterWhere<'a, T> where T: 'a { Variant1(T), @@ -575,9 +575,9 @@ enum EnumAddTraitBoundWhere { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(cfg="bpass2", except="hir_owner,generics_of,predicates_of,type_of")] +#[rustc_clean(cfg="bpass2", except="hir_owner,generics_of,clauses_of,type_of")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner,generics_of,predicates_of,type_of")] +#[rustc_clean(cfg="bpass5", except="hir_owner,generics_of,clauses_of,type_of")] #[rustc_clean(cfg="bpass6")] enum EnumAddTraitBoundWhere where T: Sync { Variant1(T), @@ -688,9 +688,9 @@ mod change_trait_bound_indirectly { #[cfg(not(any(bpass1,bpass4)))] use super::ReferencedTrait2 as Trait; - #[rustc_clean(cfg="bpass2", except="hir_owner,predicates_of")] + #[rustc_clean(cfg="bpass2", except="hir_owner,clauses_of")] #[rustc_clean(cfg="bpass3")] - #[rustc_clean(cfg="bpass5", except="hir_owner,predicates_of")] + #[rustc_clean(cfg="bpass5", except="hir_owner,clauses_of")] #[rustc_clean(cfg="bpass6")] enum Enum { Variant1(T) @@ -706,9 +706,9 @@ mod change_trait_bound_indirectly_where { #[cfg(not(any(bpass1,bpass4)))] use super::ReferencedTrait2 as Trait; - #[rustc_clean(cfg="bpass2", except="hir_owner,predicates_of")] + #[rustc_clean(cfg="bpass2", except="hir_owner,clauses_of")] #[rustc_clean(cfg="bpass3")] - #[rustc_clean(cfg="bpass5", except="hir_owner,predicates_of")] + #[rustc_clean(cfg="bpass5", except="hir_owner,clauses_of")] #[rustc_clean(cfg="bpass6")] enum Enum where T: Trait { Variant1(T) diff --git a/tests/incremental/hashes/function_interfaces.rs b/tests/incremental/hashes/function_interfaces.rs index 8e9830e0d83d4..229d515ffdd18 100644 --- a/tests/incremental/hashes/function_interfaces.rs +++ b/tests/incremental/hashes/function_interfaces.rs @@ -140,12 +140,12 @@ pub fn type_parameter () {} #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean( cfg = "bpass2", - except = "hir_owner, generics_of, type_of, predicates_of" + except = "hir_owner, generics_of, type_of, clauses_of" )] #[rustc_clean(cfg = "bpass3")] #[rustc_clean( cfg = "bpass5", - except = "hir_owner, generics_of, type_of, predicates_of" + except = "hir_owner, generics_of, type_of, clauses_of" )] #[rustc_clean(cfg = "bpass6")] pub fn type_parameter() {} @@ -168,7 +168,7 @@ pub fn lifetime_parameter<'a>() {} pub fn trait_bound() {} #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(cfg = "bpass2", except = "hir_owner, predicates_of")] +#[rustc_clean(cfg = "bpass2", except = "hir_owner, clauses_of")] #[rustc_clean(cfg = "bpass3")] pub fn trait_bound() {} @@ -178,9 +178,9 @@ pub fn trait_bound() {} pub fn builtin_bound() {} #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(cfg = "bpass2", except = "hir_owner, predicates_of")] +#[rustc_clean(cfg = "bpass2", except = "hir_owner, clauses_of")] #[rustc_clean(cfg = "bpass3")] -#[rustc_clean(cfg = "bpass5", except = "hir_owner, predicates_of")] +#[rustc_clean(cfg = "bpass5", except = "hir_owner, clauses_of")] #[rustc_clean(cfg = "bpass6")] pub fn builtin_bound() {} @@ -192,12 +192,12 @@ pub fn lifetime_bound<'a, T>() {} #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean( cfg = "bpass2", - except = "hir_owner, generics_of, type_of, predicates_of,fn_sig" + except = "hir_owner, generics_of, type_of, clauses_of,fn_sig" )] #[rustc_clean(cfg = "bpass3")] #[rustc_clean( cfg = "bpass5", - except = "hir_owner, generics_of, type_of, predicates_of,fn_sig,optimized_mir" + except = "hir_owner, generics_of, type_of, clauses_of,fn_sig,optimized_mir" )] #[rustc_clean(cfg = "bpass6")] pub fn lifetime_bound<'a, T: 'a>() {} @@ -208,7 +208,7 @@ pub fn lifetime_bound<'a, T: 'a>() {} pub fn second_trait_bound() {} #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(cfg = "bpass2", except = "hir_owner, predicates_of")] +#[rustc_clean(cfg = "bpass2", except = "hir_owner, clauses_of")] #[rustc_clean(cfg = "bpass3")] pub fn second_trait_bound() {} @@ -220,7 +220,7 @@ pub fn second_builtin_bound() {} #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg = "bpass2", except = "hir_owner")] #[rustc_clean(cfg = "bpass3")] -#[rustc_clean(cfg = "bpass5", except = "hir_owner, predicates_of")] +#[rustc_clean(cfg = "bpass5", except = "hir_owner, clauses_of")] #[rustc_clean(cfg = "bpass6")] pub fn second_builtin_bound() {} @@ -232,12 +232,12 @@ pub fn second_lifetime_bound<'a, 'b, T: 'a >() {} #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean( cfg = "bpass2", - except = "hir_owner, generics_of, type_of, predicates_of,fn_sig" + except = "hir_owner, generics_of, type_of, clauses_of,fn_sig" )] #[rustc_clean(cfg = "bpass3")] #[rustc_clean( cfg = "bpass5", - except = "hir_owner, generics_of, type_of, predicates_of,fn_sig" + except = "hir_owner, generics_of, type_of, clauses_of,fn_sig" )] #[rustc_clean(cfg = "bpass6")] pub fn second_lifetime_bound<'a, 'b, T: 'a + 'b>() {} @@ -385,9 +385,9 @@ pub mod change_trait_bound_indirectly { #[cfg(not(any(bpass1,bpass4)))] use super::ReferencedTrait2 as Trait; - #[rustc_clean(cfg = "bpass2", except = "hir_owner, predicates_of")] + #[rustc_clean(cfg = "bpass2", except = "hir_owner, clauses_of")] #[rustc_clean(cfg = "bpass3")] - #[rustc_clean(cfg = "bpass5", except = "hir_owner, predicates_of")] + #[rustc_clean(cfg = "bpass5", except = "hir_owner, clauses_of")] #[rustc_clean(cfg = "bpass6")] pub fn indirect_trait_bound(p: T) {} } @@ -400,9 +400,9 @@ pub mod change_trait_bound_indirectly_in_where_clause { #[cfg(not(any(bpass1,bpass4)))] use super::ReferencedTrait2 as Trait; - #[rustc_clean(cfg = "bpass2", except = "hir_owner, predicates_of")] + #[rustc_clean(cfg = "bpass2", except = "hir_owner, clauses_of")] #[rustc_clean(cfg = "bpass3")] - #[rustc_clean(cfg = "bpass5", except = "hir_owner, predicates_of")] + #[rustc_clean(cfg = "bpass5", except = "hir_owner, clauses_of")] #[rustc_clean(cfg = "bpass6")] pub fn indirect_trait_bound_where(p: T) where diff --git a/tests/incremental/hashes/inherent_impls.rs b/tests/incremental/hashes/inherent_impls.rs index edda93ec55127..ade4554372cc1 100644 --- a/tests/incremental/hashes/inherent_impls.rs +++ b/tests/incremental/hashes/inherent_impls.rs @@ -466,12 +466,12 @@ impl Foo { // ------------------------------------------------- // ----------- // -------------- - // ---------------------------------------------------------------- + // ------------------------------------------------------------- // // ------------------------- // ----------- // -------------- - // ---------------------------------------------------------------- + // ------------------------------------------------------------- // // ------------------------- pub fn add_type_parameter_to_method (&self) { } @@ -494,12 +494,12 @@ impl Foo { // appear dirty, that might be the cause. -nmatsakis #[rustc_clean( cfg="bpass2", - except="hir_owner,generics_of,predicates_of,type_of", + except="hir_owner,generics_of,clauses_of,type_of", )] #[rustc_clean(cfg="bpass3")] #[rustc_clean( cfg="bpass5", - except="hir_owner,generics_of,predicates_of,type_of", + except="hir_owner,generics_of,clauses_of,type_of", )] #[rustc_clean(cfg="bpass6")] pub fn add_type_parameter_to_method(&self) { } @@ -512,12 +512,12 @@ impl Foo { impl Foo { //------------ //--------------- - //----------------------------------------------------------------------- + //-------------------------------------------------------------------- // //-------------------------- //------------ //--------------- - //----------------------------------------------------------------------- + //-------------------------------------------------------------------- // //-------------------------- pub fn add_lifetime_bound_to_lifetime_param_of_method<'a, 'b >(&self) { } @@ -531,12 +531,12 @@ impl Foo { impl Foo { #[rustc_clean( cfg="bpass2", - except="hir_owner,generics_of,predicates_of,type_of,fn_sig" + except="hir_owner,generics_of,clauses_of,type_of,fn_sig" )] #[rustc_clean(cfg="bpass3")] #[rustc_clean( cfg="bpass5", - except="hir_owner,generics_of,predicates_of,type_of,fn_sig" + except="hir_owner,generics_of,clauses_of,type_of,fn_sig" )] #[rustc_clean(cfg="bpass6")] pub fn add_lifetime_bound_to_lifetime_param_of_method<'a, 'b: 'a>(&self) { } @@ -558,12 +558,12 @@ impl Foo { // ------------------------------------------------- // ----------- // -------------- - // ---------------------------------------------------------------------- + // ------------------------------------------------------------------- // // ------------------------- // ----------- // -------------- - // ---------------------------------------------------------------------- + // ------------------------------------------------------------------- // // ------------------------- pub fn add_lifetime_bound_to_type_param_of_method<'a, T >(&self) { } @@ -586,12 +586,12 @@ impl Foo { // appear dirty, that might be the cause. -nmatsakis #[rustc_clean( cfg="bpass2", - except="hir_owner,generics_of,predicates_of,type_of,fn_sig" + except="hir_owner,generics_of,clauses_of,type_of,fn_sig" )] #[rustc_clean(cfg="bpass3")] #[rustc_clean( cfg="bpass5", - except="hir_owner,generics_of,predicates_of,type_of,fn_sig" + except="hir_owner,generics_of,clauses_of,type_of,fn_sig" )] #[rustc_clean(cfg="bpass6")] pub fn add_lifetime_bound_to_type_param_of_method<'a, T: 'a>(&self) { } @@ -611,9 +611,9 @@ impl Foo { // ------------------------------------------------------------ // ------------------------------------------------------ // ------------------------------------------------- - // --------------------------------------------------------------------- + // ------------------------------------------------------------------ // ------------------------- - // --------------------------------------------------------------------- + // ------------------------------------------------------------------ // ------------------------- pub fn add_trait_bound_to_type_param_of_method(&self) { } } @@ -633,9 +633,9 @@ impl Foo { // generics before the body, then the `HirId` for things in the // body will be affected. So if you start to see `typeck_root` // appear dirty, that might be the cause. -nmatsakis - #[rustc_clean(cfg="bpass2", except="hir_owner,predicates_of")] + #[rustc_clean(cfg="bpass2", except="hir_owner,clauses_of")] #[rustc_clean(cfg="bpass3")] - #[rustc_clean(cfg="bpass5", except="hir_owner,predicates_of")] + #[rustc_clean(cfg="bpass5", except="hir_owner,clauses_of")] #[rustc_clean(cfg="bpass6")] pub fn add_trait_bound_to_type_param_of_method(&self) { } } diff --git a/tests/incremental/hashes/struct_defs.rs b/tests/incremental/hashes/struct_defs.rs index f3e6a62294619..a1fd82fca2f27 100644 --- a/tests/incremental/hashes/struct_defs.rs +++ b/tests/incremental/hashes/struct_defs.rs @@ -169,9 +169,9 @@ struct AddLifetimeParameter<'a, 'b>(&'a f32, &'b f64); struct AddLifetimeParameterBound<'a, 'b>(&'a f32, &'b f64); #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] struct AddLifetimeParameterBound<'a, 'b: 'a>( &'a f32, @@ -182,9 +182,9 @@ struct AddLifetimeParameterBound<'a, 'b: 'a>( struct AddLifetimeParameterBoundWhereClause<'a, 'b>(&'a f32, &'b f64); #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] struct AddLifetimeParameterBoundWhereClause<'a, 'b>( &'a f32, @@ -198,9 +198,9 @@ struct AddLifetimeParameterBoundWhereClause<'a, 'b>( struct AddTypeParameter(T1, T1); #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,type_of,generics_of,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,type_of,generics_of,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,type_of,generics_of,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,type_of,generics_of,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] struct AddTypeParameter( // The field contains the parent's Generics, so it's dirty even though its @@ -216,9 +216,9 @@ struct AddTypeParameter( struct AddTypeParameterBound(T); #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] struct AddTypeParameterBound( T @@ -229,9 +229,9 @@ struct AddTypeParameterBound( struct AddTypeParameterBoundWhereClause(T); #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] struct AddTypeParameterBoundWhereClause( T @@ -311,9 +311,9 @@ mod change_trait_bound_indirectly { #[cfg(not(any(bpass1,bpass4)))] use super::ReferencedTrait2 as Trait; - #[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] + #[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] - #[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] + #[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] struct Struct(T); } @@ -325,9 +325,9 @@ mod change_trait_bound_indirectly_in_where_clause { #[cfg(not(any(bpass1,bpass4)))] use super::ReferencedTrait2 as Trait; - #[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] + #[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] - #[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] + #[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] struct Struct(T) where T : Trait; } diff --git a/tests/incremental/hashes/trait_defs.rs b/tests/incremental/hashes/trait_defs.rs index bb66ad51d993e..3c6021105e893 100644 --- a/tests/incremental/hashes/trait_defs.rs +++ b/tests/incremental/hashes/trait_defs.rs @@ -31,7 +31,7 @@ trait TraitVisibility { } #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(cfg="bpass5", except="hir_owner,predicates_of")] +#[rustc_clean(cfg="bpass5", except="hir_owner,clauses_of")] #[rustc_clean(cfg="bpass6")] pub trait TraitVisibility { } @@ -44,7 +44,7 @@ trait TraitUnsafety { } #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(except="hir_owner", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] unsafe trait TraitUnsafety { } @@ -58,7 +58,7 @@ trait TraitAddMethod { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,associated_item_def_ids,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,associated_item_def_ids,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] pub trait TraitAddMethod { fn method(); @@ -75,7 +75,7 @@ trait TraitChangeMethodName { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,associated_item_def_ids,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,associated_item_def_ids,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitChangeMethodName { fn methodChanged(); @@ -96,7 +96,7 @@ trait TraitAddReturnType { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddReturnType { #[rustc_clean(except="hir_owner,fn_sig", cfg="bpass2")] @@ -121,7 +121,7 @@ trait TraitChangeReturnType { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitChangeReturnType { #[rustc_clean(except="hir_owner,fn_sig", cfg="bpass2")] @@ -146,7 +146,7 @@ trait TraitAddParameterToMethod { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddParameterToMethod { #[rustc_clean(except="hir_owner,fn_sig", cfg="bpass2")] @@ -178,7 +178,7 @@ trait TraitChangeMethodParameterName { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitChangeMethodParameterName { // FIXME(#38501) This should preferably always be clean. @@ -210,7 +210,7 @@ trait TraitChangeMethodParameterType { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitChangeMethodParameterType { #[rustc_clean(except="hir_owner,fn_sig", cfg="bpass2")] @@ -235,7 +235,7 @@ trait TraitChangeMethodParameterTypeRef { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitChangeMethodParameterTypeRef { #[rustc_clean(except="hir_owner,fn_sig", cfg="bpass2")] @@ -260,7 +260,7 @@ trait TraitChangeMethodParametersOrder { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitChangeMethodParametersOrder { #[rustc_clean(except="hir_owner,fn_sig", cfg="bpass2")] @@ -285,7 +285,7 @@ trait TraitAddMethodAutoImplementation { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddMethodAutoImplementation { #[rustc_clean(except="hir_owner", cfg="bpass2")] @@ -329,7 +329,7 @@ trait TraitChangeModeSelfRefToMut { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitChangeModeSelfRefToMut { #[rustc_clean(except="hir_owner,fn_sig", cfg="bpass2")] @@ -377,7 +377,7 @@ trait TraitChangeModeSelfOwnToRef { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitChangeModeSelfOwnToRef { #[rustc_clean(except="hir_owner,fn_sig,generics_of", cfg="bpass2")] @@ -402,7 +402,7 @@ trait TraitAddUnsafeModifier { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddUnsafeModifier { #[rustc_clean(except="hir_owner,fn_sig", cfg="bpass2")] @@ -427,7 +427,7 @@ trait TraitAddExternModifier { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddExternModifier { #[rustc_clean(except="hir_owner,fn_sig", cfg="bpass2")] @@ -452,7 +452,7 @@ trait TraitChangeExternCToExternSystem { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitChangeExternCToRustIntrinsic { #[rustc_clean(except="hir_owner,fn_sig", cfg="bpass2")] @@ -467,10 +467,10 @@ trait TraitChangeExternCToRustIntrinsic { // Add type parameter to method #[cfg(any(bpass1,bpass4))] trait TraitAddTypeParameterToMethod { - // -------------------------------------------------------------------------- + // ----------------------------------------------------------------------- // --------------- // ------------------------- - // -------------------------------------------------------------------------- + // ----------------------------------------------------------------------- // --------------- // ------------------------- fn method (); @@ -479,13 +479,13 @@ trait TraitAddTypeParameterToMethod { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddTypeParameterToMethod { - #[rustc_clean(except="hir_owner,generics_of,predicates_of,type_of", + #[rustc_clean(except="hir_owner,generics_of,clauses_of,type_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] - #[rustc_clean(except="hir_owner,generics_of,predicates_of,type_of", + #[rustc_clean(except="hir_owner,generics_of,clauses_of,type_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] fn method(); @@ -506,7 +506,7 @@ trait TraitAddLifetimeParameterToMethod { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddLifetimeParameterToMethod { #[rustc_clean(except="hir_owner,fn_sig,generics_of", cfg="bpass2")] @@ -525,9 +525,9 @@ trait ReferencedTrait1 { } // Add trait bound to method type parameter #[cfg(any(bpass1,bpass4))] trait TraitAddTraitBoundToMethodTypeParameter { - // --------------------------------------------------------------------- + // ------------------------------------------------------------------ // ------------------------- - // --------------------------------------------------------------------- + // ------------------------------------------------------------------ // ------------------------- fn method(); } @@ -535,12 +535,12 @@ trait TraitAddTraitBoundToMethodTypeParameter { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddTraitBoundToMethodTypeParameter { - #[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] + #[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] - #[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] + #[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] fn method(); } @@ -552,7 +552,7 @@ trait TraitAddTraitBoundToMethodTypeParameter { trait TraitAddBuiltinBoundToMethodTypeParameter { // --------------------------------------------------------------------- // ------------------------- - // --------------------------------------------------------------------- + // ------------------------------------------------------------------ // ------------------------- fn method(); } @@ -560,12 +560,12 @@ trait TraitAddBuiltinBoundToMethodTypeParameter { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddBuiltinBoundToMethodTypeParameter { #[rustc_clean(except="hir_owner", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] - #[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] + #[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] fn method(); } @@ -576,12 +576,12 @@ trait TraitAddBuiltinBoundToMethodTypeParameter { #[cfg(any(bpass1,bpass4))] trait TraitAddLifetimeBoundToMethodLifetimeParameter { // ----------- - // ----------------------------------------------------------------------- + // -------------------------------------------------------------------- // -------------- // // ------------------------- // ----------- - // ----------------------------------------------------------------------- + // -------------------------------------------------------------------- // -------------- // // ------------------------- @@ -591,16 +591,16 @@ trait TraitAddLifetimeBoundToMethodLifetimeParameter { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddLifetimeBoundToMethodLifetimeParameter { #[rustc_clean( - except="hir_owner,generics_of,predicates_of,fn_sig,type_of", + except="hir_owner,generics_of,clauses_of,fn_sig,type_of", cfg="bpass2", )] #[rustc_clean(cfg="bpass3")] #[rustc_clean( - except="hir_owner,generics_of,predicates_of,fn_sig,type_of", + except="hir_owner,generics_of,clauses_of,fn_sig,type_of", cfg="bpass5", )] #[rustc_clean(cfg="bpass6")] @@ -612,9 +612,9 @@ trait TraitAddLifetimeBoundToMethodLifetimeParameter { // Add second trait bound to method type parameter #[cfg(any(bpass1,bpass4))] trait TraitAddSecondTraitBoundToMethodTypeParameter { - // --------------------------------------------------------------------- + // ------------------------------------------------------------------ // ------------------------- - // --------------------------------------------------------------------- + // ------------------------------------------------------------------ // ------------------------- fn method(); } @@ -622,12 +622,12 @@ trait TraitAddSecondTraitBoundToMethodTypeParameter { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddSecondTraitBoundToMethodTypeParameter { - #[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] + #[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] - #[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] + #[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] fn method(); } @@ -637,9 +637,9 @@ trait TraitAddSecondTraitBoundToMethodTypeParameter { // Add second builtin bound to method type parameter #[cfg(any(bpass1,bpass4))] trait TraitAddSecondBuiltinBoundToMethodTypeParameter { - // --------------------------------------------------------------------- + // ------------------------------------------------------------------ // ------------------------- - // --------------------------------------------------------------------- + // ------------------------------------------------------------------ // ------------------------- fn method(); } @@ -647,12 +647,12 @@ trait TraitAddSecondBuiltinBoundToMethodTypeParameter { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddSecondBuiltinBoundToMethodTypeParameter { - #[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] + #[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] - #[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] + #[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] fn method(); } @@ -663,12 +663,12 @@ trait TraitAddSecondBuiltinBoundToMethodTypeParameter { #[cfg(any(bpass1,bpass4))] trait TraitAddSecondLifetimeBoundToMethodLifetimeParameter { // ----------- - // ----------------------------------------------------------------------- + // -------------------------------------------------------------------- // -------------- // // ------------------------- // ----------- - // ----------------------------------------------------------------------- + // -------------------------------------------------------------------- // -------------- // // ------------------------- @@ -678,16 +678,16 @@ trait TraitAddSecondLifetimeBoundToMethodLifetimeParameter { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddSecondLifetimeBoundToMethodLifetimeParameter { #[rustc_clean( - except="hir_owner,generics_of,predicates_of,fn_sig,type_of", + except="hir_owner,generics_of,clauses_of,fn_sig,type_of", cfg="bpass2", )] #[rustc_clean(cfg="bpass3")] #[rustc_clean( - except="hir_owner,generics_of,predicates_of,fn_sig,type_of", + except="hir_owner,generics_of,clauses_of,fn_sig,type_of", cfg="bpass5", )] #[rustc_clean(cfg="bpass6")] @@ -747,7 +747,7 @@ trait TraitAddTraitBoundToAssociatedType { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddTraitBoundToAssociatedType { #[rustc_clean(except="hir_owner", cfg="bpass2")] @@ -776,7 +776,7 @@ trait TraitAddLifetimeBoundToAssociatedType<'a> { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddLifetimeBoundToAssociatedType<'a> { #[rustc_clean(except="hir_owner", cfg="bpass2")] @@ -805,7 +805,7 @@ trait TraitAddDefaultToAssociatedType { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddDefaultToAssociatedType { #[rustc_clean(except="hir_owner", cfg="bpass2")] @@ -828,7 +828,7 @@ trait TraitAddAssociatedConstant { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,associated_item_def_ids,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,associated_item_def_ids,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddAssociatedConstant { const Value: u32; @@ -857,7 +857,7 @@ trait TraitAddInitializerToAssociatedConstant { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddInitializerToAssociatedConstant { #[rustc_clean(except="hir_owner", cfg="bpass2")] @@ -894,7 +894,7 @@ trait TraitChangeTypeOfAssociatedConstant { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitChangeTypeOfAssociatedConstant { #[rustc_clean(except="hir_owner,type_of", cfg="bpass2")] @@ -917,9 +917,9 @@ trait TraitChangeTypeOfAssociatedConstant { trait TraitAddSuperTrait { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddSuperTrait : ReferencedTrait0 { } @@ -930,9 +930,9 @@ trait TraitAddSuperTrait : ReferencedTrait0 { } trait TraitAddBuiltiBound { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddBuiltiBound : Send { } @@ -943,9 +943,9 @@ trait TraitAddBuiltiBound : Send { } trait TraitAddStaticLifetimeBound { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddStaticLifetimeBound : 'static { } @@ -956,9 +956,9 @@ trait TraitAddStaticLifetimeBound : 'static { } trait TraitAddTraitAsSecondBound : ReferencedTrait0 { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddTraitAsSecondBound : ReferencedTrait0 + ReferencedTrait1 { } @@ -966,9 +966,9 @@ trait TraitAddTraitAsSecondBound : ReferencedTrait0 + ReferencedTrait1 { } trait TraitAddTraitAsSecondBoundFromBuiltin : Send { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddTraitAsSecondBoundFromBuiltin : Send + ReferencedTrait0 { } @@ -979,9 +979,9 @@ trait TraitAddTraitAsSecondBoundFromBuiltin : Send + ReferencedTrait0 { } trait TraitAddBuiltinBoundAsSecondBound : ReferencedTrait0 { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddBuiltinBoundAsSecondBound : ReferencedTrait0 + Send { } @@ -989,9 +989,9 @@ trait TraitAddBuiltinBoundAsSecondBound : ReferencedTrait0 + Send { } trait TraitAddBuiltinBoundAsSecondBoundFromBuiltin : Send { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddBuiltinBoundAsSecondBoundFromBuiltin: Send + Copy { } @@ -1002,9 +1002,9 @@ trait TraitAddBuiltinBoundAsSecondBoundFromBuiltin: Send + Copy { } trait TraitAddStaticBoundAsSecondBound : ReferencedTrait0 { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddStaticBoundAsSecondBound : ReferencedTrait0 + 'static { } @@ -1012,9 +1012,9 @@ trait TraitAddStaticBoundAsSecondBound : ReferencedTrait0 + 'static { } trait TraitAddStaticBoundAsSecondBoundFromBuiltin : Send { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddStaticBoundAsSecondBoundFromBuiltin : Send + 'static { } @@ -1025,9 +1025,9 @@ trait TraitAddStaticBoundAsSecondBoundFromBuiltin : Send + 'static { } trait TraitAddTypeParameterToTrait { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,generics_of,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,generics_of,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,generics_of,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,generics_of,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddTypeParameterToTrait { } @@ -1038,9 +1038,9 @@ trait TraitAddTypeParameterToTrait { } trait TraitAddLifetimeParameterToTrait { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,generics_of,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,generics_of,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,generics_of,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,generics_of,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddLifetimeParameterToTrait<'a> { } @@ -1051,9 +1051,9 @@ trait TraitAddLifetimeParameterToTrait<'a> { } trait TraitAddTraitBoundToTypeParameterOfTrait { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddTraitBoundToTypeParameterOfTrait { } @@ -1064,9 +1064,9 @@ trait TraitAddTraitBoundToTypeParameterOfTrait { } trait TraitAddLifetimeBoundToTypeParameterOfTrait<'a, T> { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddLifetimeBoundToTypeParameterOfTrait<'a, T: 'a> { } @@ -1077,9 +1077,9 @@ trait TraitAddLifetimeBoundToTypeParameterOfTrait<'a, T: 'a> { } trait TraitAddLifetimeBoundToLifetimeParameterOfTrait<'a, 'b> { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddLifetimeBoundToLifetimeParameterOfTrait<'a: 'b, 'b> { } @@ -1090,9 +1090,9 @@ trait TraitAddLifetimeBoundToLifetimeParameterOfTrait<'a: 'b, 'b> { } trait TraitAddBuiltinBoundToTypeParameterOfTrait { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddBuiltinBoundToTypeParameterOfTrait { } @@ -1103,9 +1103,9 @@ trait TraitAddBuiltinBoundToTypeParameterOfTrait { } trait TraitAddSecondTypeParameterToTrait { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,generics_of,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,generics_of,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,generics_of,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,generics_of,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddSecondTypeParameterToTrait { } @@ -1116,9 +1116,9 @@ trait TraitAddSecondTypeParameterToTrait { } trait TraitAddSecondLifetimeParameterToTrait<'a> { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,generics_of,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,generics_of,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,generics_of,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,generics_of,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddSecondLifetimeParameterToTrait<'a, 'b> { } @@ -1129,9 +1129,9 @@ trait TraitAddSecondLifetimeParameterToTrait<'a, 'b> { } trait TraitAddSecondTraitBoundToTypeParameterOfTrait { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddSecondTraitBoundToTypeParameterOfTrait { } @@ -1142,9 +1142,9 @@ trait TraitAddSecondTraitBoundToTypeParameterOfTrait { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddSecondLifetimeBoundToTypeParameterOfTrait<'a, 'b, T: 'a + 'b> { } @@ -1155,9 +1155,9 @@ trait TraitAddSecondLifetimeBoundToTypeParameterOfTrait<'a, 'b, T: 'a + 'b> { } trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTrait<'a: 'b, 'b, 'c> { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTrait<'a: 'b + 'c, 'b, 'c> { } @@ -1168,9 +1168,9 @@ trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTrait<'a: 'b + 'c, 'b, 'c> trait TraitAddSecondBuiltinBoundToTypeParameterOfTrait { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddSecondBuiltinBoundToTypeParameterOfTrait { } @@ -1186,9 +1186,9 @@ struct ReferenceType1 {} trait TraitAddTraitBoundToTypeParameterOfTraitWhere { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddTraitBoundToTypeParameterOfTraitWhere where T: ReferencedTrait0 { } @@ -1199,9 +1199,9 @@ trait TraitAddTraitBoundToTypeParameterOfTraitWhere where T: ReferencedTrait0 trait TraitAddLifetimeBoundToTypeParameterOfTraitWhere<'a, T> { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddLifetimeBoundToTypeParameterOfTraitWhere<'a, T> where T: 'a { } @@ -1212,9 +1212,9 @@ trait TraitAddLifetimeBoundToTypeParameterOfTraitWhere<'a, T> where T: 'a { } trait TraitAddLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b> { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b> where 'a: 'b { } @@ -1225,9 +1225,9 @@ trait TraitAddLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b> where 'a: 'b trait TraitAddBuiltinBoundToTypeParameterOfTraitWhere { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddBuiltinBoundToTypeParameterOfTraitWhere where T: Send { } @@ -1238,9 +1238,9 @@ trait TraitAddBuiltinBoundToTypeParameterOfTraitWhere where T: Send { } trait TraitAddSecondTraitBoundToTypeParameterOfTraitWhere where T: ReferencedTrait0 { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddSecondTraitBoundToTypeParameterOfTraitWhere where T: ReferencedTrait0 + ReferencedTrait1 { } @@ -1252,9 +1252,9 @@ trait TraitAddSecondTraitBoundToTypeParameterOfTraitWhere trait TraitAddSecondLifetimeBoundToTypeParameterOfTraitWhere<'a, 'b, T> where T: 'a { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddSecondLifetimeBoundToTypeParameterOfTraitWhere<'a, 'b, T> where T: 'a + 'b { } @@ -1265,9 +1265,9 @@ trait TraitAddSecondLifetimeBoundToTypeParameterOfTraitWhere<'a, 'b, T> where T: trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b, 'c> where 'a: 'b { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b, 'c> where 'a: 'b + 'c { } @@ -1278,9 +1278,9 @@ trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b, 'c> whe trait TraitAddSecondBuiltinBoundToTypeParameterOfTraitWhere where T: Send { } #[cfg(not(any(bpass1,bpass4)))] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitAddSecondBuiltinBoundToTypeParameterOfTraitWhere where T: Send + Sync { } @@ -1341,9 +1341,9 @@ mod change_method_parameter_type_bound_indirectly_by_use { #[rustc_clean(cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitChangeBoundOfMethodTypeParameter { - #[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] + #[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] - #[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] + #[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] fn method(a: T); } @@ -1364,9 +1364,9 @@ mod change_method_parameter_type_bound_indirectly_by_use_where { #[rustc_clean(cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitChangeBoundOfMethodTypeParameterWhere { - #[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] + #[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] - #[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] + #[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] fn method(a: T) where T: Bound; } @@ -1381,9 +1381,9 @@ mod change_method_type_parameter_bound_indirectly { #[cfg(not(any(bpass1,bpass4)))] use super::ReferencedTrait1 as Bound; - #[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] + #[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] - #[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] + #[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitChangeTraitBound { fn method(a: T); @@ -1400,9 +1400,9 @@ mod change_method_type_parameter_bound_indirectly_where { #[cfg(not(any(bpass1,bpass4)))] use super::ReferencedTrait1 as Bound; - #[rustc_clean(except="hir_owner,predicates_of", cfg="bpass2")] + #[rustc_clean(except="hir_owner,clauses_of", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] - #[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] + #[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] trait TraitChangeTraitBoundWhere where T: Bound { fn method(a: T); diff --git a/tests/incremental/hashes/trait_impls.rs b/tests/incremental/hashes/trait_impls.rs index 06b2934cb8a8f..989cae1939622 100644 --- a/tests/incremental/hashes/trait_impls.rs +++ b/tests/incremental/hashes/trait_impls.rs @@ -35,7 +35,7 @@ impl ChangeMethodNameTrait for Foo { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,associated_item_def_ids,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,associated_item_def_ids,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] pub trait ChangeMethodNameTrait { #[rustc_clean(cfg="bpass3")] @@ -333,7 +333,7 @@ impl ChangeHasValueTrait for Foo { #[cfg(not(any(bpass1,bpass4)))] #[rustc_clean(cfg="bpass2")] #[rustc_clean(cfg="bpass3")] -#[rustc_clean(except="hir_owner,predicates_of", cfg="bpass5")] +#[rustc_clean(except="hir_owner,clauses_of", cfg="bpass5")] #[rustc_clean(cfg="bpass6")] pub trait ChangeHasValueTrait { #[rustc_clean(except="hir_owner", cfg="bpass2")] diff --git a/tests/mir-opt/impossible_predicates.impossible_predicate.ImpossiblePredicates.diff b/tests/mir-opt/impossible_clauses.impossible_clause.ImpossibleClauses.diff similarity index 74% rename from tests/mir-opt/impossible_predicates.impossible_predicate.ImpossiblePredicates.diff rename to tests/mir-opt/impossible_clauses.impossible_clause.ImpossibleClauses.diff index 46d1ca7464cdc..fb75249af3dc2 100644 --- a/tests/mir-opt/impossible_predicates.impossible_predicate.ImpossiblePredicates.diff +++ b/tests/mir-opt/impossible_clauses.impossible_clause.ImpossibleClauses.diff @@ -1,7 +1,7 @@ -- // MIR for `impossible_predicate` before ImpossiblePredicates -+ // MIR for `impossible_predicate` after ImpossiblePredicates +- // MIR for `impossible_clause` before ImpossibleClauses ++ // MIR for `impossible_clause` after ImpossibleClauses - fn impossible_predicate(_1: &mut i32) -> (&mut i32, &mut i32) { + fn impossible_clause(_1: &mut i32) -> (&mut i32, &mut i32) { - debug x => _1; let mut _0: (&mut i32, &mut i32); - let _2: &mut i32; diff --git a/tests/mir-opt/impossible_clauses.rs b/tests/mir-opt/impossible_clauses.rs new file mode 100644 index 0000000000000..24684a83027a7 --- /dev/null +++ b/tests/mir-opt/impossible_clauses.rs @@ -0,0 +1,10 @@ +//@ skip-filecheck +// EMIT_MIR impossible_clauses.impossible_clause.ImpossibleClauses.diff + +pub fn impossible_clause(x: &mut i32) -> (&mut i32, &mut i32) +where + for<'a> &'a mut i32: Copy, +{ + let y = x; + (y, x) +} diff --git a/tests/mir-opt/impossible_predicates.rs b/tests/mir-opt/impossible_predicates.rs deleted file mode 100644 index 3858bb657635d..0000000000000 --- a/tests/mir-opt/impossible_predicates.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ skip-filecheck -// EMIT_MIR impossible_predicates.impossible_predicate.ImpossiblePredicates.diff - -pub fn impossible_predicate(x: &mut i32) -> (&mut i32, &mut i32) -where - for<'a> &'a mut i32: Copy, -{ - let y = x; - (y, x) -} diff --git a/tests/ui/associated-type-bounds/ambiguous-associated-type2.stderr b/tests/ui/associated-type-bounds/ambiguous-associated-type2.stderr index 166bdc988f947..6afa00c7c74e9 100644 --- a/tests/ui/associated-type-bounds/ambiguous-associated-type2.stderr +++ b/tests/ui/associated-type-bounds/ambiguous-associated-type2.stderr @@ -5,7 +5,7 @@ LL | trait Baz: Foo + Bar {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: ...which immediately requires computing the super traits of `Baz` with associated type name `Item` again - = note: cycle used when computing the super predicates of `Baz` + = note: cycle used when computing the super clauses of `Baz` = note: for more information, see and error: aborting due to 1 previous error diff --git a/tests/ui/associated-type-bounds/implied-bounds-cycle.rs b/tests/ui/associated-type-bounds/implied-bounds-cycle.rs index 8f2bec889eac5..620999d33e8de 100644 --- a/tests/ui/associated-type-bounds/implied-bounds-cycle.rs +++ b/tests/ui/associated-type-bounds/implied-bounds-cycle.rs @@ -3,6 +3,6 @@ trait A { } trait B: A {} -//~^ ERROR cycle detected when computing the implied predicates of `B` +//~^ ERROR cycle detected when computing the implied clauses of `B` fn main() {} diff --git a/tests/ui/associated-type-bounds/implied-bounds-cycle.stderr b/tests/ui/associated-type-bounds/implied-bounds-cycle.stderr index b794a4ec01d4d..125739f275e98 100644 --- a/tests/ui/associated-type-bounds/implied-bounds-cycle.stderr +++ b/tests/ui/associated-type-bounds/implied-bounds-cycle.stderr @@ -1,10 +1,10 @@ -error[E0391]: cycle detected when computing the implied predicates of `B` +error[E0391]: cycle detected when computing the implied clauses of `B` --> $DIR/implied-bounds-cycle.rs:5:15 | LL | trait B: A {} | ^ | - = note: ...which immediately requires computing the implied predicates of `B` again + = note: ...which immediately requires computing the implied clauses of `B` again note: cycle used when computing normalized predicates of `B` --> $DIR/implied-bounds-cycle.rs:5:1 | diff --git a/tests/ui/associated-types/issue-20825.stderr b/tests/ui/associated-types/issue-20825.stderr index a833c5f69f906..dcf0b26cf15ad 100644 --- a/tests/ui/associated-types/issue-20825.stderr +++ b/tests/ui/associated-types/issue-20825.stderr @@ -5,7 +5,7 @@ LL | pub trait Processor: Subscriber { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: ...which immediately requires computing the super traits of `Processor` with associated type name `Input` again - = note: cycle used when computing the super predicates of `Processor` + = note: cycle used when computing the super clauses of `Processor` = note: for more information, see and error: aborting due to 1 previous error diff --git a/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr b/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr index afb12aaad832c..b639d45dc157d 100644 --- a/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr +++ b/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr @@ -1,10 +1,10 @@ -error[E0391]: cycle detected when computing the super predicates of `Chromosome` +error[E0391]: cycle detected when computing the super clauses of `Chromosome` --> $DIR/cycle-trait-supertrait-direct.rs:3:19 | LL | trait Chromosome: Chromosome { | ^^^^^^^^^^ | - = note: ...which immediately requires computing the super predicates of `Chromosome` again + = note: ...which immediately requires computing the super clauses of `Chromosome` again note: cycle used when checking that `Chromosome` is well-formed --> $DIR/cycle-trait-supertrait-direct.rs:3:1 | diff --git a/tests/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr b/tests/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr index 233961858d142..ec9c77568b827 100644 --- a/tests/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr +++ b/tests/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr @@ -1,16 +1,16 @@ -error[E0391]: cycle detected when computing the super predicates of `B` +error[E0391]: cycle detected when computing the super clauses of `B` --> $DIR/cycle-trait-supertrait-indirect.rs:7:10 | LL | trait B: C { | ^ | -note: ...which requires computing the super predicates of `C`... +note: ...which requires computing the super clauses of `C`... --> $DIR/cycle-trait-supertrait-indirect.rs:11:10 | LL | trait C: B { } | ^ - = note: ...which again requires computing the super predicates of `B`, completing the cycle -note: cycle used when computing the super predicates of `A` + = note: ...which again requires computing the super clauses of `B`, completing the cycle +note: cycle used when computing the super clauses of `A` --> $DIR/cycle-trait-supertrait-indirect.rs:4:10 | LL | trait A: B { diff --git a/tests/ui/cycle-trait/issue-12511.stderr b/tests/ui/cycle-trait/issue-12511.stderr index 078f2eadc45a9..1ea82b694d55e 100644 --- a/tests/ui/cycle-trait/issue-12511.stderr +++ b/tests/ui/cycle-trait/issue-12511.stderr @@ -1,15 +1,15 @@ -error[E0391]: cycle detected when computing the super predicates of `T1` +error[E0391]: cycle detected when computing the super clauses of `T1` --> $DIR/issue-12511.rs:1:12 | LL | trait T1 : T2 { | ^^ | -note: ...which requires computing the super predicates of `T2`... +note: ...which requires computing the super clauses of `T2`... --> $DIR/issue-12511.rs:5:12 | LL | trait T2 : T1 { | ^^ - = note: ...which again requires computing the super predicates of `T1`, completing the cycle + = note: ...which again requires computing the super clauses of `T1`, completing the cycle note: cycle used when checking that `T1` is well-formed --> $DIR/issue-12511.rs:1:1 | diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds.rs b/tests/ui/generic-const-items/trivially-unsatisfied-bounds.rs index 9a0c6d0feeca8..884911ecbc115 100644 --- a/tests/ui/generic-const-items/trivially-unsatisfied-bounds.rs +++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds.rs @@ -6,7 +6,7 @@ #![feature(generic_const_items)] // FIXME(generic_const_items): Try to get rid of error "entering unreachable error", it's -// unnecessary and actually caused by MIR pass `ImpossiblePredicates` replacing the body with the +// unnecessary and actually caused by MIR pass `ImpossibleClauses` replacing the body with the // terminator `Unreachable` due to the unsatisfied bound which is subsequently reached. // // NOTE(#142293): However, don't think about suppressing the evaluation of the initializer if the diff --git a/tests/ui/infinite/infinite-trait-alias-recursion.rs b/tests/ui/infinite/infinite-trait-alias-recursion.rs index df884cca22b77..e5c3a1eea0a24 100644 --- a/tests/ui/infinite/infinite-trait-alias-recursion.rs +++ b/tests/ui/infinite/infinite-trait-alias-recursion.rs @@ -1,7 +1,7 @@ #![feature(trait_alias)] //@ ignore-parallel-frontend query cycle trait T1 = T2; -//~^ ERROR cycle detected when computing the implied predicates of `T1` +//~^ ERROR cycle detected when computing the implied clauses of `T1` trait T2 = T3; diff --git a/tests/ui/infinite/infinite-trait-alias-recursion.stderr b/tests/ui/infinite/infinite-trait-alias-recursion.stderr index a47754b142083..fc19fc0115811 100644 --- a/tests/ui/infinite/infinite-trait-alias-recursion.stderr +++ b/tests/ui/infinite/infinite-trait-alias-recursion.stderr @@ -1,20 +1,20 @@ -error[E0391]: cycle detected when computing the implied predicates of `T1` +error[E0391]: cycle detected when computing the implied clauses of `T1` --> $DIR/infinite-trait-alias-recursion.rs:3:12 | LL | trait T1 = T2; | ^^ | -note: ...which requires computing the implied predicates of `T2`... +note: ...which requires computing the implied clauses of `T2`... --> $DIR/infinite-trait-alias-recursion.rs:6:12 | LL | trait T2 = T3; | ^^ -note: ...which requires computing the implied predicates of `T3`... +note: ...which requires computing the implied clauses of `T3`... --> $DIR/infinite-trait-alias-recursion.rs:8:12 | LL | trait T3 = T1 + T3; | ^^ - = note: ...which again requires computing the implied predicates of `T1`, completing the cycle + = note: ...which again requires computing the implied clauses of `T1`, completing the cycle = note: trait aliases cannot be recursive note: cycle used when checking that `T1` is well-formed --> $DIR/infinite-trait-alias-recursion.rs:3:1 diff --git a/tests/ui/privacy/generic_struct_field_projection.rs b/tests/ui/privacy/generic_struct_field_projection.rs index c5bb1233c27b9..a6a5f6332abe4 100644 --- a/tests/ui/privacy/generic_struct_field_projection.rs +++ b/tests/ui/privacy/generic_struct_field_projection.rs @@ -1,12 +1,12 @@ //! To determine all the types that need to be private when looking at `Struct`, we -//! used to invoke `predicates_of` to also look at types in `where` bounds. +//! used to invoke `clauses_of` to also look at types in `where` bounds. //! Unfortunately this also computes the inferred outlives bounds, which means for //! every field we check that if it is of type `&'a T` then `T: 'a` and if it is of //! struct type, we check that the struct satisfies its lifetime parameters by looking //! at its inferred outlives bounds. This means we end up with a `::Assoc: 'a` //! in the outlives bounds of `Struct`. While this is trivially provable, privacy //! only sees `Foo` and `Trait` and determines that `Foo` is private and then errors. -//! So now we invoke `explicit_predicates_of` to make sure we only care about user-written +//! So now we invoke `explicit_clauses_of` to make sure we only care about user-written //! predicates. //@ check-pass diff --git a/tests/ui/traits/alias/infinite_normalization.rs b/tests/ui/traits/alias/infinite_normalization.rs index 9e3b7df7085b6..e78d8d12846fd 100644 --- a/tests/ui/traits/alias/infinite_normalization.rs +++ b/tests/ui/traits/alias/infinite_normalization.rs @@ -6,6 +6,6 @@ #![feature(trait_alias)] fn foo>() {} trait Baz = Baz>; -//~^ ERROR: cycle detected when computing the implied predicates of `Baz` +//~^ ERROR: cycle detected when computing the implied clauses of `Baz` fn main() {} diff --git a/tests/ui/traits/alias/infinite_normalization.stderr b/tests/ui/traits/alias/infinite_normalization.stderr index 049f55d1ab40d..1df4fd8129f27 100644 --- a/tests/ui/traits/alias/infinite_normalization.stderr +++ b/tests/ui/traits/alias/infinite_normalization.stderr @@ -1,10 +1,10 @@ -error[E0391]: cycle detected when computing the implied predicates of `Baz` +error[E0391]: cycle detected when computing the implied clauses of `Baz` --> $DIR/infinite_normalization.rs:8:16 | LL | trait Baz = Baz>; | ^^^^^^^^^^^^^^ | - = note: ...which immediately requires computing the implied predicates of `Baz` again + = note: ...which immediately requires computing the implied clauses of `Baz` again = note: trait aliases cannot be recursive note: cycle used when computing normalized predicates of `foo` --> $DIR/infinite_normalization.rs:7:1 diff --git a/tests/ui/traits/solver-cycles/self-item-cycle.stderr b/tests/ui/traits/solver-cycles/self-item-cycle.stderr index 179d2d2bb7e05..13fcf36b5d2e2 100644 --- a/tests/ui/traits/solver-cycles/self-item-cycle.stderr +++ b/tests/ui/traits/solver-cycles/self-item-cycle.stderr @@ -5,7 +5,7 @@ LL | trait T: Iterator | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: ...which immediately requires computing the super traits of `T` with associated type name `Item` again - = note: cycle used when computing the super predicates of `T` + = note: cycle used when computing the super clauses of `T` = note: for more information, see and error: aborting due to 1 previous error diff --git a/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.rs b/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.rs index 6211c7fac4158..3b20ac94e8c62 100644 --- a/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.rs +++ b/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.rs @@ -1,6 +1,6 @@ trait A: B + A {} -//~^ ERROR cycle detected when computing the super predicates of `A` [E0391] -//~| ERROR cycle detected when computing the implied predicates of `A` [E0391] +//~^ ERROR cycle detected when computing the super clauses of `A` [E0391] +//~| ERROR cycle detected when computing the implied clauses of `A` [E0391] trait B {} diff --git a/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr b/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr index bbd2e56285f48..1b16ec76d2b92 100644 --- a/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr +++ b/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr @@ -1,10 +1,10 @@ -error[E0391]: cycle detected when computing the super predicates of `A` +error[E0391]: cycle detected when computing the super clauses of `A` --> $DIR/cyclic-trait-resolution.rs:1:14 | LL | trait A: B + A {} | ^ | - = note: ...which immediately requires computing the super predicates of `A` again + = note: ...which immediately requires computing the super clauses of `A` again note: cycle used when checking that `A` is well-formed --> $DIR/cyclic-trait-resolution.rs:1:1 | @@ -12,13 +12,13 @@ LL | trait A: B + A {} | ^^^^^^^^^^^^^^ = note: for more information, see and -error[E0391]: cycle detected when computing the implied predicates of `A` +error[E0391]: cycle detected when computing the implied clauses of `A` --> $DIR/cyclic-trait-resolution.rs:1:14 | LL | trait A: B + A {} | ^ | - = note: ...which immediately requires computing the implied predicates of `A` again + = note: ...which immediately requires computing the implied clauses of `A` again note: cycle used when checking that `` is well-formed --> $DIR/cyclic-trait-resolution.rs:7:1 |