@@ -328,24 +328,22 @@ fn check_trait_item<'tcx>(
328328) -> Result < ( ) , ErrorGuaranteed > {
329329 let def_id = trait_item. owner_id . def_id ;
330330
331- let ( method_sig, span) = match trait_item. kind {
332- hir:: TraitItemKind :: Fn ( ref sig, _) => ( Some ( sig) , trait_item. span ) ,
333- hir:: TraitItemKind :: Type ( _bounds, Some ( ty) ) => ( None , ty. span ) ,
334- _ => ( None , trait_item. span ) ,
331+ let span = match trait_item. kind {
332+ hir:: TraitItemKind :: Type ( _bounds, Some ( ty) ) => ty. span ,
333+ _ => trait_item. span ,
335334 } ;
336335
337336 // Check that an item definition in a subtrait is shadowing a supertrait item.
338337 lint_item_shadowing_supertrait_item ( tcx, def_id) ;
339338
340- let mut res = check_associated_item ( tcx, def_id, span, method_sig ) ;
339+ let mut res = check_associated_item ( tcx, def_id, span) ;
341340
342341 if matches ! ( trait_item. kind, hir:: TraitItemKind :: Fn ( ..) ) {
343342 for & assoc_ty_def_id in tcx. associated_types_for_impl_traits_in_associated_fn ( def_id) {
344343 res = res. and ( check_associated_item (
345344 tcx,
346345 assoc_ty_def_id. expect_local ( ) ,
347346 tcx. def_span ( assoc_ty_def_id) ,
348- None ,
349347 ) ) ;
350348 }
351349 }
@@ -825,13 +823,12 @@ fn check_impl_item<'tcx>(
825823 tcx : TyCtxt < ' tcx > ,
826824 impl_item : & ' tcx hir:: ImplItem < ' tcx > ,
827825) -> Result < ( ) , ErrorGuaranteed > {
828- let ( method_sig, span) = match impl_item. kind {
829- hir:: ImplItemKind :: Fn ( ref sig, _) => ( Some ( sig) , impl_item. span ) ,
826+ let span = match impl_item. kind {
830827 // Constrain binding and overflow error spans to `<Ty>` in `type foo = <Ty>`.
831- hir:: ImplItemKind :: Type ( ty) if ty. span != DUMMY_SP => ( None , ty. span ) ,
832- _ => ( None , impl_item. span ) ,
828+ hir:: ImplItemKind :: Type ( ty) if ty. span != DUMMY_SP => ty. span ,
829+ _ => impl_item. span ,
833830 } ;
834- check_associated_item ( tcx, impl_item. owner_id . def_id , span, method_sig )
831+ check_associated_item ( tcx, impl_item. owner_id . def_id , span)
835832}
836833
837834fn check_param_wf ( tcx : TyCtxt < ' _ > , param : & ty:: GenericParamDef ) -> Result < ( ) , ErrorGuaranteed > {
@@ -959,12 +956,11 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &ty::GenericParamDef) -> Result<(), Er
959956 }
960957}
961958
962- #[ instrument( level = "debug" , skip( tcx, span, sig_if_method ) ) ]
959+ #[ instrument( level = "debug" , skip( tcx, span) ) ]
963960fn check_associated_item (
964961 tcx : TyCtxt < ' _ > ,
965962 item_id : LocalDefId ,
966963 span : Span ,
967- sig_if_method : Option < & hir:: FnSig < ' _ > > ,
968964) -> Result < ( ) , ErrorGuaranteed > {
969965 let loc = Some ( WellFormedLoc :: Ty ( item_id) ) ;
970966 enter_wf_checking_ctxt ( tcx, item_id, |wfcx| {
@@ -998,7 +994,8 @@ fn check_associated_item(
998994 }
999995 ty:: AssocKind :: Fn { .. } => {
1000996 let sig = tcx. fn_sig ( item. def_id ) . instantiate_identity ( ) ;
1001- let hir_sig = sig_if_method. expect ( "bad signature for method" ) ;
997+ let hir_sig =
998+ tcx. hir_node_by_def_id ( item_id) . fn_sig ( ) . expect ( "bad signature for method" ) ;
1002999 check_fn_or_method ( wfcx, sig, hir_sig. decl , item. def_id . expect_local ( ) ) ;
10031000 check_method_receiver ( wfcx, hir_sig, item, self_ty)
10041001 }
0 commit comments