@@ -46,7 +46,6 @@ use crate::{errors, fluent_generated as fluent};
46
46
47
47
pub ( super ) struct WfCheckingCtxt < ' a , ' tcx > {
48
48
pub ( super ) ocx : ObligationCtxt < ' a , ' tcx , FulfillmentError < ' tcx > > ,
49
- span : Span ,
50
49
body_def_id : LocalDefId ,
51
50
param_env : ty:: ParamEnv < ' tcx > ,
52
51
}
@@ -122,7 +121,6 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
122
121
123
122
pub ( super ) fn enter_wf_checking_ctxt < ' tcx , F > (
124
123
tcx : TyCtxt < ' tcx > ,
125
- span : Span ,
126
124
body_def_id : LocalDefId ,
127
125
f : F ,
128
126
) -> Result < ( ) , ErrorGuaranteed >
@@ -133,7 +131,7 @@ where
133
131
let infcx = & tcx. infer_ctxt ( ) . build ( TypingMode :: non_body_analysis ( ) ) ;
134
132
let ocx = ObligationCtxt :: new_with_diagnostics ( infcx) ;
135
133
136
- let mut wfcx = WfCheckingCtxt { ocx, span , body_def_id, param_env } ;
134
+ let mut wfcx = WfCheckingCtxt { ocx, body_def_id, param_env } ;
137
135
138
136
if !tcx. features ( ) . trivial_bounds ( ) {
139
137
wfcx. check_false_global_bounds ( )
@@ -295,9 +293,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
295
293
}
296
294
res
297
295
}
298
- hir:: ItemKind :: Fn { ident, sig, .. } => {
299
- check_item_fn ( tcx, def_id, ident, item. span , sig. decl )
300
- }
296
+ hir:: ItemKind :: Fn { ident, sig, .. } => check_item_fn ( tcx, def_id, ident, sig. decl ) ,
301
297
hir:: ItemKind :: Static ( _, _, ty, _) => {
302
298
check_static_item ( tcx, def_id, ty. span , UnsizedHandling :: Forbid )
303
299
}
@@ -322,7 +318,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
322
318
// `ForeignItem`s are handled separately.
323
319
hir:: ItemKind :: ForeignMod { .. } => Ok ( ( ) ) ,
324
320
hir:: ItemKind :: TyAlias ( _, generics, hir_ty) if tcx. type_alias_is_lazy ( item. owner_id ) => {
325
- let res = enter_wf_checking_ctxt ( tcx, item . span , def_id, |wfcx| {
321
+ let res = enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
326
322
let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
327
323
let item_ty =
328
324
wfcx. deeply_normalize ( hir_ty. span , Some ( WellFormedLoc :: Ty ( def_id) ) , ty) ;
@@ -357,9 +353,7 @@ fn check_foreign_item<'tcx>(
357
353
) ;
358
354
359
355
match item. kind {
360
- hir:: ForeignItemKind :: Fn ( sig, ..) => {
361
- check_item_fn ( tcx, def_id, item. ident , item. span , sig. decl )
362
- }
356
+ hir:: ForeignItemKind :: Fn ( sig, ..) => check_item_fn ( tcx, def_id, item. ident , sig. decl ) ,
363
357
hir:: ForeignItemKind :: Static ( ty, ..) => {
364
358
check_static_item ( tcx, def_id, ty. span , UnsizedHandling :: AllowIfForeignTail )
365
359
}
@@ -897,7 +891,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
897
891
let ty = tcx. type_of ( param. def_id ) . instantiate_identity ( ) ;
898
892
899
893
if tcx. features ( ) . unsized_const_params ( ) {
900
- enter_wf_checking_ctxt ( tcx, hir_ty . span , tcx. local_parent ( param. def_id ) , |wfcx| {
894
+ enter_wf_checking_ctxt ( tcx, tcx. local_parent ( param. def_id ) , |wfcx| {
901
895
wfcx. register_bound (
902
896
ObligationCause :: new (
903
897
hir_ty. span ,
@@ -911,7 +905,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
911
905
Ok ( ( ) )
912
906
} )
913
907
} else if tcx. features ( ) . adt_const_params ( ) {
914
- enter_wf_checking_ctxt ( tcx, hir_ty . span , tcx. local_parent ( param. def_id ) , |wfcx| {
908
+ enter_wf_checking_ctxt ( tcx, tcx. local_parent ( param. def_id ) , |wfcx| {
915
909
wfcx. register_bound (
916
910
ObligationCause :: new (
917
911
hir_ty. span ,
@@ -1018,7 +1012,7 @@ fn check_associated_item(
1018
1012
sig_if_method : Option < & hir:: FnSig < ' _ > > ,
1019
1013
) -> Result < ( ) , ErrorGuaranteed > {
1020
1014
let loc = Some ( WellFormedLoc :: Ty ( item_id) ) ;
1021
- enter_wf_checking_ctxt ( tcx, span , item_id, |wfcx| {
1015
+ enter_wf_checking_ctxt ( tcx, item_id, |wfcx| {
1022
1016
let item = tcx. associated_item ( item_id) ;
1023
1017
1024
1018
// Avoid bogus "type annotations needed `Foo: Bar`" errors on `impl Bar for Foo` in case
@@ -1083,7 +1077,7 @@ fn check_type_defn<'tcx>(
1083
1077
let _ = tcx. representability ( item. owner_id . def_id ) ;
1084
1078
let adt_def = tcx. adt_def ( item. owner_id ) ;
1085
1079
1086
- enter_wf_checking_ctxt ( tcx, item. span , item . owner_id . def_id , |wfcx| {
1080
+ enter_wf_checking_ctxt ( tcx, item. owner_id . def_id , |wfcx| {
1087
1081
let variants = adt_def. variants ( ) ;
1088
1082
let packed = adt_def. repr ( ) . packed ( ) ;
1089
1083
@@ -1215,7 +1209,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) -> Result<(), ErrorGuarant
1215
1209
}
1216
1210
}
1217
1211
1218
- let res = enter_wf_checking_ctxt ( tcx, item . span , def_id, |wfcx| {
1212
+ let res = enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
1219
1213
check_where_clauses ( wfcx, item. span , def_id) ;
1220
1214
Ok ( ( ) )
1221
1215
} ) ;
@@ -1253,10 +1247,9 @@ fn check_item_fn(
1253
1247
tcx : TyCtxt < ' _ > ,
1254
1248
def_id : LocalDefId ,
1255
1249
ident : Ident ,
1256
- span : Span ,
1257
1250
decl : & hir:: FnDecl < ' _ > ,
1258
1251
) -> Result < ( ) , ErrorGuaranteed > {
1259
- enter_wf_checking_ctxt ( tcx, span , def_id, |wfcx| {
1252
+ enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
1260
1253
let sig = tcx. fn_sig ( def_id) . instantiate_identity ( ) ;
1261
1254
check_fn_or_method ( wfcx, ident. span , sig, decl, def_id) ;
1262
1255
Ok ( ( ) )
@@ -1275,7 +1268,7 @@ fn check_static_item(
1275
1268
ty_span : Span ,
1276
1269
unsized_handling : UnsizedHandling ,
1277
1270
) -> Result < ( ) , ErrorGuaranteed > {
1278
- enter_wf_checking_ctxt ( tcx, ty_span , item_id, |wfcx| {
1271
+ enter_wf_checking_ctxt ( tcx, item_id, |wfcx| {
1279
1272
let ty = tcx. type_of ( item_id) . instantiate_identity ( ) ;
1280
1273
let item_ty = wfcx. deeply_normalize ( ty_span, Some ( WellFormedLoc :: Ty ( item_id) ) , ty) ;
1281
1274
@@ -1330,7 +1323,7 @@ fn check_const_item(
1330
1323
ty_span : Span ,
1331
1324
item_span : Span ,
1332
1325
) -> Result < ( ) , ErrorGuaranteed > {
1333
- enter_wf_checking_ctxt ( tcx, ty_span , def_id, |wfcx| {
1326
+ enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
1334
1327
let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
1335
1328
let ty = wfcx. deeply_normalize ( ty_span, Some ( WellFormedLoc :: Ty ( def_id) ) , ty) ;
1336
1329
@@ -1359,7 +1352,7 @@ fn check_impl<'tcx>(
1359
1352
hir_self_ty : & hir:: Ty < ' _ > ,
1360
1353
hir_trait_ref : & Option < hir:: TraitRef < ' _ > > ,
1361
1354
) -> Result < ( ) , ErrorGuaranteed > {
1362
- enter_wf_checking_ctxt ( tcx, item. span , item . owner_id . def_id , |wfcx| {
1355
+ enter_wf_checking_ctxt ( tcx, item. owner_id . def_id , |wfcx| {
1363
1356
match hir_trait_ref {
1364
1357
Some ( hir_trait_ref) => {
1365
1358
// `#[rustc_reservation_impl]` impls are not real impls and
@@ -2301,7 +2294,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
2301
2294
#[ instrument( level = "debug" , skip( self ) ) ]
2302
2295
fn check_false_global_bounds ( & mut self ) {
2303
2296
let tcx = self . ocx . infcx . tcx ;
2304
- let mut span = self . span ;
2297
+ let mut span = tcx . def_span ( self . body_def_id ) ;
2305
2298
let empty_env = ty:: ParamEnv :: empty ( ) ;
2306
2299
2307
2300
let predicates_with_span = tcx. predicates_of ( self . body_def_id ) . predicates . iter ( ) . copied ( ) ;
0 commit comments