@@ -328,23 +328,14 @@ fn check_trait_item<'tcx>(
328328) -> Result < ( ) , ErrorGuaranteed > {
329329 let def_id = trait_item. owner_id . def_id ;
330330
331- let span = match trait_item. kind {
332- hir:: TraitItemKind :: Type ( _bounds, Some ( ty) ) => ty. span ,
333- _ => trait_item. span ,
334- } ;
335-
336331 // Check that an item definition in a subtrait is shadowing a supertrait item.
337332 lint_item_shadowing_supertrait_item ( tcx, def_id) ;
338333
339- let mut res = check_associated_item ( tcx, def_id, span ) ;
334+ let mut res = check_associated_item ( tcx, def_id) ;
340335
341336 if matches ! ( trait_item. kind, hir:: TraitItemKind :: Fn ( ..) ) {
342337 for & assoc_ty_def_id in tcx. associated_types_for_impl_traits_in_associated_fn ( def_id) {
343- res = res. and ( check_associated_item (
344- tcx,
345- assoc_ty_def_id. expect_local ( ) ,
346- tcx. def_span ( assoc_ty_def_id) ,
347- ) ) ;
338+ res = res. and ( check_associated_item ( tcx, assoc_ty_def_id. expect_local ( ) ) ) ;
348339 }
349340 }
350341 res
@@ -823,12 +814,7 @@ fn check_impl_item<'tcx>(
823814 tcx : TyCtxt < ' tcx > ,
824815 impl_item : & ' tcx hir:: ImplItem < ' tcx > ,
825816) -> Result < ( ) , ErrorGuaranteed > {
826- let span = match impl_item. kind {
827- // Constrain binding and overflow error spans to `<Ty>` in `type foo = <Ty>`.
828- hir:: ImplItemKind :: Type ( ty) if ty. span != DUMMY_SP => ty. span ,
829- _ => impl_item. span ,
830- } ;
831- check_associated_item ( tcx, impl_item. owner_id . def_id , span)
817+ check_associated_item ( tcx, impl_item. owner_id . def_id )
832818}
833819
834820fn check_param_wf ( tcx : TyCtxt < ' _ > , param : & ty:: GenericParamDef ) -> Result < ( ) , ErrorGuaranteed > {
@@ -956,12 +942,8 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &ty::GenericParamDef) -> Result<(), Er
956942 }
957943}
958944
959- #[ instrument( level = "debug" , skip( tcx, span) ) ]
960- fn check_associated_item (
961- tcx : TyCtxt < ' _ > ,
962- item_id : LocalDefId ,
963- span : Span ,
964- ) -> Result < ( ) , ErrorGuaranteed > {
945+ #[ instrument( level = "debug" , skip( tcx) ) ]
946+ fn check_associated_item ( tcx : TyCtxt < ' _ > , item_id : LocalDefId ) -> Result < ( ) , ErrorGuaranteed > {
965947 let loc = Some ( WellFormedLoc :: Ty ( item_id) ) ;
966948 enter_wf_checking_ctxt ( tcx, item_id, |wfcx| {
967949 let item = tcx. associated_item ( item_id) ;
@@ -978,6 +960,8 @@ fn check_associated_item(
978960 }
979961 } ;
980962
963+ let span = tcx. def_span ( item_id) ;
964+
981965 match item. kind {
982966 ty:: AssocKind :: Const { .. } => {
983967 let ty = tcx. type_of ( item. def_id ) . instantiate_identity ( ) ;
0 commit comments