@@ -509,14 +509,6 @@ impl<'a, 'tcx> SpecializedDecoder<Span> for DecodeContext<'a, 'tcx> {
509
509
}
510
510
}
511
511
512
- impl SpecializedDecoder < Ident > for DecodeContext < ' _ , ' _ > {
513
- fn specialized_decode ( & mut self ) -> Result < Ident , Self :: Error > {
514
- // FIXME(jseyfried): intercrate hygiene
515
-
516
- Ok ( Ident :: with_dummy_span ( Symbol :: decode ( self ) ?) )
517
- }
518
- }
519
-
520
512
impl < ' a , ' tcx > SpecializedDecoder < Fingerprint > for DecodeContext < ' a , ' tcx > {
521
513
fn specialized_decode ( & mut self ) -> Result < Fingerprint , Self :: Error > {
522
514
Fingerprint :: decode_opaque ( & mut self . opaque )
@@ -663,15 +655,27 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
663
655
& self . raw_proc_macros . unwrap ( ) [ pos]
664
656
}
665
657
666
- fn item_name ( & self , item_index : DefIndex ) -> Symbol {
658
+ fn item_ident ( & self , item_index : DefIndex , sess : & Session ) -> Ident {
667
659
if !self . is_proc_macro ( item_index) {
668
- self . def_key ( item_index)
660
+ let name = self
661
+ . def_key ( item_index)
669
662
. disambiguated_data
670
663
. data
671
664
. get_opt_name ( )
672
- . expect ( "no name in item_name" )
665
+ . expect ( "no name in item_ident" ) ;
666
+ let span = self
667
+ . root
668
+ . per_def
669
+ . ident_span
670
+ . get ( self , item_index)
671
+ . map ( |data| data. decode ( ( self , sess) ) )
672
+ . unwrap_or_else ( || panic ! ( "Missing ident span for {:?} ({:?})" , name, item_index) ) ;
673
+ Ident :: new ( name, span)
673
674
} else {
674
- Symbol :: intern ( self . raw_proc_macro ( item_index) . name ( ) )
675
+ Ident :: new (
676
+ Symbol :: intern ( self . raw_proc_macro ( item_index) . name ( ) ) ,
677
+ self . get_span ( item_index, sess) ,
678
+ )
675
679
}
676
680
}
677
681
@@ -750,6 +754,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
750
754
kind : & EntryKind ,
751
755
index : DefIndex ,
752
756
parent_did : DefId ,
757
+ sess : & Session ,
753
758
) -> ty:: VariantDef {
754
759
let data = match kind {
755
760
EntryKind :: Variant ( data) | EntryKind :: Struct ( data, _) | EntryKind :: Union ( data, _) => {
@@ -771,7 +776,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
771
776
772
777
ty:: VariantDef :: new (
773
778
tcx,
774
- Ident :: with_dummy_span ( self . item_name ( index) ) ,
779
+ self . item_ident ( index, sess ) ,
775
780
variant_did,
776
781
ctor_did,
777
782
data. discr ,
@@ -783,7 +788,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
783
788
. decode ( self )
784
789
. map ( |index| ty:: FieldDef {
785
790
did : self . local_def_id ( index) ,
786
- ident : Ident :: with_dummy_span ( self . item_name ( index) ) ,
791
+ ident : self . item_ident ( index, sess ) ,
787
792
vis : self . get_visibility ( index) ,
788
793
} )
789
794
. collect ( ) ,
@@ -812,10 +817,10 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
812
817
. get ( self , item_id)
813
818
. unwrap_or ( Lazy :: empty ( ) )
814
819
. decode ( self )
815
- . map ( |index| self . get_variant ( tcx, & self . kind ( index) , index, did) )
820
+ . map ( |index| self . get_variant ( tcx, & self . kind ( index) , index, did, tcx . sess ) )
816
821
. collect ( )
817
822
} else {
818
- std:: iter:: once ( self . get_variant ( tcx, & kind, item_id, did) ) . collect ( )
823
+ std:: iter:: once ( self . get_variant ( tcx, & kind, item_id, did, tcx . sess ) ) . collect ( )
819
824
} ;
820
825
821
826
tcx. alloc_adt_def ( did, adt_kind, variants, repr)
@@ -1007,7 +1012,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1007
1012
if let Some ( kind) = self . def_kind ( child_index) {
1008
1013
callback ( Export {
1009
1014
res : Res :: Def ( kind, self . local_def_id ( child_index) ) ,
1010
- ident : Ident :: with_dummy_span ( self . item_name ( child_index) ) ,
1015
+ ident : self . item_ident ( child_index, sess ) ,
1011
1016
vis : self . get_visibility ( child_index) ,
1012
1017
span : self
1013
1018
. root
@@ -1028,10 +1033,11 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1028
1033
1029
1034
let def_key = self . def_key ( child_index) ;
1030
1035
let span = self . get_span ( child_index, sess) ;
1031
- if let ( Some ( kind) , Some ( name) ) =
1032
- ( self . def_kind ( child_index) , def_key. disambiguated_data . data . get_opt_name ( ) )
1033
- {
1034
- let ident = Ident :: with_dummy_span ( name) ;
1036
+ if let ( Some ( kind) , true ) = (
1037
+ self . def_kind ( child_index) ,
1038
+ def_key. disambiguated_data . data . get_opt_name ( ) . is_some ( ) ,
1039
+ ) {
1040
+ let ident = self . item_ident ( child_index, sess) ;
1035
1041
let vis = self . get_visibility ( child_index) ;
1036
1042
let def_id = self . local_def_id ( child_index) ;
1037
1043
let res = Res :: Def ( kind, def_id) ;
@@ -1138,10 +1144,10 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1138
1144
}
1139
1145
}
1140
1146
1141
- fn get_associated_item ( & self , id : DefIndex ) -> ty:: AssocItem {
1147
+ fn get_associated_item ( & self , id : DefIndex , sess : & Session ) -> ty:: AssocItem {
1142
1148
let def_key = self . def_key ( id) ;
1143
1149
let parent = self . local_def_id ( def_key. parent . unwrap ( ) ) ;
1144
- let name = def_key . disambiguated_data . data . get_opt_name ( ) . unwrap ( ) ;
1150
+ let ident = self . item_ident ( id , sess ) ;
1145
1151
1146
1152
let ( kind, container, has_self) = match self . kind ( id) {
1147
1153
EntryKind :: AssocConst ( container, _, _) => ( ty:: AssocKind :: Const , container, false ) ,
@@ -1155,7 +1161,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1155
1161
} ;
1156
1162
1157
1163
ty:: AssocItem {
1158
- ident : Ident :: with_dummy_span ( name ) ,
1164
+ ident,
1159
1165
kind,
1160
1166
vis : self . get_visibility ( id) ,
1161
1167
defaultness : container. defaultness ( ) ,
@@ -1219,7 +1225,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
1219
1225
. get ( self , id)
1220
1226
. unwrap_or ( Lazy :: empty ( ) )
1221
1227
. decode ( self )
1222
- . map ( |index| respan ( self . get_span ( index, sess) , self . item_name ( index) ) )
1228
+ . map ( |index| respan ( self . get_span ( index, sess) , self . item_ident ( index, sess ) . name ) )
1223
1229
. collect ( )
1224
1230
}
1225
1231
0 commit comments