@@ -681,11 +681,32 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
681
681
Some ( self_ty) ,
682
682
) ;
683
683
684
+ let tcx = self . tcx ( ) ;
685
+ let bound_vars = tcx. late_bound_vars ( trait_ref. hir_ref_id ) ;
686
+ debug ! ( ?bound_vars) ;
687
+
688
+ let poly_trait_ref = ty:: Binder :: bind_with_vars (
689
+ ty:: TraitRef :: new_from_args ( tcx, trait_def_id, generic_args) ,
690
+ bound_vars,
691
+ ) ;
692
+
684
693
let polarity = match polarity {
685
694
rustc_ast:: BoundPolarity :: Positive => ty:: PredicatePolarity :: Positive ,
686
695
rustc_ast:: BoundPolarity :: Negative ( _) => ty:: PredicatePolarity :: Negative ,
687
696
rustc_ast:: BoundPolarity :: Maybe ( _) => {
688
- // No-op.
697
+ // Validate associated type at least. We may want to reject these
698
+ // outright in the future...
699
+ for constraint in trait_segment. args ( ) . constraints {
700
+ let _ = self . lower_assoc_item_constraint (
701
+ trait_ref. hir_ref_id ,
702
+ poly_trait_ref,
703
+ constraint,
704
+ & mut Default :: default ( ) ,
705
+ & mut Default :: default ( ) ,
706
+ constraint. span ,
707
+ predicate_filter,
708
+ ) ;
709
+ }
689
710
return arg_count;
690
711
}
691
712
} ;
@@ -699,15 +720,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
699
720
} ) ;
700
721
}
701
722
702
- let tcx = self . tcx ( ) ;
703
- let bound_vars = tcx. late_bound_vars ( trait_ref. hir_ref_id ) ;
704
- debug ! ( ?bound_vars) ;
705
-
706
- let poly_trait_ref = ty:: Binder :: bind_with_vars (
707
- ty:: TraitRef :: new_from_args ( tcx, trait_def_id, generic_args) ,
708
- bound_vars,
709
- ) ;
710
-
711
723
match predicate_filter {
712
724
PredicateFilter :: All
713
725
| PredicateFilter :: SelfOnly
@@ -758,11 +770,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
758
770
// since we should have emitted an error for them earlier, and they
759
771
// would not be well-formed!
760
772
if polarity != ty:: PredicatePolarity :: Positive {
761
- assert ! (
762
- self . dcx ( ) . has_errors ( ) . is_some ( ) ,
773
+ self . dcx ( ) . span_delayed_bug (
774
+ constraint . span ,
763
775
"negative trait bounds should not have assoc item constraints" ,
764
776
) ;
765
- continue ;
777
+ break ;
766
778
}
767
779
768
780
// Specify type to assert that error was already reported in `Err` case.
0 commit comments