@@ -328,24 +328,22 @@ fn check_trait_item<'tcx>(
328
328
) -> Result < ( ) , ErrorGuaranteed > {
329
329
let def_id = trait_item. owner_id . def_id ;
330
330
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 ,
335
334
} ;
336
335
337
336
// Check that an item definition in a subtrait is shadowing a supertrait item.
338
337
lint_item_shadowing_supertrait_item ( tcx, def_id) ;
339
338
340
- let mut res = check_associated_item ( tcx, def_id, span, method_sig ) ;
339
+ let mut res = check_associated_item ( tcx, def_id, span) ;
341
340
342
341
if matches ! ( trait_item. kind, hir:: TraitItemKind :: Fn ( ..) ) {
343
342
for & assoc_ty_def_id in tcx. associated_types_for_impl_traits_in_associated_fn ( def_id) {
344
343
res = res. and ( check_associated_item (
345
344
tcx,
346
345
assoc_ty_def_id. expect_local ( ) ,
347
346
tcx. def_span ( assoc_ty_def_id) ,
348
- None ,
349
347
) ) ;
350
348
}
351
349
}
@@ -829,13 +827,12 @@ fn check_impl_item<'tcx>(
829
827
tcx : TyCtxt < ' tcx > ,
830
828
impl_item : & ' tcx hir:: ImplItem < ' tcx > ,
831
829
) -> 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 {
834
831
// 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 ,
837
834
} ;
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)
839
836
}
840
837
841
838
fn 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
963
960
}
964
961
}
965
962
966
- #[ instrument( level = "debug" , skip( tcx, span, sig_if_method ) ) ]
963
+ #[ instrument( level = "debug" , skip( tcx, span) ) ]
967
964
fn check_associated_item (
968
965
tcx : TyCtxt < ' _ > ,
969
966
item_id : LocalDefId ,
970
967
span : Span ,
971
- sig_if_method : Option < & hir:: FnSig < ' _ > > ,
972
968
) -> Result < ( ) , ErrorGuaranteed > {
973
969
let loc = Some ( WellFormedLoc :: Ty ( item_id) ) ;
974
970
enter_wf_checking_ctxt ( tcx, item_id, |wfcx| {
@@ -1002,7 +998,8 @@ fn check_associated_item(
1002
998
}
1003
999
ty:: AssocKind :: Fn { .. } => {
1004
1000
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" ) ;
1006
1003
check_fn_or_method ( wfcx, sig, hir_sig. decl , item. def_id . expect_local ( ) ) ;
1007
1004
check_method_receiver ( wfcx, hir_sig, item, self_ty)
1008
1005
}
0 commit comments