@@ -781,12 +781,13 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
781781 id. def_id,
782782 tcx. def_path_str( id. def_id. to_def_id( ) )
783783 ) ;
784+ let item_span = tcx. def_span ( id. def_id ) ;
784785 let _indenter = indenter ( ) ;
785786 match tcx. def_kind ( id. def_id ) {
786787 DefKind :: Static ( ..) => {
787788 tcx. ensure ( ) . typeck ( id. def_id ) ;
788- maybe_check_static_with_link_section ( tcx, id. def_id , tcx . def_span ( id . def_id ) ) ;
789- check_static_inhabited ( tcx, id. def_id , tcx . def_span ( id . def_id ) ) ;
789+ maybe_check_static_with_link_section ( tcx, id. def_id , item_span ) ;
790+ check_static_inhabited ( tcx, id. def_id , item_span ) ;
790791 }
791792 DefKind :: Const => {
792793 tcx. ensure ( ) . typeck ( id. def_id ) ;
@@ -796,7 +797,7 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
796797 let hir:: ItemKind :: Enum ( ref enum_definition, _) = item. kind else {
797798 return ;
798799 } ;
799- check_enum ( tcx, item . span , & enum_definition. variants , item. def_id ) ;
800+ check_enum ( tcx, item_span , & enum_definition. variants , item. def_id ) ;
800801 }
801802 DefKind :: Fn => { } // entirely within check_item_body
802803 DefKind :: Impl => {
@@ -847,10 +848,10 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
847848 }
848849 }
849850 DefKind :: Struct => {
850- check_struct ( tcx, id. def_id , tcx . def_span ( id . def_id ) ) ;
851+ check_struct ( tcx, id. def_id , item_span ) ;
851852 }
852853 DefKind :: Union => {
853- check_union ( tcx, id. def_id , tcx . def_span ( id . def_id ) ) ;
854+ check_union ( tcx, id. def_id , item_span ) ;
854855 }
855856 DefKind :: OpaqueTy => {
856857 let item = tcx. hir ( ) . item ( id) ;
@@ -863,7 +864,7 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
863864 // See https://github.com/rust-lang/rust/issues/75100
864865 if !tcx. sess . opts . actually_rustdoc {
865866 let substs = InternalSubsts :: identity_for_item ( tcx, item. def_id . to_def_id ( ) ) ;
866- check_opaque ( tcx, item. def_id , substs, item . span , & origin) ;
867+ check_opaque ( tcx, item. def_id , substs, item_span , & origin) ;
867868 }
868869 }
869870 DefKind :: TyAlias => {
@@ -1328,7 +1329,6 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, sp: Span, adt: ty::AdtD
13281329 if !adt. repr ( ) . transparent ( ) {
13291330 return ;
13301331 }
1331- let sp = tcx. sess . source_map ( ) . guess_head_span ( sp) ;
13321332
13331333 if adt. is_union ( ) && !tcx. features ( ) . transparent_unions {
13341334 feature_err (
0 commit comments