@@ -668,7 +668,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
668
668
trait_ref : & hir:: TraitRef < ' tcx > ,
669
669
span : Span ,
670
670
constness : hir:: BoundConstness ,
671
- polarity : ty :: PredicatePolarity ,
671
+ polarity : hir :: BoundPolarity ,
672
672
self_ty : Ty < ' tcx > ,
673
673
bounds : & mut Bounds < ' tcx > ,
674
674
predicate_filter : PredicateFilter ,
@@ -690,15 +690,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
690
690
Some ( self_ty) ,
691
691
) ;
692
692
693
- if let hir:: BoundConstness :: Always ( span) | hir:: BoundConstness :: Maybe ( span) = constness
694
- && !self . tcx ( ) . is_const_trait ( trait_def_id)
695
- {
696
- self . dcx ( ) . emit_err ( crate :: errors:: ConstBoundForNonConstTrait {
697
- span,
698
- modifier : constness. as_str ( ) ,
699
- } ) ;
700
- }
701
-
702
693
let tcx = self . tcx ( ) ;
703
694
let bound_vars = tcx. late_bound_vars ( trait_ref. hir_ref_id ) ;
704
695
debug ! ( ?bound_vars) ;
@@ -708,6 +699,36 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
708
699
bound_vars,
709
700
) ;
710
701
702
+ let polarity = match polarity {
703
+ rustc_ast:: BoundPolarity :: Positive => ty:: PredicatePolarity :: Positive ,
704
+ rustc_ast:: BoundPolarity :: Negative ( _) => ty:: PredicatePolarity :: Negative ,
705
+ rustc_ast:: BoundPolarity :: Maybe ( _) => {
706
+ // Validate associated type at least. We may want to reject these
707
+ // outright in the future...
708
+ for constraint in trait_segment. args ( ) . constraints {
709
+ let _ = self . lower_assoc_item_constraint (
710
+ trait_ref. hir_ref_id ,
711
+ poly_trait_ref,
712
+ constraint,
713
+ & mut Default :: default ( ) ,
714
+ & mut Default :: default ( ) ,
715
+ constraint. span ,
716
+ predicate_filter,
717
+ ) ;
718
+ }
719
+ return arg_count;
720
+ }
721
+ } ;
722
+
723
+ if let hir:: BoundConstness :: Always ( span) | hir:: BoundConstness :: Maybe ( span) = constness
724
+ && !self . tcx ( ) . is_const_trait ( trait_def_id)
725
+ {
726
+ self . dcx ( ) . emit_err ( crate :: errors:: ConstBoundForNonConstTrait {
727
+ span,
728
+ modifier : constness. as_str ( ) ,
729
+ } ) ;
730
+ }
731
+
711
732
match predicate_filter {
712
733
PredicateFilter :: All
713
734
| PredicateFilter :: SelfOnly
@@ -763,11 +784,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
763
784
// since we should have emitted an error for them earlier, and they
764
785
// would not be well-formed!
765
786
if polarity != ty:: PredicatePolarity :: Positive {
766
- assert ! (
767
- self . dcx ( ) . has_errors ( ) . is_some ( ) ,
787
+ self . dcx ( ) . span_delayed_bug (
788
+ constraint . span ,
768
789
"negative trait bounds should not have assoc item constraints" ,
769
790
) ;
770
- continue ;
791
+ break ;
771
792
}
772
793
773
794
// Specify type to assert that error was already reported in `Err` case.
0 commit comments