diff --git a/compiler/rustc_hir_analysis/src/check/always_applicable.rs b/compiler/rustc_hir_analysis/src/check/always_applicable.rs index 972c6715ee345..6a30ff40eedc6 100644 --- a/compiler/rustc_hir_analysis/src/check/always_applicable.rs +++ b/compiler/rustc_hir_analysis/src/check/always_applicable.rs @@ -209,7 +209,7 @@ fn ensure_all_fields_are_const_destruct<'tcx>( tcx, cause, env, - ty::ClauseKind::HostEffect(ty::HostEffectPredicate { + ty::ClauseKind::HostEffect(ty::HostEffectClause { trait_ref: ty::TraitRef::new(tcx, destruct_trait, [field_ty]), constness: ty::BoundConstness::Maybe, }), diff --git a/compiler/rustc_hir_analysis/src/collect/clauses_of.rs b/compiler/rustc_hir_analysis/src/collect/clauses_of.rs index 49e9944428f53..1ee647fd61a33 100644 --- a/compiler/rustc_hir_analysis/src/collect/clauses_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/clauses_of.rs @@ -776,18 +776,18 @@ pub(super) fn assert_only_contains_clauses_from<'tcx>( `{filter:?}` implied bounds: {clause:?}" ); } - ty::ClauseKind::TypeOutlives(outlives_predicate) => { + ty::ClauseKind::TypeOutlives(outlives_clause) => { assert_eq!( - outlives_predicate.0, ty, - "expected `Self` predicate when computing \ + outlives_clause.0, ty, + "expected `Self` clause when computing \ `{filter:?}` implied bounds: {clause:?}" ); } - ty::ClauseKind::HostEffect(host_effect_predicate) => { + ty::ClauseKind::HostEffect(host_effect_clause) => { assert_eq!( - host_effect_predicate.self_ty(), + host_effect_clause.self_ty(), ty, - "expected `Self` predicate when computing \ + "expected `Self` clause when computing \ `{filter:?}` implied bounds: {clause:?}" ); } @@ -836,13 +836,13 @@ pub(super) fn assert_only_contains_clauses_from<'tcx>( PredicateFilter::ConstIfConst => { for (clause, _) in bounds { match clause.kind().skip_binder() { - ty::ClauseKind::HostEffect(ty::HostEffectPredicate { + ty::ClauseKind::HostEffect(ty::HostEffectClause { trait_ref: _, constness: ty::BoundConstness::Maybe, }) => {} _ => { bug!( - "unexpected non-`HostEffect` predicate when computing \ + "unexpected non-`HostEffect` clause when computing \ `{filter:?}` implied bounds: {clause:?}" ); } @@ -852,23 +852,23 @@ pub(super) fn assert_only_contains_clauses_from<'tcx>( PredicateFilter::SelfConstIfConst => { for (clause, _) in bounds { match clause.kind().skip_binder() { - ty::ClauseKind::HostEffect(pred) => { + ty::ClauseKind::HostEffect(host_clause) => { assert_eq!( - pred.constness, + host_clause.constness, ty::BoundConstness::Maybe, - "expected `[const]` predicate when computing `{filter:?}` \ + "expected `[const]` clause when computing `{filter:?}` \ implied bounds: {clause:?}", ); assert_eq!( - pred.trait_ref.self_ty(), + host_clause.trait_ref.self_ty(), ty, - "expected `Self` predicate when computing `{filter:?}` \ + "expected `Self` clause when computing `{filter:?}` \ implied bounds: {clause:?}" ); } _ => { bug!( - "unexpected non-`HostEffect` predicate when computing \ + "unexpected non-`HostEffect` clause when computing \ `{filter:?}` implied bounds: {clause:?}" ); } @@ -1151,10 +1151,10 @@ pub(super) fn const_conditions<'tcx>( ty::ConstConditions { parent: has_parent.then(|| tcx.local_parent(def_id).to_def_id()), - predicates: tcx.arena.alloc_from_iter(bounds.into_iter().map(|(clause, span)| { + clauses: tcx.arena.alloc_from_iter(bounds.into_iter().map(|(clause, span)| { ( clause.kind().map_bound(|clause| match clause { - ty::ClauseKind::HostEffect(ty::HostEffectPredicate { + ty::ClauseKind::HostEffect(ty::HostEffectClause { trait_ref, constness: ty::BoundConstness::Maybe, }) => trait_ref, @@ -1206,7 +1206,7 @@ pub(super) fn explicit_implied_const_bounds<'tcx>( &*tcx.arena.alloc_from_iter(bounds.iter().copied().map(|(clause, span)| { ( clause.kind().map_bound(|clause| match clause { - ty::ClauseKind::HostEffect(ty::HostEffectPredicate { + ty::ClauseKind::HostEffect(ty::HostEffectClause { trait_ref, constness: ty::BoundConstness::Maybe, }) => trait_ref, diff --git a/compiler/rustc_hir_analysis/src/variance/mod.rs b/compiler/rustc_hir_analysis/src/variance/mod.rs index 6b496e775288c..c733292df7d98 100644 --- a/compiler/rustc_hir_analysis/src/variance/mod.rs +++ b/compiler/rustc_hir_analysis/src/variance/mod.rs @@ -181,24 +181,24 @@ fn variance_of_opaque( let mut collector = OpaqueTypeLifetimeCollector { tcx, root_def_id: item_def_id.to_def_id(), variances }; let id_args = ty::GenericArgs::identity_for_item(tcx, item_def_id); - for (pred, _) in tcx + for (clause, _) in tcx .explicit_item_bounds(item_def_id) .iter_instantiated_copied(tcx, id_args) .map(Unnormalized::skip_norm_wip) { - debug!(?pred); + debug!(?clause); // We only ignore opaque type args if the opaque type is the outermost type. // The opaque type may be nested within itself via recursion in e.g. // type Foo<'a> = impl PartialEq>; // which thus mentions `'a` and should thus accept hidden types that borrow 'a // instead of requiring an additional `+ 'a`. - match pred.kind().skip_binder() { + match clause.kind().skip_binder() { ty::ClauseKind::Trait(ty::TraitPredicate { trait_ref: ty::TraitRef { def_id: _, args, .. }, polarity: _, }) - | ty::ClauseKind::HostEffect(ty::HostEffectPredicate { + | ty::ClauseKind::HostEffect(ty::HostEffectClause { trait_ref: ty::TraitRef { def_id: _, args, .. }, constness: _, }) => { @@ -219,7 +219,7 @@ fn variance_of_opaque( region.visit_with(&mut collector); } _ => { - pred.visit_with(&mut collector); + clause.visit_with(&mut collector); } } } 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 c0ec4249087c3..be24a5e7d0b8c 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 @@ -85,8 +85,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty::ClauseKind::Trait(pred) => { (pred.trait_ref.args.to_vec(), Some(pred.self_ty().into())) } - ty::ClauseKind::HostEffect(pred) => { - (pred.trait_ref.args.to_vec(), Some(pred.self_ty().into())) + ty::ClauseKind::HostEffect(clause) => { + (clause.trait_ref.args.to_vec(), Some(clause.self_ty().into())) } ty::ClauseKind::Projection(pred) => (pred.projection_term.args.to_vec(), None), ty::ClauseKind::ConstArgHasType(arg, ty) => (vec![ty.into(), arg.into()], None), diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index a119424f85af1..b8cd0791a783e 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -127,10 +127,10 @@ impl<'tcx> ObligationCause<'tcx> { pub fn derived_host_cause( mut self, - parent_host_pred: ty::Binder<'tcx, ty::HostEffectPredicate<'tcx>>, + parent_host_clause: ty::Binder<'tcx, ty::HostEffectClause<'tcx>>, variant: impl FnOnce(DerivedHostCause<'tcx>) -> ObligationCauseCode<'tcx>, ) -> ObligationCause<'tcx> { - self.code = variant(DerivedHostCause { parent_host_pred, parent_code: self.code }).into(); + self.code = variant(DerivedHostCause { parent_host_clause, parent_code: self.code }).into(); self } @@ -600,11 +600,11 @@ pub struct ImplDerivedCause<'tcx> { #[derive(Clone, Debug, PartialEq, Eq, StableHash, TyEncodable, TyDecodable)] #[derive(TypeVisitable, TypeFoldable)] pub struct DerivedHostCause<'tcx> { - /// The trait predicate of the parent obligation that led to the + /// The trait clause of the parent obligation that led to the /// current obligation. Note that only trait obligations lead to - /// derived obligations, so we just store the trait predicate here + /// derived obligations, so we just store the trait clause here /// directly. - pub parent_host_pred: ty::Binder<'tcx, ty::HostEffectPredicate<'tcx>>, + pub parent_host_clause: ty::Binder<'tcx, ty::HostEffectClause<'tcx>>, /// The parent trait had this cause. pub parent_code: ObligationCauseCodeHandle<'tcx>, diff --git a/compiler/rustc_middle/src/ty/generics.rs b/compiler/rustc_middle/src/ty/generics.rs index 029c20d47e524..bfdb89dc409f6 100644 --- a/compiler/rustc_middle/src/ty/generics.rs +++ b/compiler/rustc_middle/src/ty/generics.rs @@ -537,7 +537,7 @@ impl<'tcx> GenericClauses<'tcx> { #[derive(Copy, Clone, Default, Debug, TyEncodable, TyDecodable, StableHash)] pub struct ConstConditions<'tcx> { pub parent: Option, - pub predicates: &'tcx [(ty::PolyTraitRef<'tcx>, Span)], + pub clauses: &'tcx [(ty::PolyTraitRef<'tcx>, Span)], } impl<'tcx> ConstConditions<'tcx> { @@ -559,7 +559,7 @@ impl<'tcx> ConstConditions<'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 (trait_ref, span) = u.unzip(); (trait_ref, span.skip_normalization()) }) @@ -571,7 +571,7 @@ impl<'tcx> ConstConditions<'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 (trait_ref, span) = u.unzip(); (trait_ref, span.skip_normalization()) }) @@ -588,9 +588,9 @@ impl<'tcx> ConstConditions<'tcx> { tcx.const_conditions(def_id).instantiate_into(tcx, instantiated, args); } instantiated.extend( - self.predicates + self.clauses .iter() - .map(|&(p, s)| (EarlyBinder::bind(tcx, p).instantiate(tcx, args), s)), + .map(|&(c, s)| (EarlyBinder::bind(tcx, c).instantiate(tcx, args), s)), ); } @@ -612,7 +612,7 @@ impl<'tcx> ConstConditions<'tcx> { tcx.const_conditions(def_id).instantiate_identity_into(tcx, instantiated); } instantiated.extend( - self.predicates + self.clauses .iter() .copied() .map(|(trait_ref, span)| (Unnormalized::new(trait_ref), span)), diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 5328b29561e07..923c48f2fddfa 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -87,7 +87,7 @@ pub use self::pattern::{Pattern, PatternKind}; pub use self::predicate::{ AliasTerm, AliasTermKind, ArgOutlivesClause, Clause, ClauseKind, CoercePredicate, ExistentialPredicate, ExistentialPredicateStableCmpExt, ExistentialProjection, - ExistentialTraitRef, HostEffectPredicate, NormalizesTo, OutlivesClause, PolyCoercePredicate, + ExistentialTraitRef, HostEffectClause, NormalizesTo, OutlivesClause, PolyCoercePredicate, PolyExistentialPredicate, PolyExistentialProjection, PolyExistentialTraitRef, PolyProjectionPredicate, PolyRegionOutlivesClause, PolySubtypePredicate, PolyTraitPredicate, PolyTraitRef, PolyTypeOutlivesClause, Predicate, PredicateKind, ProjectionPredicate, diff --git a/compiler/rustc_middle/src/ty/predicate.rs b/compiler/rustc_middle/src/ty/predicate.rs index 99de04cd2dcac..990a424289e9b 100644 --- a/compiler/rustc_middle/src/ty/predicate.rs +++ b/compiler/rustc_middle/src/ty/predicate.rs @@ -15,7 +15,7 @@ pub type ExistentialPredicate<'tcx> = ir::ExistentialPredicate>; pub type ExistentialTraitRef<'tcx> = ir::ExistentialTraitRef>; pub type ExistentialProjection<'tcx> = ir::ExistentialProjection>; pub type TraitPredicate<'tcx> = ir::TraitPredicate>; -pub type HostEffectPredicate<'tcx> = ir::HostEffectPredicate>; +pub type HostEffectClause<'tcx> = ir::HostEffectClause>; pub type ClauseKind<'tcx> = ir::ClauseKind>; pub type PredicateKind<'tcx> = ir::PredicateKind>; pub type NormalizesTo<'tcx> = ir::NormalizesTo>; @@ -582,24 +582,16 @@ impl<'tcx> UpcastFrom, PolyProjectionPredicate<'tcx>> for Clause<'t } } -impl<'tcx> UpcastFrom, ty::Binder<'tcx, ty::HostEffectPredicate<'tcx>>> +impl<'tcx> UpcastFrom, ty::Binder<'tcx, ty::HostEffectClause<'tcx>>> for Predicate<'tcx> { - fn upcast_from( - from: ty::Binder<'tcx, ty::HostEffectPredicate<'tcx>>, - tcx: TyCtxt<'tcx>, - ) -> Self { + fn upcast_from(from: ty::Binder<'tcx, ty::HostEffectClause<'tcx>>, tcx: TyCtxt<'tcx>) -> Self { from.map_bound(ty::ClauseKind::HostEffect).upcast(tcx) } } -impl<'tcx> UpcastFrom, ty::Binder<'tcx, ty::HostEffectPredicate<'tcx>>> - for Clause<'tcx> -{ - fn upcast_from( - from: ty::Binder<'tcx, ty::HostEffectPredicate<'tcx>>, - tcx: TyCtxt<'tcx>, - ) -> Self { +impl<'tcx> UpcastFrom, ty::Binder<'tcx, ty::HostEffectClause<'tcx>>> for Clause<'tcx> { + fn upcast_from(from: ty::Binder<'tcx, ty::HostEffectClause<'tcx>>, tcx: TyCtxt<'tcx>) -> Self { from.map_bound(ty::ClauseKind::HostEffect).upcast(tcx) } } diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 85a18775cb873..7fdfd8479b401 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -3223,7 +3223,7 @@ define_print! { self.trait_ref.print_trait_sugared().print(p)?; } - ty::HostEffectPredicate<'tcx> { + ty::HostEffectClause<'tcx> { let constness = match self.constness { ty::BoundConstness::Const => { "const" } ty::BoundConstness::Maybe => { "[const]" } @@ -3241,10 +3241,10 @@ define_print! { ty::ClauseKind<'tcx> { match *self { ty::ClauseKind::Trait(ref data) => data.print(p)?, - ty::ClauseKind::RegionOutlives(predicate) => predicate.print(p)?, - ty::ClauseKind::TypeOutlives(predicate) => predicate.print(p)?, + ty::ClauseKind::RegionOutlives(clause) => clause.print(p)?, + ty::ClauseKind::TypeOutlives(clause) => clause.print(p)?, ty::ClauseKind::Projection(predicate) => predicate.print(p)?, - ty::ClauseKind::HostEffect(predicate) => predicate.print(p)?, + ty::ClauseKind::HostEffect(clause) => clause.print(p)?, ty::ClauseKind::ConstArgHasType(ct, ty) => { write!(p, "the constant `")?; ct.print(p)?; 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 c6dd456e3e39a..0a361d280033a 100644 --- a/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs +++ b/compiler/rustc_next_trait_solver/src/solve/effect_goals.rs @@ -18,7 +18,7 @@ use crate::solve::{ BuiltinImplSource, CandidateSource, Certainty, EvalCtxt, Goal, GoalSource, NoSolution, assembly, }; -impl assembly::GoalKind for ty::HostEffectPredicate +impl assembly::GoalKind for ty::HostEffectClause where D: SolverDelegate, I: Interner, @@ -481,7 +481,7 @@ where #[instrument(level = "trace", skip(self))] pub(super) fn compute_host_effect_goal( &mut self, - goal: Goal>, + goal: Goal>, ) -> QueryResultOrRerunNonErased { let (_, proven_via) = self.probe(|_| ProbeKind::ShadowedEnvProbing).enter(|ecx| { let trait_goal: Goal> = diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index d836e5f84c6c0..879b239047fdc 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -133,9 +133,9 @@ where ty::ClauseKind::Trait(ty::TraitPredicate { trait_ref, polarity: _ }) => { self.visit_trait(trait_ref) } - ty::ClauseKind::HostEffect(pred) => { - try_visit!(self.visit_trait(pred.trait_ref)); - pred.constness.visit_with(self) + ty::ClauseKind::HostEffect(clause) => { + try_visit!(self.visit_trait(clause.trait_ref)); + clause.constness.visit_with(self) } ty::ClauseKind::Projection(ty::ProjectionPredicate { projection_term: projection_ty, 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 d90c3e81b68ea..9071bf521394d 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 @@ -636,9 +636,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { err } - ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(predicate)) => self + ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(clause)) => self .report_host_effect_error( - bound_predicate.rebind(predicate), + bound_predicate.rebind(clause), &obligation, span, ), @@ -858,22 +858,22 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { fn report_host_effect_error( &self, - predicate: ty::Binder<'tcx, ty::HostEffectPredicate<'tcx>>, + clause: ty::Binder<'tcx, ty::HostEffectClause<'tcx>>, main_obligation: &PredicateObligation<'tcx>, span: Span, ) -> Diag<'a> { - // FIXME(const_trait_impl): We should recompute the predicate with `[const]` + // FIXME(const_trait_impl): We should recompute the clause with `[const]` // if it's `const`, and if it holds, explain that this bound only // *conditionally* holds. - let trait_ref = predicate.map_bound(|predicate| ty::TraitPredicate { - trait_ref: predicate.trait_ref, + let trait_ref = clause.map_bound(|clause| ty::TraitPredicate { + trait_ref: clause.trait_ref, polarity: ty::PredicatePolarity::Positive, }); let mut file = None; let err_msg = self.get_standard_error_message( trait_ref, - Some(predicate.constness()), + Some(clause.constness()), String::new(), &mut file, ); @@ -1512,8 +1512,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { fn can_match_host_effect( &self, param_env: ty::ParamEnv<'tcx>, - goal: ty::HostEffectPredicate<'tcx>, - assumption: ty::Binder<'tcx, ty::HostEffectPredicate<'tcx>>, + goal: ty::HostEffectClause<'tcx>, + assumption: ty::Binder<'tcx, ty::HostEffectClause<'tcx>>, ) -> bool { let assumption = self.instantiate_binder_with_fresh_vars( DUMMY_SP, @@ -1527,9 +1527,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { fn as_host_effect_clause( predicate: ty::Predicate<'tcx>, - ) -> Option>> { + ) -> Option>> { predicate.as_clause().and_then(|clause| match clause.kind().skip_binder() { - ty::ClauseKind::HostEffect(pred) => Some(clause.kind().rebind(pred)), + ty::ClauseKind::HostEffect(host_clause) => Some(clause.kind().rebind(host_clause)), _ => None, }) } 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 094b64b734077..35bedea6c565e 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -4450,19 +4450,19 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } ObligationCauseCode::ImplDerivedHost(ref data) => { let self_ty = tcx.short_string( - self.resolve_vars_if_possible(data.derived.parent_host_pred.self_ty()), + self.resolve_vars_if_possible(data.derived.parent_host_clause.self_ty()), err.long_ty_path(), ); let trait_path = tcx.short_string( data.derived - .parent_host_pred - .map_bound(|pred| pred.trait_ref) + .parent_host_clause + .map_bound(|clause| clause.trait_ref) .print_only_trait_path(), err.long_ty_path(), ); let msg = format!( "required for `{self_ty}` to implement `{} {trait_path}`", - data.derived.parent_host_pred.skip_binder().constness, + data.derived.parent_host_clause.skip_binder().constness, ); match tcx.hir_get_if_local(data.impl_def_id) { Some(Node::Item(hir::Item { @@ -4483,7 +4483,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { self.note_obligation_cause_code( body_def_id, err, - data.derived.parent_host_pred, + data.derived.parent_host_clause, param_env, &data.derived.parent_code, obligated_types, @@ -4494,7 +4494,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { self.note_obligation_cause_code( body_def_id, err, - data.parent_host_pred, + data.parent_host_clause, param_env, &data.parent_code, obligated_types, 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 a25848b30e2fc..bb75ae6247e38 100644 --- a/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs +++ b/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs @@ -453,8 +453,8 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> { ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_pred)) => { ChildMode::Trait(pred.kind().rebind(trait_pred)) } - ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(host_pred)) => { - ChildMode::Host(pred.kind().rebind(host_pred)) + ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(host_clause)) => { + ChildMode::Host(pred.kind().rebind(host_clause)) } ty::PredicateKind::Clause(ty::ClauseKind::Projection(projection)) if projection.projection_term.kind.is_trait_projection() => @@ -520,7 +520,7 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> { impl_where_bound_count += 1; } ( - ChildMode::Host(parent_host_pred), + ChildMode::Host(parent_host_clause), GoalSource::ImplWhereBound | GoalSource::AliasBoundConstCondition, ) => { obligation = make_obligation(derive_host_cause( @@ -528,7 +528,7 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> { candidate.kind(), self.obligation.cause.clone(), impl_where_bound_count, - parent_host_pred, + parent_host_clause, )); impl_where_bound_count += 1; } @@ -556,7 +556,7 @@ enum ChildMode<'tcx> { // Try to derive an `ObligationCause::{ImplDerived,BuiltinDerived}`, // and skip all `GoalSource::Misc`, which represent useless obligations // such as alias-eq which may not hold. - Host(ty::Binder<'tcx, ty::HostEffectPredicate<'tcx>>), + Host(ty::Binder<'tcx, ty::HostEffectClause<'tcx>>), // Skip trying to derive an `ObligationCause` from this obligation, and // report *all* sub-obligations as if they came directly from the parent // obligation. @@ -604,7 +604,7 @@ fn derive_host_cause<'tcx>( candidate_kind: inspect::ProbeKind>, mut cause: ObligationCause<'tcx>, idx: usize, - parent_host_pred: ty::Binder<'tcx, ty::HostEffectPredicate<'tcx>>, + parent_host_clause: ty::Binder<'tcx, ty::HostEffectClause<'tcx>>, ) -> ObligationCause<'tcx> { match candidate_kind { inspect::ProbeKind::TraitCandidate { @@ -620,7 +620,7 @@ fn derive_host_cause<'tcx>( ( trait_ref.to_host_effect_clause( tcx, - parent_host_pred.skip_binder().constness, + parent_host_clause.skip_binder().constness, ), span, ) @@ -629,7 +629,7 @@ fn derive_host_cause<'tcx>( .nth(idx) { cause = - cause.derived_host_cause(parent_host_pred, |derived| { + cause.derived_host_cause(parent_host_clause, |derived| { ObligationCauseCode::ImplDerivedHost(Box::new( traits::ImplDerivedHostCause { derived, impl_def_id, span }, )) @@ -640,8 +640,8 @@ fn derive_host_cause<'tcx>( source: CandidateSource::BuiltinImpl(..), result: _, } => { - cause = - cause.derived_host_cause(parent_host_pred, ObligationCauseCode::BuiltinDerivedHost); + cause = cause + .derived_host_cause(parent_host_clause, ObligationCauseCode::BuiltinDerivedHost); } _ => {} }; diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs index 904604b5d0ec1..c885406f6dcfb 100644 --- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs +++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs @@ -685,8 +685,8 @@ impl<'tcx> AutoTraitFinder<'tcx> { // if possible. predicates.push_back(bound_predicate.rebind(p)); } - ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(p)) => { - let p = bound_predicate.rebind(p); + ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(c)) => { + let p = bound_predicate.rebind(c); if self.is_param_no_infer(p.skip_binder().trait_ref.args) && is_new_pred { self.add_user_clause(computed_clauses, predicate.expect_clause()); } diff --git a/compiler/rustc_trait_selection/src/traits/effects.rs b/compiler/rustc_trait_selection/src/traits/effects.rs index c0a18f9d14fcb..127a46f60b3d9 100644 --- a/compiler/rustc_trait_selection/src/traits/effects.rs +++ b/compiler/rustc_trait_selection/src/traits/effects.rs @@ -15,7 +15,7 @@ use thin_vec::{ThinVec, thin_vec}; use super::SelectionContext; use super::normalize::normalize_with_depth_to; -pub type HostEffectObligation<'tcx> = Obligation<'tcx, ty::HostEffectPredicate<'tcx>>; +pub type HostEffectObligation<'tcx> = Obligation<'tcx, ty::HostEffectClause<'tcx>>; pub enum EvaluationFailure { Ambiguous, @@ -82,7 +82,7 @@ pub fn evaluate_host_effect_obligation<'tcx>( fn match_candidate<'tcx>( selcx: &mut SelectionContext<'_, 'tcx>, obligation: &HostEffectObligation<'tcx>, - candidate: ty::Binder<'tcx, ty::HostEffectPredicate<'tcx>>, + candidate: ty::Binder<'tcx, ty::HostEffectClause<'tcx>>, candidate_is_unnormalized: bool, more_nested: impl FnOnce(&mut SelectionContext<'_, 'tcx>, &mut ThinVec>), ) -> Result>, NoSolution> { diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index 28efd58ca48fd..41d2d9adfea74 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -174,8 +174,8 @@ pub fn clause_obligations<'tcx>( wf.add_wf_preds_for_trait_pred(t, Elaborate::None); } ty::ClauseKind::HostEffect(..) => { - // Technically the well-formedness of this predicate is implied by - // the corresponding trait predicate it should've been generated beside. + // Technically the well-formedness of this clause is implied by + // the corresponding trait clause it should've been generated beside. } ty::ClauseKind::RegionOutlives(..) => {} ty::ClauseKind::TypeOutlives(ty::OutlivesClause(ty, _reg)) => { diff --git a/compiler/rustc_type_ir/src/flags.rs b/compiler/rustc_type_ir/src/flags.rs index 6b89f842bd9b0..2db0c83098b54 100644 --- a/compiler/rustc_type_ir/src/flags.rs +++ b/compiler/rustc_type_ir/src/flags.rs @@ -389,7 +389,7 @@ impl FlagComputation { ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_pred)) => { self.add_args(trait_pred.trait_ref.args.as_slice()); } - ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(ty::HostEffectPredicate { + ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(ty::HostEffectClause { trait_ref, constness: _, })) => { diff --git a/compiler/rustc_type_ir/src/inherent.rs b/compiler/rustc_type_ir/src/inherent.rs index d4ced992829c4..859996d67eb64 100644 --- a/compiler/rustc_type_ir/src/inherent.rs +++ b/compiler/rustc_type_ir/src/inherent.rs @@ -529,7 +529,7 @@ pub trait Clause>: .transpose() } - fn as_host_effect_clause(self) -> Option>> { + fn as_host_effect_clause(self) -> Option>> { self.kind() .map_bound( |clause| if let ty::ClauseKind::HostEffect(t) = clause { Some(t) } else { None }, diff --git a/compiler/rustc_type_ir/src/interner.rs b/compiler/rustc_type_ir/src/interner.rs index 56a911bdb4b8b..cfe5ead83cb01 100644 --- a/compiler/rustc_type_ir/src/interner.rs +++ b/compiler/rustc_type_ir/src/interner.rs @@ -30,7 +30,7 @@ pub trait Interner: + IrPrint> + IrPrint> + IrPrint> - + IrPrint> + + IrPrint> + IrPrint> + IrPrint> + IrPrint> diff --git a/compiler/rustc_type_ir/src/ir_print.rs b/compiler/rustc_type_ir/src/ir_print.rs index ef70c50b3ae04..1b11665e1f574 100644 --- a/compiler/rustc_type_ir/src/ir_print.rs +++ b/compiler/rustc_type_ir/src/ir_print.rs @@ -4,7 +4,7 @@ use std::fmt; use crate::{AliasConst, ClosureKind}; use crate::{ AliasTerm, AliasTy, Binder, CoercePredicate, ExistentialProjection, ExistentialTraitRef, FnSig, - HostEffectPredicate, Interner, NormalizesTo, OutlivesClause, PatternKind, Placeholder, + HostEffectClause, Interner, NormalizesTo, OutlivesClause, PatternKind, Placeholder, ProjectionPredicate, Region, SubtypePredicate, TraitPredicate, TraitRef, }; @@ -46,7 +46,7 @@ define_display_via_print!( NormalizesTo, SubtypePredicate, CoercePredicate, - HostEffectPredicate, + HostEffectClause, AliasTy, AliasTerm, FnSig, diff --git a/compiler/rustc_type_ir/src/predicate.rs b/compiler/rustc_type_ir/src/predicate.rs index 2d04d28a41d58..d04db45eb9ce1 100644 --- a/compiler/rustc_type_ir/src/predicate.rs +++ b/compiler/rustc_type_ir/src/predicate.rs @@ -175,7 +175,7 @@ impl ty::Binder> { pub fn to_host_effect_clause(self, cx: I, constness: BoundConstness) -> I::Clause { self.map_bound(|trait_ref| { - ty::ClauseKind::HostEffect(HostEffectPredicate { trait_ref, constness }) + ty::ClauseKind::HostEffect(HostEffectClause { trait_ref, constness }) }) .upcast(cx) } @@ -654,15 +654,15 @@ where feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash_NoContext) )] -pub struct HostEffectPredicate { +pub struct HostEffectClause { pub trait_ref: ty::TraitRef, #[lift(identity)] pub constness: BoundConstness, } -impl Eq for HostEffectPredicate {} +impl Eq for HostEffectClause {} -impl HostEffectPredicate { +impl HostEffectClause { pub fn self_ty(self) -> I::Ty { self.trait_ref.self_ty() } @@ -676,7 +676,7 @@ impl HostEffectPredicate { } } -impl ty::Binder> { +impl ty::Binder> { pub fn def_id(self) -> I::TraitId { // Ok to skip binder since trait `DefId` does not care about regions. self.skip_binder().def_id() diff --git a/compiler/rustc_type_ir/src/predicate_kind.rs b/compiler/rustc_type_ir/src/predicate_kind.rs index 2b245addc93f4..e57f0f1e0cd8d 100644 --- a/compiler/rustc_type_ir/src/predicate_kind.rs +++ b/compiler/rustc_type_ir/src/predicate_kind.rs @@ -41,11 +41,11 @@ pub enum ClauseKind { /// Constant initializer must evaluate successfully. ConstEvaluatable(I::Const), - /// Enforces the constness of the predicate we're calling. Like a projection + /// Enforces the constness of the clause we're calling. Like a projection /// goal from a where clause, it's always going to be paired with a /// corresponding trait clause; this just enforces the *constness* of that /// implementation. - HostEffect(ty::HostEffectPredicate), + HostEffect(ty::HostEffectClause), /// Support marking impl as unstable. UnstableFeature( diff --git a/compiler/rustc_type_ir/src/serialize.rs b/compiler/rustc_type_ir/src/serialize.rs index 20358efc162be..7996fd9d32aae 100644 --- a/compiler/rustc_type_ir/src/serialize.rs +++ b/compiler/rustc_type_ir/src/serialize.rs @@ -51,7 +51,7 @@ impl_binder_encode_decode! { ty::ExistentialPredicate, ty::TraitRef, ty::ExistentialTraitRef, - ty::HostEffectPredicate, + ty::HostEffectClause, } impl, I: Interner, E: Encoder> Encodable for ty::Binder diff --git a/compiler/rustc_type_ir/src/unnormalized.rs b/compiler/rustc_type_ir/src/unnormalized.rs index 8ac567f7ef65b..e62f2763069ce 100644 --- a/compiler/rustc_type_ir/src/unnormalized.rs +++ b/compiler/rustc_type_ir/src/unnormalized.rs @@ -9,7 +9,7 @@ use crate::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder}; use crate::inherent::*; use crate::upcast::Upcast; use crate::{ - Binder, BoundConstness, ClauseKind, HostEffectPredicate, Interner, PredicatePolarity, + Binder, BoundConstness, ClauseKind, HostEffectClause, Interner, PredicatePolarity, TraitPredicate, TraitRef, }; @@ -155,7 +155,7 @@ impl Unnormalized>> { let inner = self .value .map_bound(|trait_ref| { - ClauseKind::HostEffect(HostEffectPredicate { trait_ref, constness }) + ClauseKind::HostEffect(HostEffectClause { trait_ref, constness }) }) .upcast(cx); Unnormalized::new(inner) diff --git a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs index 1be40b539c74b..820c8b550548c 100644 --- a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs +++ b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs @@ -371,7 +371,7 @@ fn check_terminator<'tcx>( let fn_ty = func.ty(body, cx.tcx); if let ty::FnDef(fn_def_id, fn_substs) = fn_ty.kind() { // FIXME: when analyzing a function with generic parameters, we may not have enough information to - // resolve to an instance. However, we could check if a host effect predicate can guarantee that + // resolve to an instance. However, we could check if a host effect clause can guarantee that // this can be made a `const` call. let fn_def_id = match Instance::try_resolve( cx.tcx, diff --git a/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.rs b/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.rs index 062853635f285..ca1155da66bee 100644 --- a/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.rs +++ b/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.rs @@ -1,4 +1,4 @@ -// Make sure we don't issue *two* error messages for the trait predicate *and* host predicate. +// Make sure we don't issue *two* error messages for the trait clause *and* host clause. #![feature(const_trait_impl)]