Skip to content

Commit f492740

Browse files
committed
rustc_metadata: rename index::Index to table::Table.
1 parent 83b3c39 commit f492740

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

src/librustc_metadata/decoder.rs

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

474474
fn maybe_entry(&self, item_id: DefIndex) -> Option<Lazy<Entry<'tcx>>> {
475-
self.root.entries_index.lookup(self.blob.raw_bytes(), item_id)
475+
self.root.entries_table.lookup(self.blob.raw_bytes(), item_id)
476476
}
477477

478478
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};
@@ -47,7 +47,7 @@ struct EncodeContext<'tcx> {
4747
opaque: opaque::Encoder,
4848
tcx: TyCtxt<'tcx>,
4949

50-
entries_index: Index<'tcx>,
50+
entries_table: Table<'tcx>,
5151

5252
lazy_state: LazyState,
5353
type_shorthands: FxHashMap<Ty<'tcx>, usize>,
@@ -325,7 +325,7 @@ impl<'tcx> EncodeContext<'tcx> {
325325

326326
let entry = op(self, data);
327327
let entry = self.lazy(entry);
328-
self.entries_index.record(id, entry);
328+
self.entries_table.record(id, entry);
329329
}
330330

331331
fn encode_info_for_items(&mut self) {
@@ -477,8 +477,8 @@ impl<'tcx> EncodeContext<'tcx> {
477477

478478

479479
i = self.position();
480-
let entries_index = self.entries_index.write_index(&mut self.opaque);
481-
let entries_index_bytes = self.position() - i;
480+
let entries_table = self.entries_table.encode(&mut self.opaque);
481+
let entries_table_bytes = self.position() - i;
482482

483483
// Encode the proc macro data
484484
i = self.position();
@@ -537,7 +537,7 @@ impl<'tcx> EncodeContext<'tcx> {
537537
impls,
538538
exported_symbols,
539539
interpret_alloc_index,
540-
entries_index,
540+
entries_table,
541541
});
542542

543543
let total_bytes = self.position();
@@ -562,7 +562,7 @@ impl<'tcx> EncodeContext<'tcx> {
562562
println!(" def-path table bytes: {}", def_path_table_bytes);
563563
println!(" proc-macro-data-bytes: {}", proc_macro_data_bytes);
564564
println!(" item bytes: {}", item_bytes);
565-
println!(" entries index bytes: {}", entries_index_bytes);
565+
println!(" entries table bytes: {}", entries_table_bytes);
566566
println!(" zero bytes: {}", zero_bytes);
567567
println!(" total bytes: {}", total_bytes);
568568
}
@@ -1916,7 +1916,7 @@ crate fn encode_metadata(tcx: TyCtxt<'_>) -> EncodedMetadata {
19161916
let mut ecx = EncodeContext {
19171917
opaque: encoder,
19181918
tcx,
1919-
entries_index: Index::new(tcx.hir().definitions().def_index_count()),
1919+
entries_table: Table::new(tcx.hir().definitions().def_index_count()),
19201920
lazy_state: LazyState::NoNode,
19211921
type_shorthands: Default::default(),
19221922
predicate_shorthands: Default::default(),

src/librustc_metadata/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ extern crate rustc_data_structures;
2626

2727
pub mod error_codes;
2828

29-
mod index;
3029
mod encoder;
3130
mod decoder;
31+
mod dependency_format;
3232
mod cstore_impl;
33-
mod schema;
34-
mod native_libs;
35-
mod link_args;
3633
mod foreign_modules;
37-
mod dependency_format;
34+
mod link_args;
35+
mod native_libs;
36+
mod schema;
37+
mod table;
3838

3939
pub mod creader;
4040
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};
@@ -186,7 +186,7 @@ crate struct CrateRoot<'tcx> {
186186
pub exported_symbols: Lazy<[(ExportedSymbol<'tcx>, SymbolExportLevel)]>,
187187
pub interpret_alloc_index: Lazy<[u32]>,
188188

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

191191
/// The DefIndex's of any proc macros delcared by
192192
/// this crate

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
@@ -76,14 +76,14 @@ impl FixedSizeEncoding for u32 {
7676
/// `0`. Whenever an index is visited, we fill in the
7777
/// appropriate spot by calling `record_position`. We should never
7878
/// visit the same index twice.
79-
crate struct Index<'tcx> {
79+
crate struct Table<'tcx> {
8080
positions: Vec<u8>,
8181
_marker: PhantomData<&'tcx ()>,
8282
}
8383

84-
impl Index<'tcx> {
84+
impl Table<'tcx> {
8585
crate fn new(max_index: usize) -> Self {
86-
Index {
86+
Table {
8787
positions: vec![0; max_index * 4],
8888
_marker: PhantomData,
8989
}
@@ -108,7 +108,7 @@ impl Index<'tcx> {
108108
position.write_to_bytes_at(positions, array_index)
109109
}
110110

111-
crate fn write_index(&self, buf: &mut Encoder) -> Lazy<[Self]> {
111+
crate fn encode(&self, buf: &mut Encoder) -> Lazy<[Self]> {
112112
let pos = buf.position();
113113
buf.emit_raw_bytes(&self.positions);
114114
Lazy::from_position_and_meta(
@@ -118,18 +118,18 @@ impl Index<'tcx> {
118118
}
119119
}
120120

121-
impl Lazy<[Index<'tcx>]> {
121+
impl Lazy<[Table<'tcx>]> {
122122
/// Given the metadata, extract out the offset of a particular
123123
/// DefIndex (if any).
124124
#[inline(never)]
125125
crate fn lookup(&self, bytes: &[u8], def_index: DefIndex) -> Option<Lazy<Entry<'tcx>>> {
126-
debug!("Index::lookup: index={:?} len={:?}",
126+
debug!("Table::lookup: index={:?} len={:?}",
127127
def_index,
128128
self.meta);
129129

130130
let bytes = &bytes[self.position.get()..][..self.meta * 4];
131131
let position = u32::read_from_bytes_at(bytes, def_index.index());
132-
debug!("Index::lookup: position={:?}", position);
132+
debug!("Table::lookup: position={:?}", position);
133133
NonZeroUsize::new(position as usize).map(Lazy::from_position)
134134
}
135135
}

0 commit comments

Comments
 (0)