Skip to content

Commit 8eaef65

Browse files
committed
Remove unnecessary impl methods for CrateMetadata
1 parent fd86800 commit 8eaef65

File tree

3 files changed

+35
-92
lines changed

3 files changed

+35
-92
lines changed

src/librustc_metadata/creader.rs

+23-23
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ pub struct CrateLoader<'a> {
5656
fn dump_crates(cstore: &CStore) {
5757
info!("resolved crates:");
5858
cstore.iter_crate_data(|_, data| {
59-
info!(" name: {}", data.name());
59+
info!(" name: {}", data.root.name);
6060
info!(" cnum: {}", data.cnum);
61-
info!(" hash: {}", data.hash());
61+
info!(" hash: {}", data.root.hash);
6262
info!(" reqd: {:?}", *data.dep_kind.lock());
6363
let CrateSource { dylib, rlib, rmeta } = data.source.clone();
6464
dylib.map(|dl| info!(" dylib: {}", dl.0.display()));
@@ -111,7 +111,7 @@ impl<'a> CrateLoader<'a> {
111111
if data.name != name { return }
112112

113113
match hash {
114-
Some(hash) if *hash == data.hash() => { ret = Some(cnum); return }
114+
Some(hash) if *hash == data.root.hash => { ret = Some(cnum); return }
115115
Some(..) => return,
116116
None => {}
117117
}
@@ -170,9 +170,9 @@ impl<'a> CrateLoader<'a> {
170170

171171
// Check for conflicts with any crate loaded so far
172172
self.cstore.iter_crate_data(|_, other| {
173-
if other.name() == root.name && // same crate-name
174-
other.disambiguator() == root.disambiguator && // same crate-disambiguator
175-
other.hash() != root.hash { // but different SVH
173+
if other.root.name == root.name && // same crate-name
174+
other.root.disambiguator == root.disambiguator && // same crate-disambiguator
175+
other.root.hash != root.hash { // but different SVH
176176
span_fatal!(self.sess, span, E0523,
177177
"found two different crates with name `{}` that are \
178178
not distinguished by differing `-C metadata`. This \
@@ -341,7 +341,7 @@ impl<'a> CrateLoader<'a> {
341341
if locate_ctxt.triple == &self.sess.opts.target_triple {
342342
let mut result = LoadResult::Loaded(library);
343343
self.cstore.iter_crate_data(|cnum, data| {
344-
if data.name() == root.name && root.hash == data.hash() {
344+
if data.root.name == root.name && root.hash == data.root.hash {
345345
assert!(locate_ctxt.hash.is_none());
346346
info!("load success, going to previous cnum: {}", cnum);
347347
result = LoadResult::Previous(cnum);
@@ -635,12 +635,12 @@ impl<'a> CrateLoader<'a> {
635635

636636
self.cstore.iter_crate_data(|cnum, data| {
637637
needs_panic_runtime = needs_panic_runtime ||
638-
data.needs_panic_runtime();
639-
if data.is_panic_runtime() {
638+
data.root.needs_panic_runtime;
639+
if data.root.panic_runtime {
640640
// Inject a dependency from all #![needs_panic_runtime] to this
641641
// #![panic_runtime] crate.
642642
self.inject_dependency_if(cnum, "a panic runtime",
643-
&|data| data.needs_panic_runtime());
643+
&|data| data.root.needs_panic_runtime);
644644
runtime_found = runtime_found || *data.dep_kind.lock() == DepKind::Explicit;
645645
}
646646
});
@@ -677,19 +677,19 @@ impl<'a> CrateLoader<'a> {
677677

678678
// Sanity check the loaded crate to ensure it is indeed a panic runtime
679679
// and the panic strategy is indeed what we thought it was.
680-
if !data.is_panic_runtime() {
680+
if !data.root.panic_runtime {
681681
self.sess.err(&format!("the crate `{}` is not a panic runtime",
682682
name));
683683
}
684-
if data.panic_strategy() != desired_strategy {
684+
if data.root.panic_strategy != desired_strategy {
685685
self.sess.err(&format!("the crate `{}` does not have the panic \
686686
strategy `{}`",
687687
name, desired_strategy.desc()));
688688
}
689689

690690
self.sess.injected_panic_runtime.set(Some(cnum));
691691
self.inject_dependency_if(cnum, "a panic runtime",
692-
&|data| data.needs_panic_runtime());
692+
&|data| data.root.needs_panic_runtime);
693693
}
694694

695695
fn inject_sanitizer_runtime(&mut self) {
@@ -784,7 +784,7 @@ impl<'a> CrateLoader<'a> {
784784
PathKind::Crate, dep_kind);
785785

786786
// Sanity check the loaded crate to ensure it is indeed a sanitizer runtime
787-
if !data.is_sanitizer_runtime() {
787+
if !data.root.sanitizer_runtime {
788788
self.sess.err(&format!("the crate `{}` is not a sanitizer runtime",
789789
name));
790790
}
@@ -807,7 +807,7 @@ impl<'a> CrateLoader<'a> {
807807
PathKind::Crate, dep_kind);
808808

809809
// Sanity check the loaded crate to ensure it is indeed a profiler runtime
810-
if !data.is_profiler_runtime() {
810+
if !data.root.profiler_runtime {
811811
self.sess.err(&format!("the crate `profiler_builtins` is not \
812812
a profiler runtime"));
813813
}
@@ -824,7 +824,7 @@ impl<'a> CrateLoader<'a> {
824824
let mut needs_allocator = attr::contains_name(&krate.attrs,
825825
"needs_allocator");
826826
self.cstore.iter_crate_data(|_, data| {
827-
needs_allocator = needs_allocator || data.needs_allocator();
827+
needs_allocator = needs_allocator || data.root.needs_allocator;
828828
});
829829
if !needs_allocator {
830830
self.sess.injected_allocator.set(None);
@@ -866,7 +866,7 @@ impl<'a> CrateLoader<'a> {
866866
None
867867
};
868868
self.cstore.iter_crate_data(|_, data| {
869-
if !data.has_global_allocator() {
869+
if !data.root.has_global_allocator {
870870
return
871871
}
872872
match global_allocator {
@@ -875,14 +875,14 @@ impl<'a> CrateLoader<'a> {
875875
conflicts with this global \
876876
allocator in: {}",
877877
other_crate,
878-
data.name()));
878+
data.root.name));
879879
}
880880
Some(None) => {
881881
self.sess.err(&format!("the #[global_allocator] in this \
882882
crate conflicts with global \
883-
allocator in: {}", data.name()));
883+
allocator in: {}", data.root.name));
884884
}
885-
None => global_allocator = Some(Some(data.name())),
885+
None => global_allocator = Some(Some(data.root.name)),
886886
}
887887
});
888888
if global_allocator.is_some() {
@@ -944,7 +944,7 @@ impl<'a> CrateLoader<'a> {
944944
// error.
945945
let mut allocator = None;
946946
self.cstore.iter_crate_data(|_, data| {
947-
if allocator.is_none() && data.has_default_lib_allocator() {
947+
if allocator.is_none() && data.root.has_default_lib_allocator {
948948
allocator = Some(data.clone());
949949
}
950950
});
@@ -1020,9 +1020,9 @@ impl<'a> CrateLoader<'a> {
10201020
self.sess.err(&format!("the crate `{}` cannot depend \
10211021
on a crate that needs {}, but \
10221022
it depends on `{}`",
1023-
self.cstore.get_crate_data(krate).name(),
1023+
self.cstore.get_crate_data(krate).root.name,
10241024
what,
1025-
data.name()));
1025+
data.root.name));
10261026
}
10271027
}
10281028

src/librustc_metadata/cstore.rs

-57
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ use schema;
1515

1616
use rustc::hir::def_id::{CrateNum, DefIndex};
1717
use rustc::hir::map::definitions::DefPathTable;
18-
use rustc::hir::svh::Svh;
1918
use rustc::middle::cstore::{DepKind, ExternCrate, MetadataLoader};
20-
use rustc::session::CrateDisambiguator;
21-
use rustc_target::spec::PanicStrategy;
2219
use rustc_data_structures::indexed_vec::IndexVec;
2320
use rustc::util::nodemap::{FxHashMap, NodeMap};
2421

@@ -175,57 +172,3 @@ impl CStore {
175172
self.extern_mod_crate_map.borrow().get(&emod_id).cloned()
176173
}
177174
}
178-
179-
impl CrateMetadata {
180-
pub fn name(&self) -> Symbol {
181-
self.root.name
182-
}
183-
184-
pub fn hash(&self) -> Svh {
185-
self.root.hash
186-
}
187-
188-
pub fn disambiguator(&self) -> CrateDisambiguator {
189-
self.root.disambiguator
190-
}
191-
192-
pub fn needs_allocator(&self) -> bool {
193-
self.root.needs_allocator
194-
}
195-
196-
pub fn has_global_allocator(&self) -> bool {
197-
self.root.has_global_allocator
198-
}
199-
200-
pub fn has_default_lib_allocator(&self) -> bool {
201-
self.root.has_default_lib_allocator
202-
}
203-
204-
pub fn is_panic_runtime(&self) -> bool {
205-
self.root.panic_runtime
206-
}
207-
208-
pub fn needs_panic_runtime(&self) -> bool {
209-
self.root.needs_panic_runtime
210-
}
211-
212-
pub fn is_compiler_builtins(&self) -> bool {
213-
self.root.compiler_builtins
214-
}
215-
216-
pub fn is_sanitizer_runtime(&self) -> bool {
217-
self.root.sanitizer_runtime
218-
}
219-
220-
pub fn is_profiler_runtime(&self) -> bool {
221-
self.root.profiler_runtime
222-
}
223-
224-
pub fn is_no_builtins(&self) -> bool {
225-
self.root.no_builtins
226-
}
227-
228-
pub fn panic_strategy(&self) -> PanicStrategy {
229-
self.root.panic_strategy
230-
}
231-
}

src/librustc_metadata/cstore_impl.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,17 @@ provide! { <'tcx> tcx, def_id, other, cdata,
169169
is_mir_available => { cdata.is_item_mir_available(def_id.index) }
170170

171171
dylib_dependency_formats => { Lrc::new(cdata.get_dylib_dependency_formats()) }
172-
is_panic_runtime => { cdata.is_panic_runtime() }
173-
is_compiler_builtins => { cdata.is_compiler_builtins() }
174-
has_global_allocator => { cdata.has_global_allocator() }
175-
is_sanitizer_runtime => { cdata.is_sanitizer_runtime() }
176-
is_profiler_runtime => { cdata.is_profiler_runtime() }
177-
panic_strategy => { cdata.panic_strategy() }
172+
is_panic_runtime => { cdata.root.panic_runtime }
173+
is_compiler_builtins => { cdata.root.compiler_builtins }
174+
has_global_allocator => { cdata.root.has_global_allocator }
175+
is_sanitizer_runtime => { cdata.root.sanitizer_runtime }
176+
is_profiler_runtime => { cdata.root.profiler_runtime }
177+
panic_strategy => { cdata.root.panic_strategy }
178178
extern_crate => {
179179
let r = Lrc::new(*cdata.extern_crate.lock());
180180
r
181181
}
182-
is_no_builtins => { cdata.is_no_builtins() }
182+
is_no_builtins => { cdata.root.no_builtins }
183183
impl_defaultness => { cdata.get_impl_defaultness(def_id.index) }
184184
reachable_non_generics => {
185185
let reachable_non_generics = tcx
@@ -208,9 +208,9 @@ provide! { <'tcx> tcx, def_id, other, cdata,
208208
DefId { krate: def_id.krate, index }
209209
})
210210
}
211-
crate_disambiguator => { cdata.disambiguator() }
212-
crate_hash => { cdata.hash() }
213-
original_crate_name => { cdata.name() }
211+
crate_disambiguator => { cdata.root.disambiguator }
212+
crate_hash => { cdata.root.hash }
213+
original_crate_name => { cdata.root.name }
214214

215215
extra_filename => { cdata.root.extra_filename.clone() }
216216

@@ -456,12 +456,12 @@ impl CrateStore for cstore::CStore {
456456

457457
fn crate_disambiguator_untracked(&self, cnum: CrateNum) -> CrateDisambiguator
458458
{
459-
self.get_crate_data(cnum).disambiguator()
459+
self.get_crate_data(cnum).root.disambiguator
460460
}
461461

462462
fn crate_hash_untracked(&self, cnum: CrateNum) -> hir::svh::Svh
463463
{
464-
self.get_crate_data(cnum).hash()
464+
self.get_crate_data(cnum).root.hash
465465
}
466466

467467
/// Returns the `DefKey` for a given `DefId`. This indicates the

0 commit comments

Comments
 (0)