@@ -8,7 +8,7 @@ use rustc_hir as hir;
88use rustc_hir:: def:: DefKind ;
99use rustc_hir:: def_id:: { DefId , LocalDefId } ;
1010use rustc_hir:: intravisit:: { self , Visitor } ;
11- use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
11+ use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeVisitableExt } ;
1212use rustc_middle:: ty:: { GenericPredicates , ImplTraitInTraitData , Upcast } ;
1313use rustc_middle:: { bug, span_bug} ;
1414use rustc_span:: symbol:: Ident ;
@@ -86,6 +86,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
8686 parent : Some ( tcx. parent ( def_id. to_def_id ( ) ) ) ,
8787 predicates : tcx. arena . alloc_from_iter ( predicates) ,
8888 effects_min_tys : ty:: List :: empty ( ) ,
89+ tainted_by_errors : Ok ( ( ) ) ,
8990 } ;
9091 }
9192
@@ -108,6 +109,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
108109 parent : Some ( impl_def_id) ,
109110 predicates : tcx. arena . alloc_from_iter ( impl_predicates) ,
110111 effects_min_tys : ty:: List :: empty ( ) ,
112+ tainted_by_errors : trait_assoc_predicates. tainted_by_errors ,
111113 } ;
112114 }
113115
@@ -128,6 +130,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
128130 // Preserving the order of insertion is important here so as not to break UI tests.
129131 let mut predicates: FxIndexSet < ( ty:: Clause < ' _ > , Span ) > = FxIndexSet :: default ( ) ;
130132 let mut effects_min_tys = Vec :: new ( ) ;
133+ let mut tainted_by_errors = Ok ( ( ) ) ;
131134
132135 let hir_generics = node. generics ( ) . unwrap_or ( NO_GENERICS ) ;
133136 if let Node :: Item ( item) = node {
@@ -291,11 +294,16 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
291294 if let Node :: Item ( & Item { kind : ItemKind :: Impl { .. } , .. } ) = node {
292295 let self_ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
293296 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+ } ) ,
299307 ) ;
300308 }
301309
@@ -338,6 +346,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
338346 parent : generics. parent ,
339347 predicates : tcx. arena . alloc_from_iter ( predicates) ,
340348 effects_min_tys : tcx. mk_type_list ( & effects_min_tys) ,
349+ tainted_by_errors,
341350 }
342351}
343352
@@ -489,6 +498,7 @@ pub(super) fn explicit_predicates_of<'tcx>(
489498 parent : predicates_and_bounds. parent ,
490499 predicates : tcx. arena . alloc_slice ( & predicates) ,
491500 effects_min_tys : predicates_and_bounds. effects_min_tys ,
501+ tainted_by_errors : predicates_and_bounds. tainted_by_errors ,
492502 }
493503 }
494504 } else {
@@ -541,6 +551,7 @@ pub(super) fn explicit_predicates_of<'tcx>(
541551 parent : parent_preds. parent ,
542552 predicates : { tcx. arena . alloc_from_iter ( filtered_predicates) } ,
543553 effects_min_tys : parent_preds. effects_min_tys ,
554+ tainted_by_errors : parent_preds. tainted_by_errors ,
544555 } ;
545556 }
546557 gather_explicit_predicates_of ( tcx, def_id)
@@ -653,6 +664,7 @@ pub(super) fn implied_predicates_with_filter(
653664 parent : None ,
654665 predicates : implied_bounds,
655666 effects_min_tys : ty:: List :: empty ( ) ,
667+ tainted_by_errors : Ok ( ( ) ) ,
656668 }
657669}
658670
@@ -688,7 +700,12 @@ pub(super) fn type_param_predicates(
688700 let icx = ItemCtxt :: new ( tcx, parent) ;
689701 icx. probe_ty_param_bounds ( DUMMY_SP , def_id, assoc_name)
690702 } )
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+ } ) ;
692709 let mut extend = None ;
693710
694711 let item_hir_id = tcx. local_def_id_to_hir_id ( item_def_id) ;
0 commit comments