Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 127e42d

Browse files
Use != Positive rather than == Negative
Feels more complete, and for ImplPolarity has the side-effect of making sure we also handle reservation impls correctly
1 parent 4b87c0b commit 127e42d

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

‎compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
710710
// Don't register additional associated type bounds for negative bounds,
711711
// since we should have emitten an error for them earlier, and they will
712712
// not be well-formed!
713-
if polarity == ty::PredicatePolarity::Negative {
713+
if polarity != ty::PredicatePolarity::Positive {
714714
assert!(
715715
self.tcx().dcx().has_errors().is_some(),
716716
"negative trait bounds should not have bindings",

‎compiler/rustc_hir_typeck/src/method/suggest.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3367,7 +3367,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33673367
"inherent impls can't be candidates, only trait impls can be",
33683368
)
33693369
})
3370-
.filter(|header| header.polarity == ty::ImplPolarity::Negative)
3370+
.filter(|header| header.polarity != ty::ImplPolarity::Positive)
33713371
.any(|header| {
33723372
let imp = header.trait_ref.instantiate_identity();
33733373
let imp_simp =

‎compiler/rustc_infer/src/traits/util.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
270270
match bound_clause.skip_binder() {
271271
ty::ClauseKind::Trait(data) => {
272272
// Negative trait bounds do not imply any supertrait bounds
273-
if data.polarity == ty::PredicatePolarity::Negative {
273+
if data.polarity != ty::PredicatePolarity::Positive {
274274
return;
275275
}
276276
// Get predicates implied by the trait, or only super predicates if we only care about self predicates.

‎compiler/rustc_trait_selection/src/traits/auto_trait.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
295295
}) = impl_source
296296
{
297297
// Blame 'tidy' for the weird bracket placement.
298-
if infcx.tcx.impl_polarity(*impl_def_id) == ty::ImplPolarity::Negative {
298+
if infcx.tcx.impl_polarity(*impl_def_id) != ty::ImplPolarity::Positive {
299299
debug!(
300300
"evaluate_nested_obligations: found explicit negative impl\
301301
{:?}, bailing out",

‎compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
245245
associated_ty: Option<(&'static str, Ty<'tcx>)>,
246246
mut body_id: LocalDefId,
247247
) {
248-
if trait_pred.skip_binder().polarity == ty::PredicatePolarity::Negative {
248+
if trait_pred.skip_binder().polarity != ty::PredicatePolarity::Positive {
249249
return;
250250
}
251251

‎compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1907,7 +1907,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
19071907
.all_impls(trait_pred.def_id())
19081908
.filter_map(|def_id| {
19091909
let imp = self.tcx.impl_trait_header(def_id).unwrap();
1910-
if imp.polarity == ty::ImplPolarity::Negative
1910+
if imp.polarity != ty::ImplPolarity::Positive
19111911
|| !self.tcx.is_user_visible_dep(def_id.krate)
19121912
{
19131913
return None;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /