@@ -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:: {
@@ -290,8 +290,8 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
290
290
}
291
291
res
292
292
}
293
- hir:: ItemKind :: Fn { ident , sig, .. } => check_item_fn ( tcx, def_id, ident , sig. decl ) ,
294
- hir:: ItemKind :: Const ( _, _, ty, _) => check_const_item ( tcx, def_id, ty. span , item . span ) ,
293
+ hir:: ItemKind :: Fn { sig, .. } => check_item_fn ( tcx, def_id, sig. decl ) ,
294
+ hir:: ItemKind :: Const ( _, _, ty, _) => check_const_item ( tcx, def_id, ty. span ) ,
295
295
hir:: ItemKind :: Struct ( ..) => check_type_defn ( tcx, item, false ) ,
296
296
hir:: ItemKind :: Union ( ..) => check_type_defn ( tcx, item, true ) ,
297
297
hir:: ItemKind :: Enum ( ..) => check_type_defn ( tcx, item, true ) ,
@@ -307,7 +307,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
307
307
Some ( WellFormedLoc :: Ty ( def_id) ) ,
308
308
item_ty. into ( ) ,
309
309
) ;
310
- check_where_clauses ( wfcx, item . span , def_id) ;
310
+ check_where_clauses ( wfcx, def_id) ;
311
311
Ok ( ( ) )
312
312
} )
313
313
}
@@ -327,7 +327,7 @@ fn check_foreign_item<'tcx>(
327
327
) ;
328
328
329
329
match item. kind {
330
- hir:: ForeignItemKind :: Fn ( sig, ..) => check_item_fn ( tcx, def_id, item . ident , sig. decl ) ,
330
+ hir:: ForeignItemKind :: Fn ( sig, ..) => check_item_fn ( tcx, def_id, sig. decl ) ,
331
331
hir:: ForeignItemKind :: Static ( ..) | hir:: ForeignItemKind :: Type => Ok ( ( ) ) ,
332
332
}
333
333
}
@@ -1017,13 +1017,7 @@ fn check_associated_item(
1017
1017
ty:: AssocKind :: Fn { .. } => {
1018
1018
let sig = tcx. fn_sig ( item. def_id ) . instantiate_identity ( ) ;
1019
1019
let hir_sig = sig_if_method. expect ( "bad signature for method" ) ;
1020
- check_fn_or_method (
1021
- wfcx,
1022
- item. ident ( tcx) . span ,
1023
- sig,
1024
- hir_sig. decl ,
1025
- item. def_id . expect_local ( ) ,
1026
- ) ;
1020
+ check_fn_or_method ( wfcx, sig, hir_sig. decl , item. def_id . expect_local ( ) ) ;
1027
1021
check_method_receiver ( wfcx, hir_sig, item, self_ty)
1028
1022
}
1029
1023
ty:: AssocKind :: Type { .. } => {
@@ -1152,7 +1146,7 @@ fn check_type_defn<'tcx>(
1152
1146
}
1153
1147
}
1154
1148
1155
- check_where_clauses ( wfcx, item. span , item . owner_id . def_id ) ;
1149
+ check_where_clauses ( wfcx, item. owner_id . def_id ) ;
1156
1150
Ok ( ( ) )
1157
1151
} )
1158
1152
}
@@ -1183,7 +1177,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) -> Result<(), ErrorGuarant
1183
1177
}
1184
1178
1185
1179
let res = enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
1186
- check_where_clauses ( wfcx, item . span , def_id) ;
1180
+ check_where_clauses ( wfcx, def_id) ;
1187
1181
Ok ( ( ) )
1188
1182
} ) ;
1189
1183
@@ -1219,12 +1213,11 @@ fn check_associated_type_bounds(wfcx: &WfCheckingCtxt<'_, '_>, item: ty::AssocIt
1219
1213
fn check_item_fn (
1220
1214
tcx : TyCtxt < ' _ > ,
1221
1215
def_id : LocalDefId ,
1222
- ident : Ident ,
1223
1216
decl : & hir:: FnDecl < ' _ > ,
1224
1217
) -> Result < ( ) , ErrorGuaranteed > {
1225
1218
enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
1226
1219
let sig = tcx. fn_sig ( def_id) . instantiate_identity ( ) ;
1227
- check_fn_or_method ( wfcx, ident . span , sig, decl, def_id) ;
1220
+ check_fn_or_method ( wfcx, sig, decl, def_id) ;
1228
1221
Ok ( ( ) )
1229
1222
} )
1230
1223
}
@@ -1287,7 +1280,6 @@ fn check_const_item(
1287
1280
tcx : TyCtxt < ' _ > ,
1288
1281
def_id : LocalDefId ,
1289
1282
ty_span : Span ,
1290
- item_span : Span ,
1291
1283
) -> Result < ( ) , ErrorGuaranteed > {
1292
1284
enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
1293
1285
let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
@@ -1305,7 +1297,7 @@ fn check_const_item(
1305
1297
tcx. require_lang_item ( LangItem :: Sized , ty_span) ,
1306
1298
) ;
1307
1299
1308
- check_where_clauses ( wfcx, item_span , def_id) ;
1300
+ check_where_clauses ( wfcx, def_id) ;
1309
1301
1310
1302
Ok ( ( ) )
1311
1303
} )
@@ -1402,14 +1394,14 @@ fn check_impl<'tcx>(
1402
1394
}
1403
1395
}
1404
1396
1405
- check_where_clauses ( wfcx, item. span , item . owner_id . def_id ) ;
1397
+ check_where_clauses ( wfcx, item. owner_id . def_id ) ;
1406
1398
Ok ( ( ) )
1407
1399
} )
1408
1400
}
1409
1401
1410
1402
/// Checks where-clauses and inline bounds that are declared on `def_id`.
1411
1403
#[ instrument( level = "debug" , skip( wfcx) ) ]
1412
- fn check_where_clauses < ' tcx > ( wfcx : & WfCheckingCtxt < ' _ , ' tcx > , span : Span , def_id : LocalDefId ) {
1404
+ pub ( super ) fn check_where_clauses < ' tcx > ( wfcx : & WfCheckingCtxt < ' _ , ' tcx > , def_id : LocalDefId ) {
1413
1405
let infcx = wfcx. infcx ;
1414
1406
let tcx = wfcx. tcx ( ) ;
1415
1407
@@ -1564,21 +1556,18 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
1564
1556
1565
1557
let predicates = predicates. instantiate_identity ( tcx) ;
1566
1558
1567
- let predicates = wfcx. normalize ( span, None , predicates) ;
1568
-
1569
- debug ! ( ?predicates. predicates) ;
1570
1559
assert_eq ! ( predicates. predicates. len( ) , predicates. spans. len( ) ) ;
1571
1560
let wf_obligations = predicates. into_iter ( ) . flat_map ( |( p, sp) | {
1561
+ let p = wfcx. normalize ( sp, None , p) ;
1572
1562
traits:: wf:: clause_obligations ( infcx, wfcx. param_env , wfcx. body_def_id , p, sp)
1573
1563
} ) ;
1574
1564
let obligations: Vec < _ > = wf_obligations. chain ( default_obligations) . collect ( ) ;
1575
1565
wfcx. register_obligations ( obligations) ;
1576
1566
}
1577
1567
1578
- #[ instrument( level = "debug" , skip( wfcx, span , hir_decl) ) ]
1568
+ #[ instrument( level = "debug" , skip( wfcx, hir_decl) ) ]
1579
1569
fn check_fn_or_method < ' tcx > (
1580
1570
wfcx : & WfCheckingCtxt < ' _ , ' tcx > ,
1581
- span : Span ,
1582
1571
sig : ty:: PolyFnSig < ' tcx > ,
1583
1572
hir_decl : & hir:: FnDecl < ' _ > ,
1584
1573
def_id : LocalDefId ,
@@ -1616,7 +1605,7 @@ fn check_fn_or_method<'tcx>(
1616
1605
) ;
1617
1606
}
1618
1607
1619
- check_where_clauses ( wfcx, span , def_id) ;
1608
+ check_where_clauses ( wfcx, def_id) ;
1620
1609
1621
1610
if sig. abi == ExternAbi :: RustCall {
1622
1611
let span = tcx. def_span ( def_id) ;
0 commit comments