Rollup merge of #122839 - compiler-errors:predicate-polarity, r=lcnr
Split out `PredicatePolarity` from `ImplPolarity` Because having to deal with a third `Reservation` level in all the trait solver code is kind of weird. r? `@lcnr` or `@oli-obk`
This commit is contained in:
commit
80306927cf
35 changed files with 163 additions and 120 deletions
|
@ -42,7 +42,7 @@ impl<'tcx> Bounds<'tcx> {
|
|||
tcx: TyCtxt<'tcx>,
|
||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
span: Span,
|
||||
polarity: ty::ImplPolarity,
|
||||
polarity: ty::PredicatePolarity,
|
||||
) {
|
||||
self.push_trait_bound_inner(tcx, trait_ref, span, polarity);
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ impl<'tcx> Bounds<'tcx> {
|
|||
tcx: TyCtxt<'tcx>,
|
||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
span: Span,
|
||||
polarity: ty::ImplPolarity,
|
||||
polarity: ty::PredicatePolarity,
|
||||
) {
|
||||
self.clauses.push((
|
||||
trait_ref
|
||||
|
|
|
@ -1322,7 +1322,7 @@ fn check_impl<'tcx>(
|
|||
trait_ref,
|
||||
);
|
||||
let trait_pred =
|
||||
ty::TraitPredicate { trait_ref, polarity: ty::ImplPolarity::Positive };
|
||||
ty::TraitPredicate { trait_ref, polarity: ty::PredicatePolarity::Positive };
|
||||
let mut obligations = traits::wf::trait_obligations(
|
||||
wfcx.infcx,
|
||||
wfcx.param_env,
|
||||
|
|
|
@ -551,7 +551,7 @@ fn infringing_fields_error(
|
|||
}
|
||||
if let ty::PredicateKind::Clause(ty::ClauseKind::Trait(ty::TraitPredicate {
|
||||
trait_ref,
|
||||
polarity: ty::ImplPolarity::Positive,
|
||||
polarity: ty::PredicatePolarity::Positive,
|
||||
..
|
||||
})) = error_predicate.kind().skip_binder()
|
||||
{
|
||||
|
|
|
@ -624,7 +624,7 @@ pub(super) fn implied_predicates_with_filter(
|
|||
for &(pred, span) in implied_bounds {
|
||||
debug!("superbound: {:?}", pred);
|
||||
if let ty::ClauseKind::Trait(bound) = pred.kind().skip_binder()
|
||||
&& bound.polarity == ty::ImplPolarity::Positive
|
||||
&& bound.polarity == ty::PredicatePolarity::Positive
|
||||
{
|
||||
tcx.at(span).super_predicates_of(bound.def_id());
|
||||
}
|
||||
|
@ -634,7 +634,7 @@ pub(super) fn implied_predicates_with_filter(
|
|||
for &(pred, span) in implied_bounds {
|
||||
debug!("superbound: {:?}", pred);
|
||||
if let ty::ClauseKind::Trait(bound) = pred.kind().skip_binder()
|
||||
&& bound.polarity == ty::ImplPolarity::Positive
|
||||
&& bound.polarity == ty::PredicatePolarity::Positive
|
||||
{
|
||||
tcx.at(span).implied_predicates_of(bound.def_id());
|
||||
}
|
||||
|
|
|
@ -140,16 +140,16 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
hir::GenericBound::Trait(poly_trait_ref, modifier) => {
|
||||
let (constness, polarity) = match modifier {
|
||||
hir::TraitBoundModifier::Const => {
|
||||
(ty::BoundConstness::Const, ty::ImplPolarity::Positive)
|
||||
(ty::BoundConstness::Const, ty::PredicatePolarity::Positive)
|
||||
}
|
||||
hir::TraitBoundModifier::MaybeConst => {
|
||||
(ty::BoundConstness::ConstIfConst, ty::ImplPolarity::Positive)
|
||||
(ty::BoundConstness::ConstIfConst, ty::PredicatePolarity::Positive)
|
||||
}
|
||||
hir::TraitBoundModifier::None => {
|
||||
(ty::BoundConstness::NotConst, ty::ImplPolarity::Positive)
|
||||
(ty::BoundConstness::NotConst, ty::PredicatePolarity::Positive)
|
||||
}
|
||||
hir::TraitBoundModifier::Negative => {
|
||||
(ty::BoundConstness::NotConst, ty::ImplPolarity::Negative)
|
||||
(ty::BoundConstness::NotConst, ty::PredicatePolarity::Negative)
|
||||
}
|
||||
hir::TraitBoundModifier::Maybe => continue,
|
||||
};
|
||||
|
|
|
@ -673,7 +673,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
trait_ref: &hir::TraitRef<'tcx>,
|
||||
span: Span,
|
||||
constness: ty::BoundConstness,
|
||||
polarity: ty::ImplPolarity,
|
||||
polarity: ty::PredicatePolarity,
|
||||
self_ty: Ty<'tcx>,
|
||||
bounds: &mut Bounds<'tcx>,
|
||||
only_self_bounds: OnlySelfBounds,
|
||||
|
@ -710,7 +710,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
// Don't register additional associated type bounds for negative bounds,
|
||||
// since we should have emitten an error for them earlier, and they will
|
||||
// not be well-formed!
|
||||
if polarity == ty::ImplPolarity::Negative {
|
||||
if polarity != ty::PredicatePolarity::Positive {
|
||||
assert!(
|
||||
self.tcx().dcx().has_errors().is_some(),
|
||||
"negative trait bounds should not have bindings",
|
||||
|
|
|
@ -43,7 +43,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
&trait_bound.trait_ref,
|
||||
trait_bound.span,
|
||||
ty::BoundConstness::NotConst,
|
||||
ty::ImplPolarity::Positive,
|
||||
ty::PredicatePolarity::Positive,
|
||||
dummy_self,
|
||||
&mut bounds,
|
||||
// True so we don't populate `bounds` with associated type bounds, even
|
||||
|
@ -60,7 +60,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
let bound_pred = pred.kind();
|
||||
match bound_pred.skip_binder() {
|
||||
ty::ClauseKind::Trait(trait_pred) => {
|
||||
assert_eq!(trait_pred.polarity, ty::ImplPolarity::Positive);
|
||||
assert_eq!(trait_pred.polarity, ty::PredicatePolarity::Positive);
|
||||
trait_bounds.push((bound_pred.rebind(trait_pred.trait_ref), span));
|
||||
}
|
||||
ty::ClauseKind::Projection(proj) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue