@@ -6,7 +6,8 @@ use rustc_hir as hir;
6
6
use rustc_hir:: def:: DefKind ;
7
7
use rustc_hir:: def_id:: { DefId , LocalDefId } ;
8
8
use rustc_middle:: ty:: {
9
- self , GenericPredicates , ImplTraitInTraitData , Ty , TyCtxt , TypeVisitable , TypeVisitor , Upcast ,
9
+ self , GenericPredicates , ImplTraitInTraitData , Ty , TyCtxt , TypeVisitable , TypeVisitableExt ,
10
+ TypeVisitor , Upcast ,
10
11
} ;
11
12
use rustc_middle:: { bug, span_bug} ;
12
13
use rustc_span:: symbol:: Ident ;
@@ -107,6 +108,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
107
108
return ty:: GenericPredicates {
108
109
parent : Some ( tcx. parent ( def_id. to_def_id ( ) ) ) ,
109
110
predicates : tcx. arena . alloc_from_iter ( predicates) ,
111
+ errored_due_to_unconstrained_params : Ok ( ( ) ) ,
110
112
} ;
111
113
}
112
114
@@ -128,6 +130,8 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
128
130
return ty:: GenericPredicates {
129
131
parent : Some ( impl_def_id) ,
130
132
predicates : tcx. arena . alloc_from_iter ( impl_predicates) ,
133
+ errored_due_to_unconstrained_params : trait_assoc_predicates
134
+ . errored_due_to_unconstrained_params ,
131
135
} ;
132
136
}
133
137
@@ -153,6 +157,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
153
157
// We use an `IndexSet` to preserve order of insertion.
154
158
// Preserving the order of insertion is important here so as not to break UI tests.
155
159
let mut predicates: FxIndexSet < ( ty:: Clause < ' _ > , Span ) > = FxIndexSet :: default ( ) ;
160
+ let mut errored_due_to_unconstrained_params = Ok ( ( ) ) ;
156
161
157
162
let hir_generics = node. generics ( ) . unwrap_or ( NO_GENERICS ) ;
158
163
if let Node :: Item ( item) = node {
@@ -319,11 +324,16 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
319
324
if let Node :: Item ( & Item { kind : ItemKind :: Impl { .. } , .. } ) = node {
320
325
let self_ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
321
326
let trait_ref = tcx. impl_trait_ref ( def_id) . map ( ty:: EarlyBinder :: instantiate_identity) ;
322
- cgp:: setup_constraining_predicates (
323
- tcx,
324
- & mut predicates,
325
- trait_ref,
326
- & mut cgp:: parameters_for_impl ( tcx, self_ty, trait_ref) ,
327
+ let mut input_parameters = cgp:: parameters_for_impl ( tcx, self_ty, trait_ref) ;
328
+ cgp:: setup_constraining_predicates ( tcx, & mut predicates, trait_ref, & mut input_parameters) ;
329
+ errored_due_to_unconstrained_params = errored_due_to_unconstrained_params. and (
330
+ self_ty. error_reported ( ) . and ( trait_ref. error_reported ( ) ) . and_then ( |( ) | {
331
+ crate :: impl_wf_check:: enforce_impl_params_are_constrained (
332
+ tcx,
333
+ def_id,
334
+ input_parameters,
335
+ )
336
+ } ) ,
327
337
) ;
328
338
}
329
339
@@ -338,6 +348,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
338
348
ty:: GenericPredicates {
339
349
parent : generics. parent ,
340
350
predicates : tcx. arena . alloc_from_iter ( predicates) ,
351
+ errored_due_to_unconstrained_params,
341
352
}
342
353
}
343
354
@@ -507,6 +518,8 @@ pub(super) fn explicit_predicates_of<'tcx>(
507
518
ty:: GenericPredicates {
508
519
parent : predicates_and_bounds. parent ,
509
520
predicates : tcx. arena . alloc_slice ( & predicates) ,
521
+ errored_due_to_unconstrained_params : predicates_and_bounds
522
+ . errored_due_to_unconstrained_params ,
510
523
}
511
524
}
512
525
} else {
@@ -558,6 +571,8 @@ pub(super) fn explicit_predicates_of<'tcx>(
558
571
return GenericPredicates {
559
572
parent : parent_preds. parent ,
560
573
predicates : { tcx. arena . alloc_from_iter ( filtered_predicates) } ,
574
+ errored_due_to_unconstrained_params : parent_preds
575
+ . errored_due_to_unconstrained_params ,
561
576
} ;
562
577
}
563
578
gather_explicit_predicates_of ( tcx, def_id)
0 commit comments