@@ -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 }
@@ -829,13 +827,12 @@ fn check_impl_item<'tcx>(
829827 tcx : TyCtxt < ' tcx > ,
830828 impl_item : & ' tcx hir:: ImplItem < ' tcx > ,
831829) -> Result < ( ) , ErrorGuaranteed > {
832- let ( method_sig, span) = match impl_item. kind {
833- hir:: ImplItemKind :: Fn ( ref sig, _) => ( Some ( sig) , impl_item. span ) ,
830+ let span = match impl_item. kind {
834831 // Constrain binding and overflow error spans to `<Ty>` in `type foo = <Ty>`.
835- hir:: ImplItemKind :: Type ( ty) if ty. span != DUMMY_SP => ( None , ty. span ) ,
836- _ => ( None , impl_item. span ) ,
832+ hir:: ImplItemKind :: Type ( ty) if ty. span != DUMMY_SP => ty. span ,
833+ _ => impl_item. span ,
837834 } ;
838- check_associated_item ( tcx, impl_item. owner_id . def_id , span, method_sig )
835+ check_associated_item ( tcx, impl_item. owner_id . def_id , span)
839836}
840837
841838fn check_param_wf ( tcx : TyCtxt < ' _ > , param : & ty:: GenericParamDef ) -> Result < ( ) , ErrorGuaranteed > {
@@ -963,12 +960,11 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &ty::GenericParamDef) -> Result<(), Er
963960 }
964961}
965962
966- #[ instrument( level = "debug" , skip( tcx, span, sig_if_method ) ) ]
963+ #[ instrument( level = "debug" , skip( tcx, span) ) ]
967964fn check_associated_item (
968965 tcx : TyCtxt < ' _ > ,
969966 item_id : LocalDefId ,
970967 span : Span ,
971- sig_if_method : Option < & hir:: FnSig < ' _ > > ,
972968) -> Result < ( ) , ErrorGuaranteed > {
973969 let loc = Some ( WellFormedLoc :: Ty ( item_id) ) ;
974970 enter_wf_checking_ctxt ( tcx, item_id, |wfcx| {
@@ -1002,7 +998,8 @@ fn check_associated_item(
1002998 }
1003999 ty:: AssocKind :: Fn { .. } => {
10041000 let sig = tcx. fn_sig ( item. def_id ) . instantiate_identity ( ) ;
1005- let hir_sig = sig_if_method. expect ( "bad signature for method" ) ;
1001+ let hir_sig =
1002+ tcx. hir_node_by_def_id ( item_id) . fn_sig ( ) . expect ( "bad signature for method" ) ;
10061003 check_fn_or_method ( wfcx, sig, hir_sig. decl , item. def_id . expect_local ( ) ) ;
10071004 check_method_receiver ( wfcx, hir_sig, item, self_ty)
10081005 }
0 commit comments