@@ -46,7 +46,6 @@ use crate::{errors, fluent_generated as fluent};
4646
4747pub ( super ) struct WfCheckingCtxt < ' a , ' tcx > {
4848 pub ( super ) ocx : ObligationCtxt < ' a , ' tcx , FulfillmentError < ' tcx > > ,
49- span : Span ,
5049 body_def_id : LocalDefId ,
5150 param_env : ty:: ParamEnv < ' tcx > ,
5251}
@@ -122,7 +121,6 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
122121
123122pub ( super ) fn enter_wf_checking_ctxt < ' tcx , F > (
124123 tcx : TyCtxt < ' tcx > ,
125- span : Span ,
126124 body_def_id : LocalDefId ,
127125 f : F ,
128126) -> Result < ( ) , ErrorGuaranteed >
@@ -133,7 +131,7 @@ where
133131 let infcx = & tcx. infer_ctxt ( ) . build ( TypingMode :: non_body_analysis ( ) ) ;
134132 let ocx = ObligationCtxt :: new_with_diagnostics ( infcx) ;
135133
136- let mut wfcx = WfCheckingCtxt { ocx, span , body_def_id, param_env } ;
134+ let mut wfcx = WfCheckingCtxt { ocx, body_def_id, param_env } ;
137135
138136 if !tcx. features ( ) . trivial_bounds ( ) {
139137 wfcx. check_false_global_bounds ( )
@@ -295,9 +293,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
295293 }
296294 res
297295 }
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 ) ,
301297 hir:: ItemKind :: Static ( _, _, ty, _) => {
302298 check_static_item ( tcx, def_id, ty. span , UnsizedHandling :: Forbid )
303299 }
@@ -322,7 +318,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
322318 // `ForeignItem`s are handled separately.
323319 hir:: ItemKind :: ForeignMod { .. } => Ok ( ( ) ) ,
324320 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| {
326322 let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
327323 let item_ty =
328324 wfcx. deeply_normalize ( hir_ty. span , Some ( WellFormedLoc :: Ty ( def_id) ) , ty) ;
@@ -357,9 +353,7 @@ fn check_foreign_item<'tcx>(
357353 ) ;
358354
359355 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 ) ,
363357 hir:: ForeignItemKind :: Static ( ty, ..) => {
364358 check_static_item ( tcx, def_id, ty. span , UnsizedHandling :: AllowIfForeignTail )
365359 }
@@ -893,7 +887,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
893887 let ty = tcx. type_of ( param. def_id ) . instantiate_identity ( ) ;
894888
895889 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| {
897891 wfcx. register_bound (
898892 ObligationCause :: new (
899893 hir_ty. span ,
@@ -907,7 +901,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
907901 Ok ( ( ) )
908902 } )
909903 } 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| {
911905 wfcx. register_bound (
912906 ObligationCause :: new (
913907 hir_ty. span ,
@@ -1014,7 +1008,7 @@ fn check_associated_item(
10141008 sig_if_method : Option < & hir:: FnSig < ' _ > > ,
10151009) -> Result < ( ) , ErrorGuaranteed > {
10161010 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| {
10181012 let item = tcx. associated_item ( item_id) ;
10191013
10201014 // Avoid bogus "type annotations needed `Foo: Bar`" errors on `impl Bar for Foo` in case
@@ -1079,7 +1073,7 @@ fn check_type_defn<'tcx>(
10791073 let _ = tcx. representability ( item. owner_id . def_id ) ;
10801074 let adt_def = tcx. adt_def ( item. owner_id ) ;
10811075
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| {
10831077 let variants = adt_def. variants ( ) ;
10841078 let packed = adt_def. repr ( ) . packed ( ) ;
10851079
@@ -1211,7 +1205,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) -> Result<(), ErrorGuarant
12111205 }
12121206 }
12131207
1214- let res = enter_wf_checking_ctxt ( tcx, item . span , def_id, |wfcx| {
1208+ let res = enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
12151209 check_where_clauses ( wfcx, item. span , def_id) ;
12161210 Ok ( ( ) )
12171211 } ) ;
@@ -1249,10 +1243,9 @@ fn check_item_fn(
12491243 tcx : TyCtxt < ' _ > ,
12501244 def_id : LocalDefId ,
12511245 ident : Ident ,
1252- span : Span ,
12531246 decl : & hir:: FnDecl < ' _ > ,
12541247) -> Result < ( ) , ErrorGuaranteed > {
1255- enter_wf_checking_ctxt ( tcx, span , def_id, |wfcx| {
1248+ enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
12561249 let sig = tcx. fn_sig ( def_id) . instantiate_identity ( ) ;
12571250 check_fn_or_method ( wfcx, ident. span , sig, decl, def_id) ;
12581251 Ok ( ( ) )
@@ -1271,7 +1264,7 @@ fn check_static_item(
12711264 ty_span : Span ,
12721265 unsized_handling : UnsizedHandling ,
12731266) -> Result < ( ) , ErrorGuaranteed > {
1274- enter_wf_checking_ctxt ( tcx, ty_span , item_id, |wfcx| {
1267+ enter_wf_checking_ctxt ( tcx, item_id, |wfcx| {
12751268 let ty = tcx. type_of ( item_id) . instantiate_identity ( ) ;
12761269 let item_ty = wfcx. deeply_normalize ( ty_span, Some ( WellFormedLoc :: Ty ( item_id) ) , ty) ;
12771270
@@ -1326,7 +1319,7 @@ fn check_const_item(
13261319 ty_span : Span ,
13271320 item_span : Span ,
13281321) -> Result < ( ) , ErrorGuaranteed > {
1329- enter_wf_checking_ctxt ( tcx, ty_span , def_id, |wfcx| {
1322+ enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
13301323 let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
13311324 let ty = wfcx. deeply_normalize ( ty_span, Some ( WellFormedLoc :: Ty ( def_id) ) , ty) ;
13321325
@@ -1355,7 +1348,7 @@ fn check_impl<'tcx>(
13551348 hir_self_ty : & hir:: Ty < ' _ > ,
13561349 hir_trait_ref : & Option < hir:: TraitRef < ' _ > > ,
13571350) -> 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| {
13591352 match hir_trait_ref {
13601353 Some ( hir_trait_ref) => {
13611354 // `#[rustc_reservation_impl]` impls are not real impls and
@@ -2295,7 +2288,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
22952288 #[ instrument( level = "debug" , skip( self ) ) ]
22962289 fn check_false_global_bounds ( & mut self ) {
22972290 let tcx = self . ocx . infcx . tcx ;
2298- let mut span = self . span ;
2291+ let mut span = tcx . def_span ( self . body_def_id ) ;
22992292 let empty_env = ty:: ParamEnv :: empty ( ) ;
23002293
23012294 let predicates_with_span = tcx. predicates_of ( self . body_def_id ) . predicates . iter ( ) . copied ( ) ;
0 commit comments