Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/always_applicable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
Expand Down
34 changes: 17 additions & 17 deletions compiler/rustc_hir_analysis/src/collect/clauses_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}"
);
}
Expand Down Expand Up @@ -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:?}"
);
}
Expand All @@ -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:?}"
);
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_hir_analysis/src/variance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Foo<'a>>;
// 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: _,
}) => {
Expand All @@ -219,7 +219,7 @@ fn variance_of_opaque(
region.visit_with(&mut collector);
}
_ => {
pred.visit_with(&mut collector);
clause.visit_with(&mut collector);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_middle/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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>,
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_middle/src/ty/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ impl<'tcx> GenericClauses<'tcx> {
#[derive(Copy, Clone, Default, Debug, TyEncodable, TyDecodable, StableHash)]
pub struct ConstConditions<'tcx> {
pub parent: Option<DefId>,
pub predicates: &'tcx [(ty::PolyTraitRef<'tcx>, Span)],
pub clauses: &'tcx [(ty::PolyTraitRef<'tcx>, Span)],
}

impl<'tcx> ConstConditions<'tcx> {
Expand All @@ -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())
})
Expand All @@ -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())
})
Expand All @@ -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)),
);
}

Expand All @@ -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)),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 5 additions & 13 deletions compiler/rustc_middle/src/ty/predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub type ExistentialPredicate<'tcx> = ir::ExistentialPredicate<TyCtxt<'tcx>>;
pub type ExistentialTraitRef<'tcx> = ir::ExistentialTraitRef<TyCtxt<'tcx>>;
pub type ExistentialProjection<'tcx> = ir::ExistentialProjection<TyCtxt<'tcx>>;
pub type TraitPredicate<'tcx> = ir::TraitPredicate<TyCtxt<'tcx>>;
pub type HostEffectPredicate<'tcx> = ir::HostEffectPredicate<TyCtxt<'tcx>>;
pub type HostEffectClause<'tcx> = ir::HostEffectClause<TyCtxt<'tcx>>;
pub type ClauseKind<'tcx> = ir::ClauseKind<TyCtxt<'tcx>>;
pub type PredicateKind<'tcx> = ir::PredicateKind<TyCtxt<'tcx>>;
pub type NormalizesTo<'tcx> = ir::NormalizesTo<TyCtxt<'tcx>>;
Expand Down Expand Up @@ -582,24 +582,16 @@ impl<'tcx> UpcastFrom<TyCtxt<'tcx>, PolyProjectionPredicate<'tcx>> for Clause<'t
}
}

impl<'tcx> UpcastFrom<TyCtxt<'tcx>, ty::Binder<'tcx, ty::HostEffectPredicate<'tcx>>>
impl<'tcx> UpcastFrom<TyCtxt<'tcx>, 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<TyCtxt<'tcx>, 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<TyCtxt<'tcx>, 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)
}
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]" }
Expand All @@ -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)?;
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_next_trait_solver/src/solve/effect_goals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::solve::{
BuiltinImplSource, CandidateSource, Certainty, EvalCtxt, Goal, GoalSource, NoSolution, assembly,
};

impl<D, I> assembly::GoalKind<D> for ty::HostEffectPredicate<I>
impl<D, I> assembly::GoalKind<D> for ty::HostEffectClause<I>
where
D: SolverDelegate<Interner = I>,
I: Interner,
Expand Down Expand Up @@ -481,7 +481,7 @@ where
#[instrument(level = "trace", skip(self))]
pub(super) fn compute_host_effect_goal(
&mut self,
goal: Goal<I, ty::HostEffectPredicate<I>>,
goal: Goal<I, ty::HostEffectClause<I>>,
) -> QueryResultOrRerunNonErased<I> {
let (_, proven_via) = self.probe(|_| ProbeKind::ShadowedEnvProbing).enter(|ecx| {
let trait_goal: Goal<I, ty::TraitPredicate<I>> =
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_privacy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down Expand Up @@ -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,
);
Expand Down Expand Up @@ -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,
Expand All @@ -1527,9 +1527,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {

fn as_host_effect_clause(
predicate: ty::Predicate<'tcx>,
) -> Option<ty::Binder<'tcx, ty::HostEffectPredicate<'tcx>>> {
) -> Option<ty::Binder<'tcx, ty::HostEffectClause<'tcx>>> {
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,
})
}
Expand Down
Loading
Loading