Skip to content

Commit 98e04ba

Browse files
committed
rustc_metadata: rename index::Index to table::Table.
1 parent 51c5e5f commit 98e04ba

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

src/librustc_metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ impl<'a, 'tcx> CrateMetadata {
486486

487487
fn maybe_entry(&self, item_id: DefIndex) -> Option<Lazy<Entry<'tcx>>> {
488488
assert!(!self.is_proc_macro(item_id));
489-
self.root.entries_index.lookup(self.blob.raw_bytes(), item_id)
489+
self.root.entries_table.lookup(self.blob.raw_bytes(), item_id)
490490
}
491491

492492
fn entry(&self, item_id: DefIndex) -> Entry<'tcx> {

src/librustc_metadata/encoder.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::index::Index;
21
use crate::schema::*;
2+
use crate::table::Table;
33

44
use rustc::middle::cstore::{LinkagePreference, NativeLibrary,
55
EncodedMetadata, ForeignModule};
@@ -45,7 +45,7 @@ pub struct EncodeContext<'a, 'tcx: 'a> {
4545
opaque: opaque::Encoder,
4646
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
4747

48-
entries_index: Index<'tcx>,
48+
entries_table: Table<'tcx>,
4949

5050
lazy_state: LazyState,
5151
type_shorthands: FxHashMap<Ty<'tcx>, usize>,
@@ -316,7 +316,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
316316

317317
let entry = op(self, data);
318318
let entry = self.lazy(entry);
319-
self.entries_index.record(id, entry);
319+
self.entries_table.record(id, entry);
320320
}
321321

322322
fn encode_info_for_items(&mut self) {
@@ -460,8 +460,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
460460
};
461461

462462
i = self.position();
463-
let entries_index = self.entries_index.write_index(&mut self.opaque);
464-
let entries_index_bytes = self.position() - i;
463+
let entries_table = self.entries_table.encode(&mut self.opaque);
464+
let entries_table_bytes = self.position() - i;
465465

466466
let attrs = tcx.hir().krate_attrs();
467467
let is_proc_macro = tcx.sess.crate_types.borrow().contains(&CrateType::ProcMacro);
@@ -512,7 +512,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
512512
impls,
513513
exported_symbols,
514514
interpret_alloc_index,
515-
entries_index,
515+
entries_table,
516516
});
517517

518518
let total_bytes = self.position();
@@ -535,7 +535,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
535535
println!(" exp. symbols bytes: {}", exported_symbols_bytes);
536536
println!(" def-path table bytes: {}", def_path_table_bytes);
537537
println!(" item bytes: {}", item_bytes);
538-
println!(" entries index bytes: {}", entries_index_bytes);
538+
println!(" entries table bytes: {}", entries_table_bytes);
539539
println!(" zero bytes: {}", zero_bytes);
540540
println!(" total bytes: {}", total_bytes);
541541
}
@@ -1875,7 +1875,7 @@ pub fn encode_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
18751875
let mut ecx = EncodeContext {
18761876
opaque: encoder,
18771877
tcx,
1878-
entries_index: Index::new(tcx.hir().definitions().def_index_counts_lo_hi()),
1878+
entries_table: Table::new(tcx.hir().definitions().def_index_counts_lo_hi()),
18791879
lazy_state: LazyState::NoNode,
18801880
type_shorthands: Default::default(),
18811881
predicate_shorthands: Default::default(),

src/librustc_metadata/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ extern crate rustc_data_structures;
2929

3030
mod diagnostics;
3131

32-
mod index;
3332
mod encoder;
3433
mod decoder;
3534
mod cstore_impl;
36-
mod schema;
37-
mod native_libs;
38-
mod link_args;
3935
mod foreign_modules;
36+
mod link_args;
37+
mod native_libs;
38+
mod schema;
39+
mod table;
4040

4141
pub mod creader;
4242
pub mod cstore;

src/librustc_metadata/schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::index;
1+
use crate::table::Table;
22

33
use rustc::hir;
44
use rustc::hir::def::{self, CtorKind};
@@ -184,7 +184,7 @@ pub struct CrateRoot<'tcx> {
184184
pub exported_symbols: Lazy<[(ExportedSymbol<'tcx>, SymbolExportLevel)]>,
185185
pub interpret_alloc_index: Lazy<[u32]>,
186186

187-
pub entries_index: Lazy<[index::Index<'tcx>]>,
187+
pub entries_table: Lazy<[Table<'tcx>]>,
188188

189189
pub compiler_builtins: bool,
190190
pub needs_allocator: bool,

src/librustc_metadata/index.rs renamed to src/librustc_metadata/table.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ impl FixedSizeEncoding for u32 {
7575
/// `0`. Whenever an index is visited, we fill in the
7676
/// appropriate spot by calling `record_position`. We should never
7777
/// visit the same index twice.
78-
pub struct Index<'tcx> {
78+
pub struct Table<'tcx> {
7979
positions: [Vec<u8>; 2],
8080
_marker: PhantomData<&'tcx ()>,
8181
}
8282

83-
impl Index<'tcx> {
83+
impl Table<'tcx> {
8484
pub fn new((max_index_lo, max_index_hi): (usize, usize)) -> Self {
85-
Index {
85+
Table {
8686
positions: [vec![0; max_index_lo * 4],
8787
vec![0; max_index_hi * 4]],
8888
_marker: PhantomData,
@@ -110,7 +110,7 @@ impl Index<'tcx> {
110110
position.write_to_bytes_at(positions, array_index)
111111
}
112112

113-
pub fn write_index(&self, buf: &mut Encoder) -> Lazy<[Self]> {
113+
pub fn encode(&self, buf: &mut Encoder) -> Lazy<[Self]> {
114114
let pos = buf.position();
115115

116116
// First we write the length of the lower range ...
@@ -126,13 +126,13 @@ impl Index<'tcx> {
126126
}
127127
}
128128

129-
impl Lazy<[Index<'tcx>]> {
129+
impl Lazy<[Table<'tcx>]> {
130130
/// Given the metadata, extract out the offset of a particular
131131
/// DefIndex (if any).
132132
#[inline(never)]
133133
pub fn lookup(&self, bytes: &[u8], def_index: DefIndex) -> Option<Lazy<Entry<'tcx>>> {
134134
let bytes = &bytes[self.position.get()..];
135-
debug!("Index::lookup: index={:?} len={:?}",
135+
debug!("Table::lookup: index={:?} len={:?}",
136136
def_index,
137137
self.meta);
138138

@@ -146,7 +146,7 @@ impl Lazy<[Index<'tcx>]> {
146146
};
147147

148148
let position = u32::read_from_bytes_at(bytes, 1 + i);
149-
debug!("Index::lookup: position={:?}", position);
149+
debug!("Table::lookup: position={:?}", position);
150150
NonZeroUsize::new(position as usize).map(Lazy::from_position)
151151
}
152152
}

0 commit comments

Comments
 (0)