Use != Positive rather than == Negative
Feels more complete, and for ImplPolarity has the side-effect of making sure we also handle reservation impls correctly
This commit is contained in:
parent
4b87c0b9c9
commit
127e42d33b
6 changed files with 6 additions and 6 deletions
|
@ -710,7 +710,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||||
// Don't register additional associated type bounds for negative bounds,
|
// Don't register additional associated type bounds for negative bounds,
|
||||||
// since we should have emitten an error for them earlier, and they will
|
// since we should have emitten an error for them earlier, and they will
|
||||||
// not be well-formed!
|
// not be well-formed!
|
||||||
if polarity == ty::PredicatePolarity::Negative {
|
if polarity != ty::PredicatePolarity::Positive {
|
||||||
assert!(
|
assert!(
|
||||||
self.tcx().dcx().has_errors().is_some(),
|
self.tcx().dcx().has_errors().is_some(),
|
||||||
"negative trait bounds should not have bindings",
|
"negative trait bounds should not have bindings",
|
||||||
|
|
|
@ -3367,7 +3367,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
"inherent impls can't be candidates, only trait impls can be",
|
"inherent impls can't be candidates, only trait impls can be",
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.filter(|header| header.polarity == ty::ImplPolarity::Negative)
|
.filter(|header| header.polarity != ty::ImplPolarity::Positive)
|
||||||
.any(|header| {
|
.any(|header| {
|
||||||
let imp = header.trait_ref.instantiate_identity();
|
let imp = header.trait_ref.instantiate_identity();
|
||||||
let imp_simp =
|
let imp_simp =
|
||||||
|
|
|
@ -270,7 +270,7 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
|
||||||
match bound_clause.skip_binder() {
|
match bound_clause.skip_binder() {
|
||||||
ty::ClauseKind::Trait(data) => {
|
ty::ClauseKind::Trait(data) => {
|
||||||
// Negative trait bounds do not imply any supertrait bounds
|
// Negative trait bounds do not imply any supertrait bounds
|
||||||
if data.polarity == ty::PredicatePolarity::Negative {
|
if data.polarity != ty::PredicatePolarity::Positive {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 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.
|
||||||
|
|
|
@ -295,7 +295,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
||||||
}) = impl_source
|
}) = impl_source
|
||||||
{
|
{
|
||||||
// Blame 'tidy' for the weird bracket placement.
|
// Blame 'tidy' for the weird bracket placement.
|
||||||
if infcx.tcx.impl_polarity(*impl_def_id) == ty::ImplPolarity::Negative {
|
if infcx.tcx.impl_polarity(*impl_def_id) != ty::ImplPolarity::Positive {
|
||||||
debug!(
|
debug!(
|
||||||
"evaluate_nested_obligations: found explicit negative impl\
|
"evaluate_nested_obligations: found explicit negative impl\
|
||||||
{:?}, bailing out",
|
{:?}, bailing out",
|
||||||
|
|
|
@ -245,7 +245,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
associated_ty: Option<(&'static str, Ty<'tcx>)>,
|
associated_ty: Option<(&'static str, Ty<'tcx>)>,
|
||||||
mut body_id: LocalDefId,
|
mut body_id: LocalDefId,
|
||||||
) {
|
) {
|
||||||
if trait_pred.skip_binder().polarity == ty::PredicatePolarity::Negative {
|
if trait_pred.skip_binder().polarity != ty::PredicatePolarity::Positive {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1907,7 +1907,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||||
.all_impls(trait_pred.def_id())
|
.all_impls(trait_pred.def_id())
|
||||||
.filter_map(|def_id| {
|
.filter_map(|def_id| {
|
||||||
let imp = self.tcx.impl_trait_header(def_id).unwrap();
|
let imp = self.tcx.impl_trait_header(def_id).unwrap();
|
||||||
if imp.polarity == ty::ImplPolarity::Negative
|
if imp.polarity != ty::ImplPolarity::Positive
|
||||||
|| !self.tcx.is_user_visible_dep(def_id.krate)
|
|| !self.tcx.is_user_visible_dep(def_id.krate)
|
||||||
{
|
{
|
||||||
return None;
|
return None;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue