@@ -19,6 +19,7 @@ use rustc_hir::Node;
19
19
use rustc_middle:: mir:: interpret:: ErrorHandled ;
20
20
use rustc_middle:: ty:: error:: ExpectedFound ;
21
21
use rustc_middle:: ty:: fold:: TypeFolder ;
22
+ use rustc_middle:: ty:: subst:: GenericArgKind ;
22
23
use rustc_middle:: ty:: {
23
24
self , fast_reject, AdtKind , SubtypePredicate , ToPolyTraitRef , ToPredicate , Ty , TyCtxt ,
24
25
TypeFoldable , WithConstness ,
@@ -610,15 +611,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
610
611
}
611
612
}
612
613
613
- ty:: PredicateKind :: WellFormedConst ( ct) => {
614
- // Const WF predicates cannot themselves make
615
- // errors. They can only block due to
616
- // ambiguity; otherwise, they always
617
- // degenerate into other obligations
618
- // (which may fail).
619
- span_bug ! ( span, "const WF predicate not satisfied for {:?}" , ct) ;
620
- }
621
-
622
614
ty:: PredicateKind :: ConstEvaluatable ( ..) => {
623
615
// Errors for `ConstEvaluatable` predicates show up as
624
616
// `SelectionError::ConstEvalFailure`,
@@ -1540,22 +1532,24 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1540
1532
err
1541
1533
}
1542
1534
1543
- ty:: PredicateKind :: WellFormed ( ty ) => {
1535
+ ty:: PredicateKind :: WellFormed ( arg ) => {
1544
1536
// Same hacky approach as above to avoid deluging user
1545
1537
// with error messages.
1546
- if ty . references_error ( ) || self . tcx . sess . has_errors ( ) {
1538
+ if arg . references_error ( ) || self . tcx . sess . has_errors ( ) {
1547
1539
return ;
1548
1540
}
1549
- self . need_type_info_err ( body_id, span, ty, ErrorCode :: E0282 )
1550
- }
1551
1541
1552
- ty:: PredicateKind :: WellFormedConst ( ct) => {
1553
- // Same hacky approach as above to avoid deluging user
1554
- // with error messages.
1555
- if ct. references_error ( ) || self . tcx . sess . has_errors ( ) {
1556
- return ;
1542
+ match arg. unpack ( ) {
1543
+ GenericArgKind :: Lifetime ( lt) => {
1544
+ span_bug ! ( span, "unexpected well formed predicate: {:?}" , lt)
1545
+ }
1546
+ GenericArgKind :: Type ( ty) => {
1547
+ self . need_type_info_err ( body_id, span, ty, ErrorCode :: E0282 )
1548
+ }
1549
+ GenericArgKind :: Const ( ct) => {
1550
+ self . need_type_info_err_const ( body_id, span, ct, ErrorCode :: E0282 )
1551
+ }
1557
1552
}
1558
- self . need_type_info_err_const ( body_id, span, ct, ErrorCode :: E0282 )
1559
1553
}
1560
1554
1561
1555
ty:: PredicateKind :: Subtype ( ref data) => {
0 commit comments