@@ -8,7 +8,7 @@ use rustc_hir as hir;
8
8
use rustc_hir:: def:: DefKind ;
9
9
use rustc_hir:: def_id:: { DefId , LocalDefId } ;
10
10
use rustc_hir:: intravisit:: { self , Visitor } ;
11
- use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
11
+ use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeVisitableExt } ;
12
12
use rustc_middle:: ty:: { GenericPredicates , ImplTraitInTraitData , Upcast } ;
13
13
use rustc_middle:: { bug, span_bug} ;
14
14
use rustc_span:: symbol:: Ident ;
@@ -86,6 +86,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
86
86
parent : Some ( tcx. parent ( def_id. to_def_id ( ) ) ) ,
87
87
predicates : tcx. arena . alloc_from_iter ( predicates) ,
88
88
effects_min_tys : ty:: List :: empty ( ) ,
89
+ tainted_by_errors : Ok ( ( ) ) ,
89
90
} ;
90
91
}
91
92
@@ -108,6 +109,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
108
109
parent : Some ( impl_def_id) ,
109
110
predicates : tcx. arena . alloc_from_iter ( impl_predicates) ,
110
111
effects_min_tys : ty:: List :: empty ( ) ,
112
+ tainted_by_errors : trait_assoc_predicates. tainted_by_errors ,
111
113
} ;
112
114
}
113
115
@@ -128,6 +130,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
128
130
// Preserving the order of insertion is important here so as not to break UI tests.
129
131
let mut predicates: FxIndexSet < ( ty:: Clause < ' _ > , Span ) > = FxIndexSet :: default ( ) ;
130
132
let mut effects_min_tys = Vec :: new ( ) ;
133
+ let mut tainted_by_errors = Ok ( ( ) ) ;
131
134
132
135
let hir_generics = node. generics ( ) . unwrap_or ( NO_GENERICS ) ;
133
136
if let Node :: Item ( item) = node {
@@ -291,11 +294,16 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
291
294
if let Node :: Item ( & Item { kind : ItemKind :: Impl { .. } , .. } ) = node {
292
295
let self_ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
293
296
let trait_ref = tcx. impl_trait_ref ( def_id) . map ( ty:: EarlyBinder :: instantiate_identity) ;
294
- cgp:: setup_constraining_predicates (
295
- tcx,
296
- & mut predicates,
297
- trait_ref,
298
- & mut cgp:: parameters_for_impl ( tcx, self_ty, trait_ref) ,
297
+ let mut input_parameters = cgp:: parameters_for_impl ( tcx, self_ty, trait_ref) ;
298
+ cgp:: setup_constraining_predicates ( tcx, & mut predicates, trait_ref, & mut input_parameters) ;
299
+ tainted_by_errors = tainted_by_errors. and (
300
+ self_ty. error_reported ( ) . and ( trait_ref. error_reported ( ) ) . and_then ( |( ) | {
301
+ crate :: impl_wf_check:: enforce_impl_params_are_constrained (
302
+ tcx,
303
+ def_id,
304
+ input_parameters,
305
+ )
306
+ } ) ,
299
307
) ;
300
308
}
301
309
@@ -338,6 +346,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
338
346
parent : generics. parent ,
339
347
predicates : tcx. arena . alloc_from_iter ( predicates) ,
340
348
effects_min_tys : tcx. mk_type_list ( & effects_min_tys) ,
349
+ tainted_by_errors,
341
350
}
342
351
}
343
352
@@ -489,6 +498,7 @@ pub(super) fn explicit_predicates_of<'tcx>(
489
498
parent : predicates_and_bounds. parent ,
490
499
predicates : tcx. arena . alloc_slice ( & predicates) ,
491
500
effects_min_tys : predicates_and_bounds. effects_min_tys ,
501
+ tainted_by_errors : predicates_and_bounds. tainted_by_errors ,
492
502
}
493
503
}
494
504
} else {
@@ -541,6 +551,7 @@ pub(super) fn explicit_predicates_of<'tcx>(
541
551
parent : parent_preds. parent ,
542
552
predicates : { tcx. arena . alloc_from_iter ( filtered_predicates) } ,
543
553
effects_min_tys : parent_preds. effects_min_tys ,
554
+ tainted_by_errors : parent_preds. tainted_by_errors ,
544
555
} ;
545
556
}
546
557
gather_explicit_predicates_of ( tcx, def_id)
@@ -653,6 +664,7 @@ pub(super) fn implied_predicates_with_filter(
653
664
parent : None ,
654
665
predicates : implied_bounds,
655
666
effects_min_tys : ty:: List :: empty ( ) ,
667
+ tainted_by_errors : Ok ( ( ) ) ,
656
668
}
657
669
}
658
670
@@ -688,7 +700,12 @@ pub(super) fn type_param_predicates(
688
700
let icx = ItemCtxt :: new ( tcx, parent) ;
689
701
icx. probe_ty_param_bounds ( DUMMY_SP , def_id, assoc_name)
690
702
} )
691
- . unwrap_or_default ( ) ;
703
+ . unwrap_or ( GenericPredicates {
704
+ parent : None ,
705
+ predicates : & [ ] ,
706
+ effects_min_tys : ty:: List :: empty ( ) ,
707
+ tainted_by_errors : Ok ( ( ) ) ,
708
+ } ) ;
692
709
let mut extend = None ;
693
710
694
711
let item_hir_id = tcx. local_def_id_to_hir_id ( item_def_id) ;
0 commit comments