@@ -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
}
@@ -893,7 +887,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
893
887
let ty = tcx. type_of ( param. def_id ) . instantiate_identity ( ) ;
894
888
895
889
if tcx. features ( ) . unsized_const_params ( ) {
896
- enter_wf_checking_ctxt ( tcx, hir_ty . span , tcx. local_parent ( param. def_id ) , |wfcx| {
890
+ enter_wf_checking_ctxt ( tcx, tcx. local_parent ( param. def_id ) , |wfcx| {
897
891
wfcx. register_bound (
898
892
ObligationCause :: new (
899
893
hir_ty. span ,
@@ -907,7 +901,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
907
901
Ok ( ( ) )
908
902
} )
909
903
} else if tcx. features ( ) . adt_const_params ( ) {
910
- enter_wf_checking_ctxt ( tcx, hir_ty . span , tcx. local_parent ( param. def_id ) , |wfcx| {
904
+ enter_wf_checking_ctxt ( tcx, tcx. local_parent ( param. def_id ) , |wfcx| {
911
905
wfcx. register_bound (
912
906
ObligationCause :: new (
913
907
hir_ty. span ,
@@ -1014,7 +1008,7 @@ fn check_associated_item(
1014
1008
sig_if_method : Option < & hir:: FnSig < ' _ > > ,
1015
1009
) -> Result < ( ) , ErrorGuaranteed > {
1016
1010
let loc = Some ( WellFormedLoc :: Ty ( item_id) ) ;
1017
- enter_wf_checking_ctxt ( tcx, span , item_id, |wfcx| {
1011
+ enter_wf_checking_ctxt ( tcx, item_id, |wfcx| {
1018
1012
let item = tcx. associated_item ( item_id) ;
1019
1013
1020
1014
// Avoid bogus "type annotations needed `Foo: Bar`" errors on `impl Bar for Foo` in case
@@ -1079,7 +1073,7 @@ fn check_type_defn<'tcx>(
1079
1073
let _ = tcx. representability ( item. owner_id . def_id ) ;
1080
1074
let adt_def = tcx. adt_def ( item. owner_id ) ;
1081
1075
1082
- enter_wf_checking_ctxt ( tcx, item. span , item . owner_id . def_id , |wfcx| {
1076
+ enter_wf_checking_ctxt ( tcx, item. owner_id . def_id , |wfcx| {
1083
1077
let variants = adt_def. variants ( ) ;
1084
1078
let packed = adt_def. repr ( ) . packed ( ) ;
1085
1079
@@ -1211,7 +1205,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) -> Result<(), ErrorGuarant
1211
1205
}
1212
1206
}
1213
1207
1214
- let res = enter_wf_checking_ctxt ( tcx, item . span , def_id, |wfcx| {
1208
+ let res = enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
1215
1209
check_where_clauses ( wfcx, item. span , def_id) ;
1216
1210
Ok ( ( ) )
1217
1211
} ) ;
@@ -1249,10 +1243,9 @@ fn check_item_fn(
1249
1243
tcx : TyCtxt < ' _ > ,
1250
1244
def_id : LocalDefId ,
1251
1245
ident : Ident ,
1252
- span : Span ,
1253
1246
decl : & hir:: FnDecl < ' _ > ,
1254
1247
) -> Result < ( ) , ErrorGuaranteed > {
1255
- enter_wf_checking_ctxt ( tcx, span , def_id, |wfcx| {
1248
+ enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
1256
1249
let sig = tcx. fn_sig ( def_id) . instantiate_identity ( ) ;
1257
1250
check_fn_or_method ( wfcx, ident. span , sig, decl, def_id) ;
1258
1251
Ok ( ( ) )
@@ -1271,7 +1264,7 @@ fn check_static_item(
1271
1264
ty_span : Span ,
1272
1265
unsized_handling : UnsizedHandling ,
1273
1266
) -> Result < ( ) , ErrorGuaranteed > {
1274
- enter_wf_checking_ctxt ( tcx, ty_span , item_id, |wfcx| {
1267
+ enter_wf_checking_ctxt ( tcx, item_id, |wfcx| {
1275
1268
let ty = tcx. type_of ( item_id) . instantiate_identity ( ) ;
1276
1269
let item_ty = wfcx. deeply_normalize ( ty_span, Some ( WellFormedLoc :: Ty ( item_id) ) , ty) ;
1277
1270
@@ -1326,7 +1319,7 @@ fn check_const_item(
1326
1319
ty_span : Span ,
1327
1320
item_span : Span ,
1328
1321
) -> Result < ( ) , ErrorGuaranteed > {
1329
- enter_wf_checking_ctxt ( tcx, ty_span , def_id, |wfcx| {
1322
+ enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
1330
1323
let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
1331
1324
let ty = wfcx. deeply_normalize ( ty_span, Some ( WellFormedLoc :: Ty ( def_id) ) , ty) ;
1332
1325
@@ -1355,7 +1348,7 @@ fn check_impl<'tcx>(
1355
1348
hir_self_ty : & hir:: Ty < ' _ > ,
1356
1349
hir_trait_ref : & Option < hir:: TraitRef < ' _ > > ,
1357
1350
) -> Result < ( ) , ErrorGuaranteed > {
1358
- enter_wf_checking_ctxt ( tcx, item. span , item . owner_id . def_id , |wfcx| {
1351
+ enter_wf_checking_ctxt ( tcx, item. owner_id . def_id , |wfcx| {
1359
1352
match hir_trait_ref {
1360
1353
Some ( hir_trait_ref) => {
1361
1354
// `#[rustc_reservation_impl]` impls are not real impls and
@@ -2295,7 +2288,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
2295
2288
#[ instrument( level = "debug" , skip( self ) ) ]
2296
2289
fn check_false_global_bounds ( & mut self ) {
2297
2290
let tcx = self . ocx . infcx . tcx ;
2298
- let mut span = self . span ;
2291
+ let mut span = tcx . def_span ( self . body_def_id ) ;
2299
2292
let empty_env = ty:: ParamEnv :: empty ( ) ;
2300
2293
2301
2294
let predicates_with_span = tcx. predicates_of ( self . body_def_id ) . predicates . iter ( ) . copied ( ) ;
0 commit comments