@@ -509,14 +509,6 @@ impl<'a, 'tcx> SpecializedDecoder<Span> for DecodeContext<'a, 'tcx> {
509509 }
510510}
511511
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-
520512impl < ' a , ' tcx > SpecializedDecoder < Fingerprint > for DecodeContext < ' a , ' tcx > {
521513 fn specialized_decode ( & mut self ) -> Result < Fingerprint , Self :: Error > {
522514 Fingerprint :: decode_opaque ( & mut self . opaque )
@@ -663,15 +655,27 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
663655 & self . raw_proc_macros . unwrap ( ) [ pos]
664656 }
665657
666- fn item_name ( & self , item_index : DefIndex ) -> Symbol {
658+ fn item_ident ( & self , item_index : DefIndex , sess : & Session ) -> Ident {
667659 if !self . is_proc_macro ( item_index) {
668- self . def_key ( item_index)
660+ let name = self
661+ . def_key ( item_index)
669662 . disambiguated_data
670663 . data
671664 . 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)
673674 } 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+ )
675679 }
676680 }
677681
@@ -750,6 +754,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
750754 kind : & EntryKind ,
751755 index : DefIndex ,
752756 parent_did : DefId ,
757+ sess : & Session ,
753758 ) -> ty:: VariantDef {
754759 let data = match kind {
755760 EntryKind :: Variant ( data) | EntryKind :: Struct ( data, _) | EntryKind :: Union ( data, _) => {
@@ -771,7 +776,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
771776
772777 ty:: VariantDef :: new (
773778 tcx,
774- Ident :: with_dummy_span ( self . item_name ( index) ) ,
779+ self . item_ident ( index, sess ) ,
775780 variant_did,
776781 ctor_did,
777782 data. discr ,
@@ -783,7 +788,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
783788 . decode ( self )
784789 . map ( |index| ty:: FieldDef {
785790 did : self . local_def_id ( index) ,
786- ident : Ident :: with_dummy_span ( self . item_name ( index) ) ,
791+ ident : self . item_ident ( index, sess ) ,
787792 vis : self . get_visibility ( index) ,
788793 } )
789794 . collect ( ) ,
@@ -812,10 +817,10 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
812817 . get ( self , item_id)
813818 . unwrap_or ( Lazy :: empty ( ) )
814819 . 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 ) )
816821 . collect ( )
817822 } 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 ( )
819824 } ;
820825
821826 tcx. alloc_adt_def ( did, adt_kind, variants, repr)
@@ -1007,7 +1012,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
10071012 if let Some ( kind) = self . def_kind ( child_index) {
10081013 callback ( Export {
10091014 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 ) ,
10111016 vis : self . get_visibility ( child_index) ,
10121017 span : self
10131018 . root
@@ -1028,10 +1033,11 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
10281033
10291034 let def_key = self . def_key ( child_index) ;
10301035 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) ;
10351041 let vis = self . get_visibility ( child_index) ;
10361042 let def_id = self . local_def_id ( child_index) ;
10371043 let res = Res :: Def ( kind, def_id) ;
@@ -1138,10 +1144,10 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
11381144 }
11391145 }
11401146
1141- fn get_associated_item ( & self , id : DefIndex ) -> ty:: AssocItem {
1147+ fn get_associated_item ( & self , id : DefIndex , sess : & Session ) -> ty:: AssocItem {
11421148 let def_key = self . def_key ( id) ;
11431149 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 ) ;
11451151
11461152 let ( kind, container, has_self) = match self . kind ( id) {
11471153 EntryKind :: AssocConst ( container, _, _) => ( ty:: AssocKind :: Const , container, false ) ,
@@ -1155,7 +1161,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
11551161 } ;
11561162
11571163 ty:: AssocItem {
1158- ident : Ident :: with_dummy_span ( name ) ,
1164+ ident,
11591165 kind,
11601166 vis : self . get_visibility ( id) ,
11611167 defaultness : container. defaultness ( ) ,
@@ -1219,7 +1225,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
12191225 . get ( self , id)
12201226 . unwrap_or ( Lazy :: empty ( ) )
12211227 . 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 ) )
12231229 . collect ( )
12241230 }
12251231
0 commit comments