11use crate :: rmeta:: * ;
2- use crate :: rmeta:: table:: { FixedSizeEncoding , PerDefTable } ;
2+ use crate :: rmeta:: table:: { FixedSizeEncoding , Table } ;
33
44use rustc:: middle:: cstore:: { LinkagePreference , NativeLibrary ,
55 EncodedMetadata , ForeignModule } ;
@@ -8,7 +8,7 @@ use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefIndex, DefId, LocalDefId,
88use rustc:: hir:: { GenericParamKind , AnonConst } ;
99use rustc:: hir:: map:: definitions:: DefPathTable ;
1010use rustc_data_structures:: fingerprint:: Fingerprint ;
11- use rustc_index:: vec:: IndexVec ;
11+ use rustc_index:: vec:: { Idx , IndexVec } ;
1212use rustc:: middle:: dependency_format:: Linkage ;
1313use rustc:: middle:: exported_symbols:: { ExportedSymbol , SymbolExportLevel ,
1414 metadata_symbol_name} ;
@@ -62,26 +62,26 @@ struct EncodeContext<'tcx> {
6262
6363#[ derive( Default ) ]
6464struct PerDefTables < ' tcx > {
65- kind : PerDefTable < Lazy < EntryKind < ' tcx > > > ,
66- visibility : PerDefTable < Lazy < ty:: Visibility > > ,
67- span : PerDefTable < Lazy < Span > > ,
68- attributes : PerDefTable < Lazy < [ ast:: Attribute ] > > ,
69- children : PerDefTable < Lazy < [ DefIndex ] > > ,
70- stability : PerDefTable < Lazy < attr:: Stability > > ,
71- deprecation : PerDefTable < Lazy < attr:: Deprecation > > ,
72-
73- ty : PerDefTable < Lazy < Ty < ' tcx > > > ,
74- fn_sig : PerDefTable < Lazy < ty:: PolyFnSig < ' tcx > > > ,
75- impl_trait_ref : PerDefTable < Lazy < ty:: TraitRef < ' tcx > > > ,
76- inherent_impls : PerDefTable < Lazy < [ DefIndex ] > > ,
77- variances : PerDefTable < Lazy < [ ty:: Variance ] > > ,
78- generics : PerDefTable < Lazy < ty:: Generics > > ,
79- explicit_predicates : PerDefTable < Lazy < ty:: GenericPredicates < ' tcx > > > ,
80- inferred_outlives : PerDefTable < Lazy < & ' tcx [ ( ty:: Predicate < ' tcx > , Span ) ] > > ,
81- super_predicates : PerDefTable < Lazy < ty:: GenericPredicates < ' tcx > > > ,
82-
83- mir : PerDefTable < Lazy < mir:: Body < ' tcx > > > ,
84- promoted_mir : PerDefTable < Lazy < IndexVec < mir:: Promoted , mir:: Body < ' tcx > > > > ,
65+ kind : Table < DefIndex , Lazy < EntryKind < ' tcx > > > ,
66+ visibility : Table < DefIndex , Lazy < ty:: Visibility > > ,
67+ span : Table < DefIndex , Lazy < Span > > ,
68+ attributes : Table < DefIndex , Lazy < [ ast:: Attribute ] > > ,
69+ children : Table < DefIndex , Lazy < [ DefIndex ] > > ,
70+ stability : Table < DefIndex , Lazy < attr:: Stability > > ,
71+ deprecation : Table < DefIndex , Lazy < attr:: Deprecation > > ,
72+
73+ ty : Table < DefIndex , Lazy < Ty < ' tcx > > > ,
74+ fn_sig : Table < DefIndex , Lazy < ty:: PolyFnSig < ' tcx > > > ,
75+ impl_trait_ref : Table < DefIndex , Lazy < ty:: TraitRef < ' tcx > > > ,
76+ inherent_impls : Table < DefIndex , Lazy < [ DefIndex ] > > ,
77+ variances : Table < DefIndex , Lazy < [ ty:: Variance ] > > ,
78+ generics : Table < DefIndex , Lazy < ty:: Generics > > ,
79+ explicit_predicates : Table < DefIndex , Lazy < ty:: GenericPredicates < ' tcx > > > ,
80+ inferred_outlives : Table < DefIndex , Lazy < & ' tcx [ ( ty:: Predicate < ' tcx > , Span ) ] > > ,
81+ super_predicates : Table < DefIndex , Lazy < ty:: GenericPredicates < ' tcx > > > ,
82+
83+ mir : Table < DefIndex , Lazy < mir:: Body < ' tcx > > > ,
84+ promoted_mir : Table < DefIndex , Lazy < IndexVec < mir:: Promoted , mir:: Body < ' tcx > > > > ,
8585}
8686
8787macro_rules! encoder_methods {
@@ -138,10 +138,10 @@ impl<'tcx, T: Encodable> SpecializedEncoder<Lazy<[T]>> for EncodeContext<'tcx> {
138138 }
139139}
140140
141- impl < ' tcx , T > SpecializedEncoder < Lazy < PerDefTable < T > > > for EncodeContext < ' tcx >
141+ impl < ' tcx , I : Idx , T > SpecializedEncoder < Lazy < Table < I , T > > > for EncodeContext < ' tcx >
142142 where Option < T > : FixedSizeEncoding ,
143143{
144- fn specialized_encode ( & mut self , lazy : & Lazy < PerDefTable < T > > ) -> Result < ( ) , Self :: Error > {
144+ fn specialized_encode ( & mut self , lazy : & Lazy < Table < I , T > > ) -> Result < ( ) , Self :: Error > {
145145 self . emit_usize ( lazy. meta ) ?;
146146 self . emit_lazy_distance ( * lazy)
147147 }
@@ -307,14 +307,14 @@ impl<I, T: Encodable> EncodeContentsForLazy<[T]> for I
307307 }
308308}
309309
310- // Shorthand for `$self.$tables.$table.set($key , $self.lazy($value))`, which would
310+ // Shorthand for `$self.$tables.$table.set($def_id.index , $self.lazy($value))`, which would
311311// normally need extra variables to avoid errors about multiple mutable borrows.
312312macro_rules! record {
313- ( $self: ident. $tables: ident. $table: ident[ $key : expr] <- $value: expr) => { {
313+ ( $self: ident. $tables: ident. $table: ident[ $def_id : expr] <- $value: expr) => { {
314314 {
315315 let value = $value;
316316 let lazy = $self. lazy( value) ;
317- $self. $tables. $table. set( $key , lazy) ;
317+ $self. $tables. $table. set( $def_id . index , lazy) ;
318318 }
319319 } }
320320}
0 commit comments