@@ -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}
@@ -1017,13 +1017,7 @@ fn check_associated_item(
10171017 ty:: AssocKind :: Fn { .. } => {
10181018 let sig = tcx. fn_sig ( item. def_id ) . instantiate_identity ( ) ;
10191019 let hir_sig = sig_if_method. expect ( "bad signature for method" ) ;
1020- check_fn_or_method (
1021- wfcx,
1022- item. ident ( tcx) . span ,
1023- sig,
1024- hir_sig. decl ,
1025- item. def_id . expect_local ( ) ,
1026- ) ;
1020+ check_fn_or_method ( wfcx, sig, hir_sig. decl , item. def_id . expect_local ( ) ) ;
10271021 check_method_receiver ( wfcx, hir_sig, item, self_ty)
10281022 }
10291023 ty:: AssocKind :: Type { .. } => {
@@ -1152,7 +1146,7 @@ fn check_type_defn<'tcx>(
11521146 }
11531147 }
11541148
1155- check_where_clauses ( wfcx, item. span , item . owner_id . def_id ) ;
1149+ check_where_clauses ( wfcx, item. owner_id . def_id ) ;
11561150 Ok ( ( ) )
11571151 } )
11581152}
@@ -1183,7 +1177,7 @@ fn check_trait(tcx: TyCtxt<'_>, item: &hir::Item<'_>) -> Result<(), ErrorGuarant
11831177 }
11841178
11851179 let res = enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
1186- check_where_clauses ( wfcx, item . span , def_id) ;
1180+ check_where_clauses ( wfcx, def_id) ;
11871181 Ok ( ( ) )
11881182 } ) ;
11891183
@@ -1219,12 +1213,11 @@ fn check_associated_type_bounds(wfcx: &WfCheckingCtxt<'_, '_>, item: ty::AssocIt
12191213fn check_item_fn (
12201214 tcx : TyCtxt < ' _ > ,
12211215 def_id : LocalDefId ,
1222- ident : Ident ,
12231216 decl : & hir:: FnDecl < ' _ > ,
12241217) -> Result < ( ) , ErrorGuaranteed > {
12251218 enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
12261219 let sig = tcx. fn_sig ( def_id) . instantiate_identity ( ) ;
1227- check_fn_or_method ( wfcx, ident . span , sig, decl, def_id) ;
1220+ check_fn_or_method ( wfcx, sig, decl, def_id) ;
12281221 Ok ( ( ) )
12291222 } )
12301223}
@@ -1287,7 +1280,6 @@ fn check_const_item(
12871280 tcx : TyCtxt < ' _ > ,
12881281 def_id : LocalDefId ,
12891282 ty_span : Span ,
1290- item_span : Span ,
12911283) -> Result < ( ) , ErrorGuaranteed > {
12921284 enter_wf_checking_ctxt ( tcx, def_id, |wfcx| {
12931285 let ty = tcx. type_of ( def_id) . instantiate_identity ( ) ;
@@ -1305,7 +1297,7 @@ fn check_const_item(
13051297 tcx. require_lang_item ( LangItem :: Sized , ty_span) ,
13061298 ) ;
13071299
1308- check_where_clauses ( wfcx, item_span , def_id) ;
1300+ check_where_clauses ( wfcx, def_id) ;
13091301
13101302 Ok ( ( ) )
13111303 } )
@@ -1402,14 +1394,14 @@ fn check_impl<'tcx>(
14021394 }
14031395 }
14041396
1405- check_where_clauses ( wfcx, item. span , item . owner_id . def_id ) ;
1397+ check_where_clauses ( wfcx, item. owner_id . def_id ) ;
14061398 Ok ( ( ) )
14071399 } )
14081400}
14091401
14101402/// Checks where-clauses and inline bounds that are declared on `def_id`.
14111403#[ instrument( level = "debug" , skip( wfcx) ) ]
1412- fn check_where_clauses < ' tcx > ( wfcx : & WfCheckingCtxt < ' _ , ' tcx > , span : Span , def_id : LocalDefId ) {
1404+ pub ( super ) fn check_where_clauses < ' tcx > ( wfcx : & WfCheckingCtxt < ' _ , ' tcx > , def_id : LocalDefId ) {
14131405 let infcx = wfcx. infcx ;
14141406 let tcx = wfcx. tcx ( ) ;
14151407
@@ -1564,21 +1556,18 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
15641556
15651557 let predicates = predicates. instantiate_identity ( tcx) ;
15661558
1567- let predicates = wfcx. normalize ( span, None , predicates) ;
1568-
1569- debug ! ( ?predicates. predicates) ;
15701559 assert_eq ! ( predicates. predicates. len( ) , predicates. spans. len( ) ) ;
15711560 let wf_obligations = predicates. into_iter ( ) . flat_map ( |( p, sp) | {
1561+ let p = wfcx. normalize ( sp, None , p) ;
15721562 traits:: wf:: clause_obligations ( infcx, wfcx. param_env , wfcx. body_def_id , p, sp)
15731563 } ) ;
15741564 let obligations: Vec < _ > = wf_obligations. chain ( default_obligations) . collect ( ) ;
15751565 wfcx. register_obligations ( obligations) ;
15761566}
15771567
1578- #[ instrument( level = "debug" , skip( wfcx, span , hir_decl) ) ]
1568+ #[ instrument( level = "debug" , skip( wfcx, hir_decl) ) ]
15791569fn check_fn_or_method < ' tcx > (
15801570 wfcx : & WfCheckingCtxt < ' _ , ' tcx > ,
1581- span : Span ,
15821571 sig : ty:: PolyFnSig < ' tcx > ,
15831572 hir_decl : & hir:: FnDecl < ' _ > ,
15841573 def_id : LocalDefId ,
@@ -1616,7 +1605,7 @@ fn check_fn_or_method<'tcx>(
16161605 ) ;
16171606 }
16181607
1619- check_where_clauses ( wfcx, span , def_id) ;
1608+ check_where_clauses ( wfcx, def_id) ;
16201609
16211610 if sig. abi == ExternAbi :: RustCall {
16221611 let span = tcx. def_span ( def_id) ;
0 commit comments