@@ -25,7 +25,7 @@ use rustc_middle::ty::{
25
25
} ;
26
26
use rustc_middle:: { bug, span_bug} ;
27
27
use rustc_session:: parse:: feature_err;
28
- use rustc_span:: { DUMMY_SP , Ident , Span , sym} ;
28
+ use rustc_span:: { DUMMY_SP , Span , sym} ;
29
29
use rustc_trait_selection:: error_reporting:: InferCtxtErrorExt ;
30
30
use rustc_trait_selection:: regions:: { InferCtxtRegionExt , OutlivesEnvironmentBuildExt } ;
31
31
use rustc_trait_selection:: traits:: misc:: {
@@ -291,8 +291,8 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
291
291
}
292
292
res
293
293
}
294
- hir:: ItemKind :: Fn { ident , sig, .. } => check_item_fn ( tcx, def_id, ident , sig. decl ) ,
295
- hir:: ItemKind :: Const ( _, _, ty, _) => check_const_item ( tcx, def_id, ty. span , item . span ) ,
294
+ hir:: ItemKind :: Fn { sig, .. } => check_item_fn ( tcx, def_id, sig. decl ) ,
295
+ hir:: ItemKind :: Const ( _, _, ty, _) => check_const_item ( tcx, def_id, ty. span ) ,
296
296
hir:: ItemKind :: Struct ( ..) => check_type_defn ( tcx, item, false ) ,
297
297
hir:: ItemKind :: Union ( ..) => check_type_defn ( tcx, item, true ) ,
298
298
hir:: ItemKind :: Enum ( ..) => check_type_defn ( tcx, item, true ) ,
@@ -308,7 +308,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
308
308
Some ( WellFormedLoc :: Ty ( def_id) ) ,
309
309
item_ty. into ( ) ,
310
310
) ;
311
- check_where_clauses ( wfcx, item . span , def_id) ;
311
+ check_where_clauses ( wfcx, def_id) ;
312
312
Ok ( ( ) )
313
313
} )
314
314
}
@@ -330,7 +330,7 @@ fn check_foreign_item<'tcx>(
330
330
) ;
331
331
332
332
match item. kind {
333
- hir:: ForeignItemKind :: Fn ( sig, ..) => check_item_fn ( tcx, def_id, item . ident , sig. decl ) ,
333
+ hir:: ForeignItemKind :: Fn ( sig, ..) => check_item_fn ( tcx, def_id, sig. decl ) ,
334
334
hir:: ForeignItemKind :: Static ( ..) | hir:: ForeignItemKind :: Type => Ok ( ( ) ) ,
335
335
}
336
336
}
@@ -1086,13 +1086,7 @@ fn check_associated_item(
1086
1086
ty:: AssocKind :: Fn { .. } => {
1087
1087
let sig = tcx. fn_sig ( item. def_id ) . instantiate_identity ( ) ;
1088
1088
let hir_sig = sig_if_method. expect ( "bad signature for method" ) ;
1089
- check_fn_or_method (
1090
- wfcx,
1091
- item. ident ( tcx) . span ,
1092
- sig,
1093
- hir_sig. decl ,
1094
- item. def_id . expect_local ( ) ,
1095
- ) ;
1089
+ check_fn_or_method ( wfcx, sig, hir_sig. decl , item. def_id . expect_local ( ) ) ;
1096
1090
check_method_receiver ( wfcx, hir_sig, item, self_ty)
1097
1091
}
1098
1092
ty:: AssocKind :: Type { .. } => {
@@ -1221,7 +1215,7 @@ fn check_type_defn<'tcx>(
1221
1215
}
1222
1216
}
1223
1217
1224
- check_where_clauses ( wfcx, item. span , item . owner_id . def_id ) ;
1218
+ check_where_clauses ( wfcx, item. owner_id . def_id ) ;
1225
1219
Ok ( ( ) )
1226
1220
} )
1227
1221
}
@@ -1247,7 +1241,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) -> Result<(), ErrorGuarant
1247
1241
}
1248
1242
1249
1243
let res = enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
1250
- check_where_clauses ( wfcx, item . span , def_id) ;
1244
+ check_where_clauses ( wfcx, def_id) ;
1251
1245
Ok ( ( ) )
1252
1246
} ) ;
1253
1247
@@ -1283,12 +1277,11 @@ fn check_associated_type_bounds(wfcx: &WfCheckingCtxt<'_, '_>, item: ty::AssocIt
1283
1277
fn check_item_fn (
1284
1278
tcx : TyCtxt < ' _ > ,
1285
1279
def_id : LocalDefId ,
1286
- ident : Ident ,
1287
1280
decl : & hir:: FnDecl < ' _ > ,
1288
1281
) -> Result < ( ) , ErrorGuaranteed > {
1289
1282
enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
1290
1283
let sig = tcx. fn_sig ( def_id) . instantiate_identity ( ) ;
1291
- check_fn_or_method ( wfcx, ident . span , sig, decl, def_id) ;
1284
+ check_fn_or_method ( wfcx, sig, decl, def_id) ;
1292
1285
Ok ( ( ) )
1293
1286
} )
1294
1287
}
@@ -1349,7 +1342,6 @@ fn check_const_item(
1349
1342
tcx : TyCtxt < ' _ > ,
1350
1343
def_id : LocalDefId ,
1351
1344
ty_span : Span ,
1352
- item_span : Span ,
1353
1345
) -> Result < ( ) , ErrorGuaranteed > {
1354
1346
enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
1355
1347
let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
@@ -1367,7 +1359,7 @@ fn check_const_item(
1367
1359
tcx. require_lang_item ( LangItem :: Sized , None ) ,
1368
1360
) ;
1369
1361
1370
- check_where_clauses ( wfcx, item_span , def_id) ;
1362
+ check_where_clauses ( wfcx, def_id) ;
1371
1363
1372
1364
Ok ( ( ) )
1373
1365
} )
@@ -1464,14 +1456,14 @@ fn check_impl<'tcx>(
1464
1456
}
1465
1457
}
1466
1458
1467
- check_where_clauses ( wfcx, item. span , item . owner_id . def_id ) ;
1459
+ check_where_clauses ( wfcx, item. owner_id . def_id ) ;
1468
1460
Ok ( ( ) )
1469
1461
} )
1470
1462
}
1471
1463
1472
1464
/// Checks where-clauses and inline bounds that are declared on `def_id`.
1473
1465
#[ instrument( level = "debug" , skip( wfcx) ) ]
1474
- fn check_where_clauses < ' tcx > ( wfcx : & WfCheckingCtxt < ' _ , ' tcx > , span : Span , def_id : LocalDefId ) {
1466
+ pub ( super ) fn check_where_clauses < ' tcx > ( wfcx : & WfCheckingCtxt < ' _ , ' tcx > , def_id : LocalDefId ) {
1475
1467
let infcx = wfcx. infcx ;
1476
1468
let tcx = wfcx. tcx ( ) ;
1477
1469
@@ -1624,21 +1616,18 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
1624
1616
1625
1617
let predicates = predicates. instantiate_identity ( tcx) ;
1626
1618
1627
- let predicates = wfcx. normalize ( span, None , predicates) ;
1628
-
1629
- debug ! ( ?predicates. predicates) ;
1630
1619
assert_eq ! ( predicates. predicates. len( ) , predicates. spans. len( ) ) ;
1631
1620
let wf_obligations = predicates. into_iter ( ) . flat_map ( |( p, sp) | {
1621
+ let p = wfcx. normalize ( sp, None , p) ;
1632
1622
traits:: wf:: clause_obligations ( infcx, wfcx. param_env , wfcx. body_def_id , p, sp)
1633
1623
} ) ;
1634
1624
let obligations: Vec < _ > = wf_obligations. chain ( default_obligations) . collect ( ) ;
1635
1625
wfcx. register_obligations ( obligations) ;
1636
1626
}
1637
1627
1638
- #[ instrument( level = "debug" , skip( wfcx, span , hir_decl) ) ]
1628
+ #[ instrument( level = "debug" , skip( wfcx, hir_decl) ) ]
1639
1629
fn check_fn_or_method < ' tcx > (
1640
1630
wfcx : & WfCheckingCtxt < ' _ , ' tcx > ,
1641
- span : Span ,
1642
1631
sig : ty:: PolyFnSig < ' tcx > ,
1643
1632
hir_decl : & hir:: FnDecl < ' _ > ,
1644
1633
def_id : LocalDefId ,
@@ -1676,7 +1665,7 @@ fn check_fn_or_method<'tcx>(
1676
1665
) ;
1677
1666
}
1678
1667
1679
- check_where_clauses ( wfcx, span , def_id) ;
1668
+ check_where_clauses ( wfcx, def_id) ;
1680
1669
1681
1670
if sig. abi == ExternAbi :: RustCall {
1682
1671
let span = tcx. def_span ( def_id) ;
0 commit comments