@@ -750,7 +750,7 @@ pub(crate) fn clean_generics<'tcx>(
750
750
751
751
fn clean_ty_generics < ' tcx > (
752
752
cx : & mut DocContext < ' tcx > ,
753
- generics : & ty:: Generics ,
753
+ generics : & ' tcx ty:: Generics ,
754
754
predicates : ty:: GenericPredicates < ' tcx > ,
755
755
_item_def_id : DefId ,
756
756
) -> Generics {
@@ -787,10 +787,48 @@ fn clean_ty_generics<'tcx>(
787
787
let mut impl_trait_proj =
788
788
FxHashMap :: < u32 , Vec < ( DefId , PathSegment , ty:: Binder < ' _ , ty:: Term < ' _ > > ) > > :: default ( ) ;
789
789
790
+ let item_span = {
791
+ if !predicates. predicates . is_empty ( ) {
792
+ let span = cx. tcx . def_span ( _item_def_id) ;
793
+ // FIXME: this is not correct if spans come from different expansions!
794
+ let params_sp = {
795
+ let mut params = generics. params . iter ( ) ;
796
+ if let Some ( param) = params. next ( ) {
797
+ let mut sp = cx. tcx . def_ident_span ( param. def_id ) . unwrap ( ) ;
798
+ while let Some ( param) = params. next ( ) {
799
+ sp = sp. to ( cx. tcx . def_ident_span ( param. def_id ) . unwrap ( ) ) ;
800
+ }
801
+ sp
802
+ } else {
803
+ None
804
+ }
805
+ } ;
806
+
807
+ Some ( span)
808
+ } else {
809
+ None
810
+ }
811
+ } ;
812
+
790
813
let where_predicates = predicates
791
814
. predicates
792
815
. iter ( )
793
- . flat_map ( |( pred, _) | {
816
+ . flat_map ( |( pred, span) | {
817
+ if !( span. is_dummy ( )
818
+ || span. is_empty ( )
819
+ || span. from_expansion ( )
820
+ || !cx. tcx . sess . source_map ( ) . is_span_accessible ( * span) )
821
+ {
822
+ let mut diag = cx. tcx . dcx ( ) . struct_span_warn ( * span, format ! ( "pred={pred:?}" ) ) ;
823
+
824
+ if let Some ( item_span) = item_span {
825
+ diag. span_note ( item_span, "span" ) ;
826
+ diag. note ( if item_span. contains ( * span) { "<...>" } else { "where ... " } ) ;
827
+ }
828
+
829
+ diag. emit ( ) ;
830
+ }
831
+
794
832
let mut projection = None ;
795
833
let param_idx = ( || {
796
834
let bound_p = pred. kind ( ) ;
0 commit comments