Skip to content

Commit 462e00b

Browse files
committed
rustc_metadata: rename index::Index to table::Table.
1 parent 4f59179 commit 462e00b

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
@@ -13,14 +13,14 @@ use log::debug;
1313
/// `0`. Whenever an index is visited, we fill in the
1414
/// appropriate spot by calling `record_position`. We should never
1515
/// visit the same index twice.
16-
pub struct Index<'tcx> {
16+
pub struct Table<'tcx> {
1717
positions: [Vec<u8>; 2],
1818
_marker: PhantomData<&'tcx ()>,
1919
}
2020

21-
impl Index<'tcx> {
21+
impl Table<'tcx> {
2222
pub fn new((max_index_lo, max_index_hi): (usize, usize)) -> Self {
23-
Index {
23+
Table {
2424
positions: [vec![0; max_index_lo * 4],
2525
vec![0; max_index_hi * 4]],
2626
_marker: PhantomData,
@@ -48,7 +48,7 @@ impl Index<'tcx> {
4848
write_le_u32(destination, position);
4949
}
5050

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

5454
// First we write the length of the lower range ...
@@ -64,12 +64,12 @@ impl Index<'tcx> {
6464
}
6565
}
6666

67-
impl Lazy<[Index<'tcx>]> {
67+
impl Lazy<[Table<'tcx>]> {
6868
/// Given the metadata, extract out the offset of a particular
6969
/// DefIndex (if any).
7070
#[inline(never)]
7171
pub fn lookup(&self, bytes: &[u8], def_index: DefIndex) -> Option<Lazy<Entry<'tcx>>> {
72-
debug!("Index::lookup: index={:?} len={:?}",
72+
debug!("Table::lookup: index={:?} len={:?}",
7373
def_index,
7474
self.meta);
7575

@@ -83,7 +83,7 @@ impl Lazy<[Index<'tcx>]> {
8383
};
8484

8585
let position = read_le_u32(&bytes[self.position.get() + (1 + i) * 4..]);
86-
debug!("Index::lookup: position={:?}", position);
86+
debug!("Table::lookup: position={:?}", position);
8787
NonZeroUsize::new(position as usize).map(Lazy::from_position)
8888
}
8989
}

0 commit comments

Comments
 (0)