@@ -47,7 +47,6 @@ use crate::{errors, fluent_generated as fluent};
4747
4848pub ( super ) struct WfCheckingCtxt < ' a , ' tcx > {
4949 pub ( super ) ocx : ObligationCtxt < ' a , ' tcx , FulfillmentError < ' tcx > > ,
50- span : Span ,
5150 body_def_id : LocalDefId ,
5251 param_env : ty:: ParamEnv < ' tcx > ,
5352}
@@ -123,7 +122,6 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
123122
124123pub ( super ) fn enter_wf_checking_ctxt < ' tcx , F > (
125124 tcx : TyCtxt < ' tcx > ,
126- span : Span ,
127125 body_def_id : LocalDefId ,
128126 f : F ,
129127) -> Result < ( ) , ErrorGuaranteed >
@@ -134,7 +132,7 @@ where
134132 let infcx = & tcx. infer_ctxt ( ) . build ( TypingMode :: non_body_analysis ( ) ) ;
135133 let ocx = ObligationCtxt :: new_with_diagnostics ( infcx) ;
136134
137- let mut wfcx = WfCheckingCtxt { ocx, span , body_def_id, param_env } ;
135+ let mut wfcx = WfCheckingCtxt { ocx, body_def_id, param_env } ;
138136
139137 if !tcx. features ( ) . trivial_bounds ( ) {
140138 wfcx. check_false_global_bounds ( )
@@ -294,9 +292,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
294292 }
295293 res
296294 }
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 ) ,
300296 hir:: ItemKind :: Static ( _, _, ty, _) => {
301297 check_static_item ( tcx, def_id, ty. span , UnsizedHandling :: Forbid )
302298 }
@@ -321,7 +317,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
321317 // `ForeignItem`s are handled separately.
322318 hir:: ItemKind :: ForeignMod { .. } => Ok ( ( ) ) ,
323319 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| {
325321 let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
326322 let item_ty =
327323 wfcx. deeply_normalize ( hir_ty. span , Some ( WellFormedLoc :: Ty ( def_id) ) , ty) ;
@@ -358,9 +354,7 @@ fn check_foreign_item<'tcx>(
358354 ) ;
359355
360356 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 ) ,
364358 hir:: ForeignItemKind :: Static ( ty, ..) => {
365359 check_static_item ( tcx, def_id, ty. span , UnsizedHandling :: AllowIfForeignTail )
366360 }
@@ -960,7 +954,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
960954 let ty = tcx. type_of ( param. def_id ) . instantiate_identity ( ) ;
961955
962956 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| {
964958 wfcx. register_bound (
965959 ObligationCause :: new (
966960 hir_ty. span ,
@@ -974,7 +968,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
974968 Ok ( ( ) )
975969 } )
976970 } 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| {
978972 wfcx. register_bound (
979973 ObligationCause :: new (
980974 hir_ty. span ,
@@ -1081,7 +1075,7 @@ fn check_associated_item(
10811075 sig_if_method : Option < & hir:: FnSig < ' _ > > ,
10821076) -> Result < ( ) , ErrorGuaranteed > {
10831077 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| {
10851079 let item = tcx. associated_item ( item_id) ;
10861080
10871081 // Avoid bogus "type annotations needed `Foo: Bar`" errors on `impl Bar for Foo` in case
@@ -1146,7 +1140,7 @@ fn check_type_defn<'tcx>(
11461140 let _ = tcx. representability ( item. owner_id . def_id ) ;
11471141 let adt_def = tcx. adt_def ( item. owner_id ) ;
11481142
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| {
11501144 let variants = adt_def. variants ( ) ;
11511145 let packed = adt_def. repr ( ) . packed ( ) ;
11521146
@@ -1273,7 +1267,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) -> Result<(), ErrorGuarant
12731267 }
12741268 }
12751269
1276- let res = enter_wf_checking_ctxt ( tcx, item . span , def_id, |wfcx| {
1270+ let res = enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
12771271 check_where_clauses ( wfcx, item. span , def_id) ;
12781272 Ok ( ( ) )
12791273 } ) ;
@@ -1311,10 +1305,9 @@ fn check_item_fn(
13111305 tcx : TyCtxt < ' _ > ,
13121306 def_id : LocalDefId ,
13131307 ident : Ident ,
1314- span : Span ,
13151308 decl : & hir:: FnDecl < ' _ > ,
13161309) -> Result < ( ) , ErrorGuaranteed > {
1317- enter_wf_checking_ctxt ( tcx, span , def_id, |wfcx| {
1310+ enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
13181311 let sig = tcx. fn_sig ( def_id) . instantiate_identity ( ) ;
13191312 check_fn_or_method ( wfcx, ident. span , sig, decl, def_id) ;
13201313 Ok ( ( ) )
@@ -1333,7 +1326,7 @@ fn check_static_item(
13331326 ty_span : Span ,
13341327 unsized_handling : UnsizedHandling ,
13351328) -> Result < ( ) , ErrorGuaranteed > {
1336- enter_wf_checking_ctxt ( tcx, ty_span , item_id, |wfcx| {
1329+ enter_wf_checking_ctxt ( tcx, item_id, |wfcx| {
13371330 let ty = tcx. type_of ( item_id) . instantiate_identity ( ) ;
13381331 let item_ty = wfcx. deeply_normalize ( ty_span, Some ( WellFormedLoc :: Ty ( item_id) ) , ty) ;
13391332
@@ -1388,7 +1381,7 @@ fn check_const_item(
13881381 ty_span : Span ,
13891382 item_span : Span ,
13901383) -> Result < ( ) , ErrorGuaranteed > {
1391- enter_wf_checking_ctxt ( tcx, ty_span , def_id, |wfcx| {
1384+ enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
13921385 let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
13931386 let ty = wfcx. deeply_normalize ( ty_span, Some ( WellFormedLoc :: Ty ( def_id) ) , ty) ;
13941387
@@ -1417,7 +1410,7 @@ fn check_impl<'tcx>(
14171410 hir_self_ty : & hir:: Ty < ' _ > ,
14181411 hir_trait_ref : & Option < hir:: TraitRef < ' _ > > ,
14191412) -> 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| {
14211414 match hir_trait_ref {
14221415 Some ( hir_trait_ref) => {
14231416 // `#[rustc_reservation_impl]` impls are not real impls and
@@ -2357,7 +2350,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
23572350 #[ instrument( level = "debug" , skip( self ) ) ]
23582351 fn check_false_global_bounds ( & mut self ) {
23592352 let tcx = self . ocx . infcx . tcx ;
2360- let mut span = self . span ;
2353+ let mut span = tcx . def_span ( self . body_def_id ) ;
23612354 let empty_env = ty:: ParamEnv :: empty ( ) ;
23622355
23632356 let predicates_with_span = tcx. predicates_of ( self . body_def_id ) . predicates . iter ( ) . copied ( ) ;
0 commit comments