Rollup merge of #132344 - compiler-errors:same-thing, r=lcnr
Merge `HostPolarity` and `BoundConstness` They're basically the same thing, and I think `BoundConstness` is easier to use. r? fee1-dead or reassign
This commit is contained in:
commit
7b19508abe
16 changed files with 66 additions and 81 deletions
|
@ -84,11 +84,11 @@ impl<'tcx> Bounds<'tcx> {
|
|||
&mut self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
bound_trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
host: ty::HostPolarity,
|
||||
constness: ty::BoundConstness,
|
||||
span: Span,
|
||||
) {
|
||||
if tcx.is_const_trait(bound_trait_ref.def_id()) {
|
||||
self.clauses.push((bound_trait_ref.to_host_effect_clause(tcx, host), span));
|
||||
self.clauses.push((bound_trait_ref.to_host_effect_clause(tcx, constness), span));
|
||||
} else {
|
||||
tcx.dcx().span_delayed_bug(span, "tried to lower {host:?} bound for non-const trait");
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ fn compare_method_predicate_entailment<'tcx>(
|
|||
tcx.const_conditions(trait_m.def_id).instantiate_own(tcx, trait_to_impl_args),
|
||||
)
|
||||
.map(|(trait_ref, _)| {
|
||||
trait_ref.to_host_effect_clause(tcx, ty::HostPolarity::Maybe)
|
||||
trait_ref.to_host_effect_clause(tcx, ty::BoundConstness::Maybe)
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ fn compare_method_predicate_entailment<'tcx>(
|
|||
tcx,
|
||||
cause,
|
||||
param_env,
|
||||
const_condition.to_host_effect_clause(tcx, ty::HostPolarity::Maybe),
|
||||
const_condition.to_host_effect_clause(tcx, ty::BoundConstness::Maybe),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -1942,7 +1942,7 @@ fn compare_type_predicate_entailment<'tcx>(
|
|||
tcx.const_conditions(trait_ty.def_id).instantiate_own(tcx, trait_to_impl_args),
|
||||
)
|
||||
.map(|(trait_ref, _)| {
|
||||
trait_ref.to_host_effect_clause(tcx, ty::HostPolarity::Maybe)
|
||||
trait_ref.to_host_effect_clause(tcx, ty::BoundConstness::Maybe)
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
@ -1985,7 +1985,7 @@ fn compare_type_predicate_entailment<'tcx>(
|
|||
tcx,
|
||||
cause,
|
||||
param_env,
|
||||
const_condition.to_host_effect_clause(tcx, ty::HostPolarity::Maybe),
|
||||
const_condition.to_host_effect_clause(tcx, ty::BoundConstness::Maybe),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -2091,7 +2091,7 @@ pub(super) fn check_type_bounds<'tcx>(
|
|||
tcx,
|
||||
mk_cause(span),
|
||||
param_env,
|
||||
c.to_host_effect_clause(tcx, ty::HostPolarity::Maybe),
|
||||
c.to_host_effect_clause(tcx, ty::BoundConstness::Maybe),
|
||||
)
|
||||
}),
|
||||
);
|
||||
|
|
|
@ -1388,7 +1388,7 @@ fn check_impl<'tcx>(
|
|||
ObligationCauseCode::WellFormed(None),
|
||||
),
|
||||
wfcx.param_env,
|
||||
bound.to_host_effect_clause(tcx, ty::HostPolarity::Maybe),
|
||||
bound.to_host_effect_clause(tcx, ty::BoundConstness::Maybe),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -709,7 +709,7 @@ pub(super) fn assert_only_contains_predicates_from<'tcx>(
|
|||
match clause.kind().skip_binder() {
|
||||
ty::ClauseKind::HostEffect(ty::HostEffectPredicate {
|
||||
trait_ref: _,
|
||||
host: ty::HostPolarity::Maybe,
|
||||
constness: ty::BoundConstness::Maybe,
|
||||
}) => {}
|
||||
_ => {
|
||||
bug!(
|
||||
|
@ -725,8 +725,8 @@ pub(super) fn assert_only_contains_predicates_from<'tcx>(
|
|||
match clause.kind().skip_binder() {
|
||||
ty::ClauseKind::HostEffect(pred) => {
|
||||
assert_eq!(
|
||||
pred.host,
|
||||
ty::HostPolarity::Maybe,
|
||||
pred.constness,
|
||||
ty::BoundConstness::Maybe,
|
||||
"expected `~const` predicate when computing `{filter:?}` \
|
||||
implied bounds: {clause:?}",
|
||||
);
|
||||
|
@ -936,7 +936,7 @@ pub(super) fn const_conditions<'tcx>(
|
|||
bounds.push_const_bound(
|
||||
tcx,
|
||||
ty::Binder::dummy(ty::TraitRef::identity(tcx, def_id.to_def_id())),
|
||||
ty::HostPolarity::Maybe,
|
||||
ty::BoundConstness::Maybe,
|
||||
DUMMY_SP,
|
||||
);
|
||||
|
||||
|
@ -956,7 +956,7 @@ pub(super) fn const_conditions<'tcx>(
|
|||
clause.kind().map_bound(|clause| match clause {
|
||||
ty::ClauseKind::HostEffect(ty::HostEffectPredicate {
|
||||
trait_ref,
|
||||
host: ty::HostPolarity::Maybe,
|
||||
constness: ty::BoundConstness::Maybe,
|
||||
}) => trait_ref,
|
||||
_ => bug!("converted {clause:?}"),
|
||||
}),
|
||||
|
@ -994,7 +994,7 @@ pub(super) fn implied_const_bounds<'tcx>(
|
|||
clause.kind().map_bound(|clause| match clause {
|
||||
ty::ClauseKind::HostEffect(ty::HostEffectPredicate {
|
||||
trait_ref,
|
||||
host: ty::HostPolarity::Maybe,
|
||||
constness: ty::BoundConstness::Maybe,
|
||||
}) => trait_ref,
|
||||
_ => bug!("converted {clause:?}"),
|
||||
}),
|
||||
|
|
|
@ -721,7 +721,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
bounds.push_const_bound(
|
||||
tcx,
|
||||
poly_trait_ref,
|
||||
ty::HostPolarity::Const,
|
||||
ty::BoundConstness::Const,
|
||||
span,
|
||||
);
|
||||
}
|
||||
|
@ -744,7 +744,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst => match constness {
|
||||
hir::BoundConstness::Maybe(span) => {
|
||||
if polarity == ty::PredicatePolarity::Positive {
|
||||
bounds.push_const_bound(tcx, poly_trait_ref, ty::HostPolarity::Maybe, span);
|
||||
bounds.push_const_bound(
|
||||
tcx,
|
||||
poly_trait_ref,
|
||||
ty::BoundConstness::Maybe,
|
||||
span,
|
||||
);
|
||||
}
|
||||
}
|
||||
hir::BoundConstness::Always(_) | hir::BoundConstness::Never => {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue