@@ -66,15 +66,11 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
66
66
span : Span ,
67
67
loc : Option < WellFormedLoc > ,
68
68
arg : ty:: GenericArg < ' tcx > ,
69
- override_constness : Option < hir:: Constness > ,
70
69
) {
71
70
let cause =
72
71
traits:: ObligationCause :: new ( span, self . body_id , ObligationCauseCode :: WellFormed ( loc) ) ;
73
- let param_env = if let Some ( constness) = override_constness {
74
- self . param_env . with_constness ( constness)
75
- } else {
76
- self . param_env
77
- } ;
72
+ // for a type to be WF, we do not need to check if const trait predicates satisfy.
73
+ let param_env = self . param_env . without_const ( ) ;
78
74
self . ocx . register_obligation ( traits:: Obligation :: new (
79
75
cause,
80
76
param_env,
@@ -991,7 +987,7 @@ fn check_associated_item(
991
987
ty:: AssocKind :: Const => {
992
988
let ty = tcx. type_of ( item. def_id ) ;
993
989
let ty = wfcx. normalize ( span, Some ( WellFormedLoc :: Ty ( item_id) ) , ty) ;
994
- wfcx. register_wf_obligation ( span, loc, ty. into ( ) , None ) ;
990
+ wfcx. register_wf_obligation ( span, loc, ty. into ( ) ) ;
995
991
}
996
992
ty:: AssocKind :: Fn => {
997
993
let sig = tcx. fn_sig ( item. def_id ) ;
@@ -1012,7 +1008,7 @@ fn check_associated_item(
1012
1008
if item. defaultness ( tcx) . has_value ( ) {
1013
1009
let ty = tcx. type_of ( item. def_id ) ;
1014
1010
let ty = wfcx. normalize ( span, Some ( WellFormedLoc :: Ty ( item_id) ) , ty) ;
1015
- wfcx. register_wf_obligation ( span, loc, ty. into ( ) , None ) ;
1011
+ wfcx. register_wf_obligation ( span, loc, ty. into ( ) ) ;
1016
1012
}
1017
1013
}
1018
1014
}
@@ -1048,7 +1044,6 @@ fn check_type_defn<'tcx, F>(
1048
1044
field. span ,
1049
1045
Some ( WellFormedLoc :: Ty ( field. def_id ) ) ,
1050
1046
field. ty . into ( ) ,
1051
- None ,
1052
1047
)
1053
1048
}
1054
1049
@@ -1202,7 +1197,6 @@ fn check_item_type(tcx: TyCtxt<'_>, item_id: LocalDefId, ty_span: Span, allow_fo
1202
1197
ty_span,
1203
1198
Some ( WellFormedLoc :: Ty ( item_id) ) ,
1204
1199
item_ty. into ( ) ,
1205
- None ,
1206
1200
) ;
1207
1201
if forbid_unsized {
1208
1202
wfcx. register_bound (
@@ -1272,7 +1266,6 @@ fn check_impl<'tcx>(
1272
1266
ast_self_ty. span ,
1273
1267
Some ( WellFormedLoc :: Ty ( item. hir_id ( ) . expect_owner ( ) ) ) ,
1274
1268
self_ty. into ( ) ,
1275
- None ,
1276
1269
) ;
1277
1270
}
1278
1271
}
@@ -1317,7 +1310,6 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
1317
1310
tcx. def_span ( param. def_id ) ,
1318
1311
None ,
1319
1312
ty. into ( ) ,
1320
- None ,
1321
1313
) ;
1322
1314
}
1323
1315
}
@@ -1334,7 +1326,6 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
1334
1326
tcx. def_span ( param. def_id ) ,
1335
1327
None ,
1336
1328
default_ct. into ( ) ,
1337
- None ,
1338
1329
) ;
1339
1330
}
1340
1331
}
@@ -1463,7 +1454,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
1463
1454
assert_eq ! ( predicates. predicates. len( ) , predicates. spans. len( ) ) ;
1464
1455
let wf_obligations =
1465
1456
iter:: zip ( & predicates. predicates , & predicates. spans ) . flat_map ( |( & p, & sp) | {
1466
- traits:: wf:: predicate_obligations ( infcx, wfcx. param_env , wfcx. body_id , p, sp)
1457
+ traits:: wf:: predicate_obligations ( infcx, wfcx. param_env . without_const ( ) , wfcx. body_id , p, sp)
1467
1458
} ) ;
1468
1459
1469
1460
let obligations: Vec < _ > = wf_obligations. chain ( default_obligations) . collect ( ) ;
@@ -1515,15 +1506,13 @@ fn check_fn_or_method<'tcx>(
1515
1506
ty. span ,
1516
1507
Some ( WellFormedLoc :: Param { function : def_id, param_idx : i. try_into ( ) . unwrap ( ) } ) ,
1517
1508
input_ty. into ( ) ,
1518
- None ,
1519
1509
) ;
1520
1510
}
1521
1511
1522
1512
wfcx. register_wf_obligation (
1523
1513
hir_decl. output . span ( ) ,
1524
1514
None ,
1525
1515
sig. output ( ) . into ( ) ,
1526
- Some ( hir:: Constness :: NotConst ) ,
1527
1516
) ;
1528
1517
1529
1518
check_where_clauses ( wfcx, span, def_id) ;
0 commit comments