@@ -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 }
@@ -897,7 +891,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
897891 let ty = tcx. type_of ( param. def_id ) . instantiate_identity ( ) ;
898892
899893 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| {
901895 wfcx. register_bound (
902896 ObligationCause :: new (
903897 hir_ty. span ,
@@ -911,7 +905,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) -> Result<(),
911905 Ok ( ( ) )
912906 } )
913907 } 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| {
915909 wfcx. register_bound (
916910 ObligationCause :: new (
917911 hir_ty. span ,
@@ -1018,7 +1012,7 @@ fn check_associated_item(
10181012 sig_if_method : Option < & hir:: FnSig < ' _ > > ,
10191013) -> Result < ( ) , ErrorGuaranteed > {
10201014 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| {
10221016 let item = tcx. associated_item ( item_id) ;
10231017
10241018 // Avoid bogus "type annotations needed `Foo: Bar`" errors on `impl Bar for Foo` in case
@@ -1083,7 +1077,7 @@ fn check_type_defn<'tcx>(
10831077 let _ = tcx. representability ( item. owner_id . def_id ) ;
10841078 let adt_def = tcx. adt_def ( item. owner_id ) ;
10851079
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| {
10871081 let variants = adt_def. variants ( ) ;
10881082 let packed = adt_def. repr ( ) . packed ( ) ;
10891083
@@ -1215,7 +1209,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) -> Result<(), ErrorGuarant
12151209 }
12161210 }
12171211
1218- let res = enter_wf_checking_ctxt ( tcx, item . span , def_id, |wfcx| {
1212+ let res = enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
12191213 check_where_clauses ( wfcx, item. span , def_id) ;
12201214 Ok ( ( ) )
12211215 } ) ;
@@ -1253,10 +1247,9 @@ fn check_item_fn(
12531247 tcx : TyCtxt < ' _ > ,
12541248 def_id : LocalDefId ,
12551249 ident : Ident ,
1256- span : Span ,
12571250 decl : & hir:: FnDecl < ' _ > ,
12581251) -> Result < ( ) , ErrorGuaranteed > {
1259- enter_wf_checking_ctxt ( tcx, span , def_id, |wfcx| {
1252+ enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
12601253 let sig = tcx. fn_sig ( def_id) . instantiate_identity ( ) ;
12611254 check_fn_or_method ( wfcx, ident. span , sig, decl, def_id) ;
12621255 Ok ( ( ) )
@@ -1275,7 +1268,7 @@ fn check_static_item(
12751268 ty_span : Span ,
12761269 unsized_handling : UnsizedHandling ,
12771270) -> Result < ( ) , ErrorGuaranteed > {
1278- enter_wf_checking_ctxt ( tcx, ty_span , item_id, |wfcx| {
1271+ enter_wf_checking_ctxt ( tcx, item_id, |wfcx| {
12791272 let ty = tcx. type_of ( item_id) . instantiate_identity ( ) ;
12801273 let item_ty = wfcx. deeply_normalize ( ty_span, Some ( WellFormedLoc :: Ty ( item_id) ) , ty) ;
12811274
@@ -1330,7 +1323,7 @@ fn check_const_item(
13301323 ty_span : Span ,
13311324 item_span : Span ,
13321325) -> Result < ( ) , ErrorGuaranteed > {
1333- enter_wf_checking_ctxt ( tcx, ty_span , def_id, |wfcx| {
1326+ enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
13341327 let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
13351328 let ty = wfcx. deeply_normalize ( ty_span, Some ( WellFormedLoc :: Ty ( def_id) ) , ty) ;
13361329
@@ -1359,7 +1352,7 @@ fn check_impl<'tcx>(
13591352 hir_self_ty : & hir:: Ty < ' _ > ,
13601353 hir_trait_ref : & Option < hir:: TraitRef < ' _ > > ,
13611354) -> 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| {
13631356 match hir_trait_ref {
13641357 Some ( hir_trait_ref) => {
13651358 // `#[rustc_reservation_impl]` impls are not real impls and
@@ -2301,7 +2294,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
23012294 #[ instrument( level = "debug" , skip( self ) ) ]
23022295 fn check_false_global_bounds ( & mut self ) {
23032296 let tcx = self . ocx . infcx . tcx ;
2304- let mut span = self . span ;
2297+ let mut span = tcx . def_span ( self . body_def_id ) ;
23052298 let empty_env = ty:: ParamEnv :: empty ( ) ;
23062299
23072300 let predicates_with_span = tcx. predicates_of ( self . body_def_id ) . predicates . iter ( ) . copied ( ) ;
0 commit comments