@@ -25,7 +25,7 @@ use rustc_middle::ty::{
2525} ;
2626use rustc_middle:: { bug, span_bug} ;
2727use rustc_session:: parse:: feature_err;
28- use rustc_span:: { DUMMY_SP , Ident , Span , sym} ;
28+ use rustc_span:: { DUMMY_SP , Span , sym} ;
2929use rustc_trait_selection:: error_reporting:: InferCtxtErrorExt ;
3030use rustc_trait_selection:: regions:: { InferCtxtRegionExt , OutlivesEnvironmentBuildExt } ;
3131use rustc_trait_selection:: traits:: misc:: {
@@ -291,8 +291,8 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
291291 }
292292 res
293293 }
294- hir:: ItemKind :: Fn { ident , sig, .. } => check_item_fn ( tcx, def_id, ident , sig. decl ) ,
295- hir:: ItemKind :: Const ( _, _, ty, _) => check_const_item ( tcx, def_id, ty. span , item . span ) ,
294+ hir:: ItemKind :: Fn { sig, .. } => check_item_fn ( tcx, def_id, sig. decl ) ,
295+ hir:: ItemKind :: Const ( _, _, ty, _) => check_const_item ( tcx, def_id, ty. span ) ,
296296 hir:: ItemKind :: Struct ( ..) => check_type_defn ( tcx, item, false ) ,
297297 hir:: ItemKind :: Union ( ..) => check_type_defn ( tcx, item, true ) ,
298298 hir:: ItemKind :: Enum ( ..) => check_type_defn ( tcx, item, true ) ,
@@ -308,7 +308,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
308308 Some ( WellFormedLoc :: Ty ( def_id) ) ,
309309 item_ty. into ( ) ,
310310 ) ;
311- check_where_clauses ( wfcx, item . span , def_id) ;
311+ check_where_clauses ( wfcx, def_id) ;
312312 Ok ( ( ) )
313313 } )
314314 }
@@ -330,7 +330,7 @@ fn check_foreign_item<'tcx>(
330330 ) ;
331331
332332 match item. kind {
333- hir:: ForeignItemKind :: Fn ( sig, ..) => check_item_fn ( tcx, def_id, item . ident , sig. decl ) ,
333+ hir:: ForeignItemKind :: Fn ( sig, ..) => check_item_fn ( tcx, def_id, sig. decl ) ,
334334 hir:: ForeignItemKind :: Static ( ..) | hir:: ForeignItemKind :: Type => Ok ( ( ) ) ,
335335 }
336336}
@@ -1086,13 +1086,7 @@ fn check_associated_item(
10861086 ty:: AssocKind :: Fn { .. } => {
10871087 let sig = tcx. fn_sig ( item. def_id ) . instantiate_identity ( ) ;
10881088 let hir_sig = sig_if_method. expect ( "bad signature for method" ) ;
1089- check_fn_or_method (
1090- wfcx,
1091- item. ident ( tcx) . span ,
1092- sig,
1093- hir_sig. decl ,
1094- item. def_id . expect_local ( ) ,
1095- ) ;
1089+ check_fn_or_method ( wfcx, sig, hir_sig. decl , item. def_id . expect_local ( ) ) ;
10961090 check_method_receiver ( wfcx, hir_sig, item, self_ty)
10971091 }
10981092 ty:: AssocKind :: Type { .. } => {
@@ -1221,7 +1215,7 @@ fn check_type_defn<'tcx>(
12211215 }
12221216 }
12231217
1224- check_where_clauses ( wfcx, item. span , item . owner_id . def_id ) ;
1218+ check_where_clauses ( wfcx, item. owner_id . def_id ) ;
12251219 Ok ( ( ) )
12261220 } )
12271221}
@@ -1247,7 +1241,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) -> Result<(), ErrorGuarant
12471241 }
12481242
12491243 let res = enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
1250- check_where_clauses ( wfcx, item . span , def_id) ;
1244+ check_where_clauses ( wfcx, def_id) ;
12511245 Ok ( ( ) )
12521246 } ) ;
12531247
@@ -1283,12 +1277,11 @@ fn check_associated_type_bounds(wfcx: &WfCheckingCtxt<'_, '_>, item: ty::AssocIt
12831277fn check_item_fn (
12841278 tcx : TyCtxt < ' _ > ,
12851279 def_id : LocalDefId ,
1286- ident : Ident ,
12871280 decl : & hir:: FnDecl < ' _ > ,
12881281) -> Result < ( ) , ErrorGuaranteed > {
12891282 enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
12901283 let sig = tcx. fn_sig ( def_id) . instantiate_identity ( ) ;
1291- check_fn_or_method ( wfcx, ident . span , sig, decl, def_id) ;
1284+ check_fn_or_method ( wfcx, sig, decl, def_id) ;
12921285 Ok ( ( ) )
12931286 } )
12941287}
@@ -1349,7 +1342,6 @@ fn check_const_item(
13491342 tcx : TyCtxt < ' _ > ,
13501343 def_id : LocalDefId ,
13511344 ty_span : Span ,
1352- item_span : Span ,
13531345) -> Result < ( ) , ErrorGuaranteed > {
13541346 enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
13551347 let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
@@ -1367,7 +1359,7 @@ fn check_const_item(
13671359 tcx. require_lang_item ( LangItem :: Sized , None ) ,
13681360 ) ;
13691361
1370- check_where_clauses ( wfcx, item_span , def_id) ;
1362+ check_where_clauses ( wfcx, def_id) ;
13711363
13721364 Ok ( ( ) )
13731365 } )
@@ -1464,14 +1456,14 @@ fn check_impl<'tcx>(
14641456 }
14651457 }
14661458
1467- check_where_clauses ( wfcx, item. span , item . owner_id . def_id ) ;
1459+ check_where_clauses ( wfcx, item. owner_id . def_id ) ;
14681460 Ok ( ( ) )
14691461 } )
14701462}
14711463
14721464/// Checks where-clauses and inline bounds that are declared on `def_id`.
14731465#[ instrument( level = "debug" , skip( wfcx) ) ]
1474- fn check_where_clauses < ' tcx > ( wfcx : & WfCheckingCtxt < ' _ , ' tcx > , span : Span , def_id : LocalDefId ) {
1466+ pub ( super ) fn check_where_clauses < ' tcx > ( wfcx : & WfCheckingCtxt < ' _ , ' tcx > , def_id : LocalDefId ) {
14751467 let infcx = wfcx. infcx ;
14761468 let tcx = wfcx. tcx ( ) ;
14771469
@@ -1624,21 +1616,18 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
16241616
16251617 let predicates = predicates. instantiate_identity ( tcx) ;
16261618
1627- let predicates = wfcx. normalize ( span, None , predicates) ;
1628-
1629- debug ! ( ?predicates. predicates) ;
16301619 assert_eq ! ( predicates. predicates. len( ) , predicates. spans. len( ) ) ;
16311620 let wf_obligations = predicates. into_iter ( ) . flat_map ( |( p, sp) | {
1621+ let p = wfcx. normalize ( sp, None , p) ;
16321622 traits:: wf:: clause_obligations ( infcx, wfcx. param_env , wfcx. body_def_id , p, sp)
16331623 } ) ;
16341624 let obligations: Vec < _ > = wf_obligations. chain ( default_obligations) . collect ( ) ;
16351625 wfcx. register_obligations ( obligations) ;
16361626}
16371627
1638- #[ instrument( level = "debug" , skip( wfcx, span , hir_decl) ) ]
1628+ #[ instrument( level = "debug" , skip( wfcx, hir_decl) ) ]
16391629fn check_fn_or_method < ' tcx > (
16401630 wfcx : & WfCheckingCtxt < ' _ , ' tcx > ,
1641- span : Span ,
16421631 sig : ty:: PolyFnSig < ' tcx > ,
16431632 hir_decl : & hir:: FnDecl < ' _ > ,
16441633 def_id : LocalDefId ,
@@ -1676,7 +1665,7 @@ fn check_fn_or_method<'tcx>(
16761665 ) ;
16771666 }
16781667
1679- check_where_clauses ( wfcx, span , def_id) ;
1668+ check_where_clauses ( wfcx, def_id) ;
16801669
16811670 if sig. abi == ExternAbi :: RustCall {
16821671 let span = tcx. def_span ( def_id) ;
0 commit comments