@@ -781,12 +781,13 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
781
781
id. def_id,
782
782
tcx. def_path_str( id. def_id. to_def_id( ) )
783
783
) ;
784
+ let item_span = tcx. def_span ( id. def_id ) ;
784
785
let _indenter = indenter ( ) ;
785
786
match tcx. def_kind ( id. def_id ) {
786
787
DefKind :: Static ( ..) => {
787
788
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 ) ;
790
791
}
791
792
DefKind :: Const => {
792
793
tcx. ensure ( ) . typeck ( id. def_id ) ;
@@ -796,7 +797,7 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
796
797
let hir:: ItemKind :: Enum ( ref enum_definition, _) = item. kind else {
797
798
return ;
798
799
} ;
799
- check_enum ( tcx, item . span , & enum_definition. variants , item. def_id ) ;
800
+ check_enum ( tcx, item_span , & enum_definition. variants , item. def_id ) ;
800
801
}
801
802
DefKind :: Fn => { } // entirely within check_item_body
802
803
DefKind :: Impl => {
@@ -847,10 +848,10 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
847
848
}
848
849
}
849
850
DefKind :: Struct => {
850
- check_struct ( tcx, id. def_id , tcx . def_span ( id . def_id ) ) ;
851
+ check_struct ( tcx, id. def_id , item_span ) ;
851
852
}
852
853
DefKind :: Union => {
853
- check_union ( tcx, id. def_id , tcx . def_span ( id . def_id ) ) ;
854
+ check_union ( tcx, id. def_id , item_span ) ;
854
855
}
855
856
DefKind :: OpaqueTy => {
856
857
let item = tcx. hir ( ) . item ( id) ;
@@ -863,7 +864,7 @@ fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, id: hir::ItemId) {
863
864
// See https://github.com/rust-lang/rust/issues/75100
864
865
if !tcx. sess . opts . actually_rustdoc {
865
866
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) ;
867
868
}
868
869
}
869
870
DefKind :: TyAlias => {
@@ -1328,7 +1329,6 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, sp: Span, adt: ty::AdtD
1328
1329
if !adt. repr ( ) . transparent ( ) {
1329
1330
return ;
1330
1331
}
1331
- let sp = tcx. sess . source_map ( ) . guess_head_span ( sp) ;
1332
1332
1333
1333
if adt. is_union ( ) && !tcx. features ( ) . transparent_unions {
1334
1334
feature_err (
0 commit comments