@@ -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:: {
@@ -290,8 +290,8 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
290290 }
291291 res
292292 }
293- hir:: ItemKind :: Fn { ident , sig, .. } => check_item_fn ( tcx, def_id, ident , sig. decl ) ,
294- hir:: ItemKind :: Const ( _, _, ty, _) => check_const_item ( tcx, def_id, ty. span , item . span ) ,
293+ hir:: ItemKind :: Fn { sig, .. } => check_item_fn ( tcx, def_id, sig. decl ) ,
294+ hir:: ItemKind :: Const ( _, _, ty, _) => check_const_item ( tcx, def_id, ty. span ) ,
295295 hir:: ItemKind :: Struct ( ..) => check_type_defn ( tcx, item, false ) ,
296296 hir:: ItemKind :: Union ( ..) => check_type_defn ( tcx, item, true ) ,
297297 hir:: ItemKind :: Enum ( ..) => check_type_defn ( tcx, item, true ) ,
@@ -307,7 +307,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) -> Result<()
307307 Some ( WellFormedLoc :: Ty ( def_id) ) ,
308308 item_ty. into ( ) ,
309309 ) ;
310- check_where_clauses ( wfcx, item . span , def_id) ;
310+ check_where_clauses ( wfcx, def_id) ;
311311 Ok ( ( ) )
312312 } )
313313 }
@@ -327,7 +327,7 @@ fn check_foreign_item<'tcx>(
327327 ) ;
328328
329329 match item. kind {
330- hir:: ForeignItemKind :: Fn ( sig, ..) => check_item_fn ( tcx, def_id, item . ident , sig. decl ) ,
330+ hir:: ForeignItemKind :: Fn ( sig, ..) => check_item_fn ( tcx, def_id, sig. decl ) ,
331331 hir:: ForeignItemKind :: Static ( ..) | hir:: ForeignItemKind :: Type => Ok ( ( ) ) ,
332332 }
333333}
@@ -1013,13 +1013,7 @@ fn check_associated_item(
10131013 ty:: AssocKind :: Fn { .. } => {
10141014 let sig = tcx. fn_sig ( item. def_id ) . instantiate_identity ( ) ;
10151015 let hir_sig = sig_if_method. expect ( "bad signature for method" ) ;
1016- check_fn_or_method (
1017- wfcx,
1018- item. ident ( tcx) . span ,
1019- sig,
1020- hir_sig. decl ,
1021- item. def_id . expect_local ( ) ,
1022- ) ;
1016+ check_fn_or_method ( wfcx, sig, hir_sig. decl , item. def_id . expect_local ( ) ) ;
10231017 check_method_receiver ( wfcx, hir_sig, item, self_ty)
10241018 }
10251019 ty:: AssocKind :: Type { .. } => {
@@ -1148,7 +1142,7 @@ fn check_type_defn<'tcx>(
11481142 }
11491143 }
11501144
1151- check_where_clauses ( wfcx, item. span , item . owner_id . def_id ) ;
1145+ check_where_clauses ( wfcx, item. owner_id . def_id ) ;
11521146 Ok ( ( ) )
11531147 } )
11541148}
@@ -1179,7 +1173,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) -> Result<(), ErrorGuarant
11791173 }
11801174
11811175 let res = enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
1182- check_where_clauses ( wfcx, item . span , def_id) ;
1176+ check_where_clauses ( wfcx, def_id) ;
11831177 Ok ( ( ) )
11841178 } ) ;
11851179
@@ -1215,12 +1209,11 @@ fn check_associated_type_bounds(wfcx: &WfCheckingCtxt<'_, '_>, item: ty::AssocIt
12151209fn check_item_fn (
12161210 tcx : TyCtxt < ' _ > ,
12171211 def_id : LocalDefId ,
1218- ident : Ident ,
12191212 decl : & hir:: FnDecl < ' _ > ,
12201213) -> Result < ( ) , ErrorGuaranteed > {
12211214 enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
12221215 let sig = tcx. fn_sig ( def_id) . instantiate_identity ( ) ;
1223- check_fn_or_method ( wfcx, ident . span , sig, decl, def_id) ;
1216+ check_fn_or_method ( wfcx, sig, decl, def_id) ;
12241217 Ok ( ( ) )
12251218 } )
12261219}
@@ -1281,7 +1274,6 @@ fn check_const_item(
12811274 tcx : TyCtxt < ' _ > ,
12821275 def_id : LocalDefId ,
12831276 ty_span : Span ,
1284- item_span : Span ,
12851277) -> Result < ( ) , ErrorGuaranteed > {
12861278 enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
12871279 let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
@@ -1299,7 +1291,7 @@ fn check_const_item(
12991291 tcx. require_lang_item ( LangItem :: Sized , ty_span) ,
13001292 ) ;
13011293
1302- check_where_clauses ( wfcx, item_span , def_id) ;
1294+ check_where_clauses ( wfcx, def_id) ;
13031295
13041296 Ok ( ( ) )
13051297 } )
@@ -1396,14 +1388,14 @@ fn check_impl<'tcx>(
13961388 }
13971389 }
13981390
1399- check_where_clauses ( wfcx, item. span , item . owner_id . def_id ) ;
1391+ check_where_clauses ( wfcx, item. owner_id . def_id ) ;
14001392 Ok ( ( ) )
14011393 } )
14021394}
14031395
14041396/// Checks where-clauses and inline bounds that are declared on `def_id`.
14051397#[ instrument( level = "debug" , skip( wfcx) ) ]
1406- fn check_where_clauses < ' tcx > ( wfcx : & WfCheckingCtxt < ' _ , ' tcx > , span : Span , def_id : LocalDefId ) {
1398+ pub ( super ) fn check_where_clauses < ' tcx > ( wfcx : & WfCheckingCtxt < ' _ , ' tcx > , def_id : LocalDefId ) {
14071399 let infcx = wfcx. infcx ;
14081400 let tcx = wfcx. tcx ( ) ;
14091401
@@ -1556,21 +1548,18 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
15561548
15571549 let predicates = predicates. instantiate_identity ( tcx) ;
15581550
1559- let predicates = wfcx. normalize ( span, None , predicates) ;
1560-
1561- debug ! ( ?predicates. predicates) ;
15621551 assert_eq ! ( predicates. predicates. len( ) , predicates. spans. len( ) ) ;
15631552 let wf_obligations = predicates. into_iter ( ) . flat_map ( |( p, sp) | {
1553+ let p = wfcx. normalize ( sp, None , p) ;
15641554 traits:: wf:: clause_obligations ( infcx, wfcx. param_env , wfcx. body_def_id , p, sp)
15651555 } ) ;
15661556 let obligations: Vec < _ > = wf_obligations. chain ( default_obligations) . collect ( ) ;
15671557 wfcx. register_obligations ( obligations) ;
15681558}
15691559
1570- #[ instrument( level = "debug" , skip( wfcx, span , hir_decl) ) ]
1560+ #[ instrument( level = "debug" , skip( wfcx, hir_decl) ) ]
15711561fn check_fn_or_method < ' tcx > (
15721562 wfcx : & WfCheckingCtxt < ' _ , ' tcx > ,
1573- span : Span ,
15741563 sig : ty:: PolyFnSig < ' tcx > ,
15751564 hir_decl : & hir:: FnDecl < ' _ > ,
15761565 def_id : LocalDefId ,
@@ -1608,7 +1597,7 @@ fn check_fn_or_method<'tcx>(
16081597 ) ;
16091598 }
16101599
1611- check_where_clauses ( wfcx, span , def_id) ;
1600+ check_where_clauses ( wfcx, def_id) ;
16121601
16131602 if sig. abi == ExternAbi :: RustCall {
16141603 let span = tcx. def_span ( def_id) ;
0 commit comments