@@ -47,7 +47,6 @@ use crate::{errors, fluent_generated as fluent};
47
47
48
48
pub ( super ) struct WfCheckingCtxt < ' a , ' tcx > {
49
49
pub ( super ) ocx : ObligationCtxt < ' a , ' tcx , FulfillmentError < ' tcx > > ,
50
- span : Span ,
51
50
body_def_id : LocalDefId ,
52
51
param_env : ty:: ParamEnv < ' tcx > ,
53
52
}
@@ -123,7 +122,6 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
123
122
124
123
pub ( super ) fn enter_wf_checking_ctxt < ' tcx , F > (
125
124
tcx : TyCtxt < ' tcx > ,
126
- span : Span ,
127
125
body_def_id : LocalDefId ,
128
126
f : F ,
129
127
) -> Result < ( ) , ErrorGuaranteed >
@@ -134,7 +132,7 @@ where
134
132
let infcx = & tcx. infer_ctxt ( ) . build ( TypingMode :: non_body_analysis ( ) ) ;
135
133
let ocx = ObligationCtxt :: new_with_diagnostics ( infcx) ;
136
134
137
- let mut wfcx = WfCheckingCtxt { ocx, span , body_def_id, param_env } ;
135
+ let mut wfcx = WfCheckingCtxt { ocx, body_def_id, param_env } ;
138
136
139
137
if !tcx. features ( ) . trivial_bounds ( ) {
140
138
wfcx. check_false_global_bounds ( )
@@ -294,9 +292,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
294
292
}
295
293
res
296
294
}
297
- hir:: ItemKind :: Fn { ident, sig, .. } => {
298
- check_item_fn ( tcx, def_id, ident, item. span , sig. decl )
299
- }
295
+ hir:: ItemKind :: Fn { ident, sig, .. } => check_item_fn ( tcx, def_id, ident, sig. decl ) ,
300
296
hir:: ItemKind :: Static ( _, _, ty, _) => {
301
297
check_static_item ( tcx, def_id, ty. span , UnsizedHandling :: Forbid )
302
298
}
@@ -321,7 +317,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
321
317
// `ForeignItem`s are handled separately.
322
318
hir:: ItemKind :: ForeignMod { .. } => Ok ( ( ) ) ,
323
319
hir:: ItemKind :: TyAlias ( _, generics, hir_ty) if tcx. type_alias_is_lazy ( item. owner_id ) => {
324
- let res = enter_wf_checking_ctxt ( tcx, item . span , def_id, |wfcx| {
320
+ let res = enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
325
321
let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
326
322
let item_ty =
327
323
wfcx. deeply_normalize ( hir_ty. span , Some ( WellFormedLoc :: Ty ( def_id) ) , ty) ;
@@ -358,9 +354,7 @@ fn check_foreign_item<'tcx>(
358
354
) ;
359
355
360
356
match item. kind {
361
- hir:: ForeignItemKind :: Fn ( sig, ..) => {
362
- check_item_fn ( tcx, def_id, item. ident , item. span , sig. decl )
363
- }
357
+ hir:: ForeignItemKind :: Fn ( sig, ..) => check_item_fn ( tcx, def_id, item. ident , sig. decl ) ,
364
358
hir:: ForeignItemKind :: Static ( ty, ..) => {
365
359
check_static_item ( tcx, def_id, ty. span , UnsizedHandling :: AllowIfForeignTail )
366
360
}
@@ -960,7 +954,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
960
954
let ty = tcx. type_of ( param. def_id ) . instantiate_identity ( ) ;
961
955
962
956
if tcx. features ( ) . unsized_const_params ( ) {
963
- enter_wf_checking_ctxt ( tcx, hir_ty . span , tcx. local_parent ( param. def_id ) , |wfcx| {
957
+ enter_wf_checking_ctxt ( tcx, tcx. local_parent ( param. def_id ) , |wfcx| {
964
958
wfcx. register_bound (
965
959
ObligationCause :: new (
966
960
hir_ty. span ,
@@ -974,7 +968,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
974
968
Ok ( ( ) )
975
969
} )
976
970
} else if tcx. features ( ) . adt_const_params ( ) {
977
- enter_wf_checking_ctxt ( tcx, hir_ty . span , tcx. local_parent ( param. def_id ) , |wfcx| {
971
+ enter_wf_checking_ctxt ( tcx, tcx. local_parent ( param. def_id ) , |wfcx| {
978
972
wfcx. register_bound (
979
973
ObligationCause :: new (
980
974
hir_ty. span ,
@@ -1081,7 +1075,7 @@ fn check_associated_item(
1081
1075
sig_if_method : Option < & hir:: FnSig < ' _ > > ,
1082
1076
) -> Result < ( ) , ErrorGuaranteed > {
1083
1077
let loc = Some ( WellFormedLoc :: Ty ( item_id) ) ;
1084
- enter_wf_checking_ctxt ( tcx, span , item_id, |wfcx| {
1078
+ enter_wf_checking_ctxt ( tcx, item_id, |wfcx| {
1085
1079
let item = tcx. associated_item ( item_id) ;
1086
1080
1087
1081
// Avoid bogus "type annotations needed `Foo: Bar`" errors on `impl Bar for Foo` in case
@@ -1146,7 +1140,7 @@ fn check_type_defn<'tcx>(
1146
1140
let _ = tcx. representability ( item. owner_id . def_id ) ;
1147
1141
let adt_def = tcx. adt_def ( item. owner_id ) ;
1148
1142
1149
- enter_wf_checking_ctxt ( tcx, item. span , item . owner_id . def_id , |wfcx| {
1143
+ enter_wf_checking_ctxt ( tcx, item. owner_id . def_id , |wfcx| {
1150
1144
let variants = adt_def. variants ( ) ;
1151
1145
let packed = adt_def. repr ( ) . packed ( ) ;
1152
1146
@@ -1273,7 +1267,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) -> Result<(), ErrorGuarant
1273
1267
}
1274
1268
}
1275
1269
1276
- let res = enter_wf_checking_ctxt ( tcx, item . span , def_id, |wfcx| {
1270
+ let res = enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
1277
1271
check_where_clauses ( wfcx, item. span , def_id) ;
1278
1272
Ok ( ( ) )
1279
1273
} ) ;
@@ -1311,10 +1305,9 @@ fn check_item_fn(
1311
1305
tcx : TyCtxt < ' _ > ,
1312
1306
def_id : LocalDefId ,
1313
1307
ident : Ident ,
1314
- span : Span ,
1315
1308
decl : & hir:: FnDecl < ' _ > ,
1316
1309
) -> Result < ( ) , ErrorGuaranteed > {
1317
- enter_wf_checking_ctxt ( tcx, span , def_id, |wfcx| {
1310
+ enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
1318
1311
let sig = tcx. fn_sig ( def_id) . instantiate_identity ( ) ;
1319
1312
check_fn_or_method ( wfcx, ident. span , sig, decl, def_id) ;
1320
1313
Ok ( ( ) )
@@ -1333,7 +1326,7 @@ fn check_static_item(
1333
1326
ty_span : Span ,
1334
1327
unsized_handling : UnsizedHandling ,
1335
1328
) -> Result < ( ) , ErrorGuaranteed > {
1336
- enter_wf_checking_ctxt ( tcx, ty_span , item_id, |wfcx| {
1329
+ enter_wf_checking_ctxt ( tcx, item_id, |wfcx| {
1337
1330
let ty = tcx. type_of ( item_id) . instantiate_identity ( ) ;
1338
1331
let item_ty = wfcx. deeply_normalize ( ty_span, Some ( WellFormedLoc :: Ty ( item_id) ) , ty) ;
1339
1332
@@ -1388,7 +1381,7 @@ fn check_const_item(
1388
1381
ty_span : Span ,
1389
1382
item_span : Span ,
1390
1383
) -> Result < ( ) , ErrorGuaranteed > {
1391
- enter_wf_checking_ctxt ( tcx, ty_span , def_id, |wfcx| {
1384
+ enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
1392
1385
let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
1393
1386
let ty = wfcx. deeply_normalize ( ty_span, Some ( WellFormedLoc :: Ty ( def_id) ) , ty) ;
1394
1387
@@ -1417,7 +1410,7 @@ fn check_impl<'tcx>(
1417
1410
hir_self_ty : & hir:: Ty < ' _ > ,
1418
1411
hir_trait_ref : & Option < hir:: TraitRef < ' _ > > ,
1419
1412
) -> Result < ( ) , ErrorGuaranteed > {
1420
- enter_wf_checking_ctxt ( tcx, item. span , item . owner_id . def_id , |wfcx| {
1413
+ enter_wf_checking_ctxt ( tcx, item. owner_id . def_id , |wfcx| {
1421
1414
match hir_trait_ref {
1422
1415
Some ( hir_trait_ref) => {
1423
1416
// `#[rustc_reservation_impl]` impls are not real impls and
@@ -2357,7 +2350,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
2357
2350
#[ instrument( level = "debug" , skip( self ) ) ]
2358
2351
fn check_false_global_bounds ( & mut self ) {
2359
2352
let tcx = self . ocx . infcx . tcx ;
2360
- let mut span = self . span ;
2353
+ let mut span = tcx . def_span ( self . body_def_id ) ;
2361
2354
let empty_env = ty:: ParamEnv :: empty ( ) ;
2362
2355
2363
2356
let predicates_with_span = tcx. predicates_of ( self . body_def_id ) . predicates . iter ( ) . copied ( ) ;
0 commit comments