File tree 3 files changed +25
-5
lines changed
compiler/rustc_hir_analysis/src/collect
tests/ui/traits/negative-bounds
3 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -657,14 +657,15 @@ pub(super) fn implied_predicates_with_filter(
657
657
& * tcx. arena . alloc_from_iter ( superbounds. predicates ( ) . chain ( where_bounds_that_match) ) ;
658
658
debug ! ( ?implied_bounds) ;
659
659
660
- // Now require that immediate supertraits are converted,
661
- // which will, in turn, reach indirect supertraits.
660
+ // Now require that immediate supertraits are converted, which will, in
661
+ // turn, reach indirect supertraits, so we detect cycles now instead of
662
+ // overflowing during elaboration.
662
663
if matches ! ( filter, PredicateFilter :: SelfOnly ) {
663
- // Now require that immediate supertraits are converted,
664
- // which will, in turn, reach indirect supertraits.
665
664
for & ( pred, span) in implied_bounds {
666
665
debug ! ( "superbound: {:?}" , pred) ;
667
- if let ty:: PredicateKind :: Clause ( ty:: Clause :: Trait ( bound) ) = pred. kind ( ) . skip_binder ( ) {
666
+ if let ty:: PredicateKind :: Clause ( ty:: Clause :: Trait ( bound) ) = pred. kind ( ) . skip_binder ( )
667
+ && bound. polarity == ty:: ImplPolarity :: Positive
668
+ {
668
669
tcx. at ( span) . super_predicates_of ( bound. def_id ( ) ) ;
669
670
}
670
671
}
Original file line number Diff line number Diff line change
1
+ // check-pass
2
+
3
+ #![ feature( negative_bounds) ]
4
+ //~^ WARN the feature `negative_bounds` is incomplete
5
+
6
+ trait A : !B { }
7
+ trait B : !A { }
8
+
9
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ warning: the feature `negative_bounds` is incomplete and may not be safe to use and/or cause compiler crashes
2
+ --> $DIR/supertrait.rs:3:12
3
+ |
4
+ LL | #![feature(negative_bounds)]
5
+ | ^^^^^^^^^^^^^^^
6
+ |
7
+ = note: `#[warn(incomplete_features)]` on by default
8
+
9
+ warning: 1 warning emitted
10
+
You can’t perform that action at this time.
0 commit comments