@@ -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
}
@@ -825,13 +823,12 @@ fn check_impl_item<'tcx>(
825
823
tcx : TyCtxt < ' tcx > ,
826
824
impl_item : & ' tcx hir:: ImplItem < ' tcx > ,
827
825
) -> 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 {
830
827
// 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 ,
833
830
} ;
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)
835
832
}
836
833
837
834
fn 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
959
956
}
960
957
}
961
958
962
- #[ instrument( level = "debug" , skip( tcx, span, sig_if_method ) ) ]
959
+ #[ instrument( level = "debug" , skip( tcx, span) ) ]
963
960
fn check_associated_item (
964
961
tcx : TyCtxt < ' _ > ,
965
962
item_id : LocalDefId ,
966
963
span : Span ,
967
- sig_if_method : Option < & hir:: FnSig < ' _ > > ,
968
964
) -> Result < ( ) , ErrorGuaranteed > {
969
965
let loc = Some ( WellFormedLoc :: Ty ( item_id) ) ;
970
966
enter_wf_checking_ctxt ( tcx, item_id, |wfcx| {
@@ -998,7 +994,8 @@ fn check_associated_item(
998
994
}
999
995
ty:: AssocKind :: Fn { .. } => {
1000
996
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" ) ;
1002
999
check_fn_or_method ( wfcx, sig, hir_sig. decl , item. def_id . expect_local ( ) ) ;
1003
1000
check_method_receiver ( wfcx, hir_sig, item, self_ty)
1004
1001
}
0 commit comments