Skip to content

Commit 55a00a9

Browse files
committed
Remove unnecessary impl methods for CrateMetadata
1 parent 680f3b2 commit 55a00a9

File tree

3 files changed

+36
-97
lines changed

3 files changed

+36
-97
lines changed

src/librustc_metadata/creader.rs

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

115115
match hash {
116-
Some(hash) if *hash == data.hash() => { ret = Some(cnum); return }
116+
Some(hash) if *hash == data.root.hash => { ret = Some(cnum); return }
117117
Some(..) => return,
118118
None => {}
119119
}
@@ -172,9 +172,9 @@ impl<'a> CrateLoader<'a> {
172172

173173
// Check for conflicts with any crate loaded so far
174174
self.cstore.iter_crate_data(|_, other| {
175-
if other.name() == root.name && // same crate-name
176-
other.disambiguator() == root.disambiguator && // same crate-disambiguator
177-
other.hash() != root.hash { // but different SVH
175+
if other.root.name == root.name && // same crate-name
176+
other.root.disambiguator == root.disambiguator && // same crate-disambiguator
177+
other.root.hash != root.hash { // but different SVH
178178
span_fatal!(self.sess, span, E0523,
179179
"found two different crates with name `{}` that are \
180180
not distinguished by differing `-C metadata`. This \
@@ -343,7 +343,7 @@ impl<'a> CrateLoader<'a> {
343343
if locate_ctxt.triple == &self.sess.opts.target_triple {
344344
let mut result = LoadResult::Loaded(library);
345345
self.cstore.iter_crate_data(|cnum, data| {
346-
if data.name() == root.name && root.hash == data.hash() {
346+
if data.root.name == root.name && root.hash == data.root.hash {
347347
assert!(locate_ctxt.hash.is_none());
348348
info!("load success, going to previous cnum: {}", cnum);
349349
result = LoadResult::Previous(cnum);
@@ -642,12 +642,12 @@ impl<'a> CrateLoader<'a> {
642642

643643
self.cstore.iter_crate_data(|cnum, data| {
644644
needs_panic_runtime = needs_panic_runtime ||
645-
data.needs_panic_runtime();
646-
if data.is_panic_runtime() {
645+
data.root.needs_panic_runtime;
646+
if data.root.panic_runtime {
647647
// Inject a dependency from all #![needs_panic_runtime] to this
648648
// #![panic_runtime] crate.
649649
self.inject_dependency_if(cnum, "a panic runtime",
650-
&|data| data.needs_panic_runtime());
650+
&|data| data.root.needs_panic_runtime);
651651
runtime_found = runtime_found || *data.dep_kind.lock() == DepKind::Explicit;
652652
}
653653
});
@@ -684,19 +684,19 @@ impl<'a> CrateLoader<'a> {
684684

685685
// Sanity check the loaded crate to ensure it is indeed a panic runtime
686686
// and the panic strategy is indeed what we thought it was.
687-
if !data.is_panic_runtime() {
687+
if !data.root.panic_runtime {
688688
self.sess.err(&format!("the crate `{}` is not a panic runtime",
689689
name));
690690
}
691-
if data.panic_strategy() != desired_strategy {
691+
if data.root.panic_strategy != desired_strategy {
692692
self.sess.err(&format!("the crate `{}` does not have the panic \
693693
strategy `{}`",
694694
name, desired_strategy.desc()));
695695
}
696696

697697
self.sess.injected_panic_runtime.set(Some(cnum));
698698
self.inject_dependency_if(cnum, "a panic runtime",
699-
&|data| data.needs_panic_runtime());
699+
&|data| data.root.needs_panic_runtime);
700700
}
701701

702702
fn inject_sanitizer_runtime(&mut self) {
@@ -791,7 +791,7 @@ impl<'a> CrateLoader<'a> {
791791
PathKind::Crate, dep_kind);
792792

793793
// Sanity check the loaded crate to ensure it is indeed a sanitizer runtime
794-
if !data.is_sanitizer_runtime() {
794+
if !data.root.sanitizer_runtime {
795795
self.sess.err(&format!("the crate `{}` is not a sanitizer runtime",
796796
name));
797797
}
@@ -814,7 +814,7 @@ impl<'a> CrateLoader<'a> {
814814
PathKind::Crate, dep_kind);
815815

816816
// Sanity check the loaded crate to ensure it is indeed a profiler runtime
817-
if !data.is_profiler_runtime() {
817+
if !data.root.profiler_runtime {
818818
self.sess.err(&format!("the crate `profiler_builtins` is not \
819819
a profiler runtime"));
820820
}
@@ -831,7 +831,7 @@ impl<'a> CrateLoader<'a> {
831831
let mut needs_allocator = attr::contains_name(&krate.attrs,
832832
"needs_allocator");
833833
self.cstore.iter_crate_data(|_, data| {
834-
needs_allocator = needs_allocator || data.needs_allocator();
834+
needs_allocator = needs_allocator || data.root.needs_allocator;
835835
});
836836
if !needs_allocator {
837837
self.sess.injected_allocator.set(None);
@@ -873,7 +873,7 @@ impl<'a> CrateLoader<'a> {
873873
None
874874
};
875875
self.cstore.iter_crate_data(|_, data| {
876-
if !data.has_global_allocator() {
876+
if !data.root.has_global_allocator {
877877
return
878878
}
879879
match global_allocator {
@@ -882,14 +882,14 @@ impl<'a> CrateLoader<'a> {
882882
conflicts with this global \
883883
allocator in: {}",
884884
other_crate,
885-
data.name()));
885+
data.root.name));
886886
}
887887
Some(None) => {
888888
self.sess.err(&format!("the #[global_allocator] in this \
889889
crate conflicts with global \
890-
allocator in: {}", data.name()));
890+
allocator in: {}", data.root.name));
891891
}
892-
None => global_allocator = Some(Some(data.name())),
892+
None => global_allocator = Some(Some(data.root.name)),
893893
}
894894
});
895895
if global_allocator.is_some() {
@@ -951,7 +951,7 @@ impl<'a> CrateLoader<'a> {
951951
// error.
952952
let mut allocator = None;
953953
self.cstore.iter_crate_data(|_, data| {
954-
if allocator.is_none() && data.has_default_lib_allocator() {
954+
if allocator.is_none() && data.root.has_default_lib_allocator {
955955
allocator = Some(data.clone());
956956
}
957957
});
@@ -1027,9 +1027,9 @@ impl<'a> CrateLoader<'a> {
10271027
self.sess.err(&format!("the crate `{}` cannot depend \
10281028
on a crate that needs {}, but \
10291029
it depends on `{}`",
1030-
self.cstore.get_crate_data(krate).name(),
1030+
self.cstore.get_crate_data(krate).root.name,
10311031
what,
1032-
data.name()));
1032+
data.root.name));
10331033
}
10341034
}
10351035

src/librustc_metadata/cstore.rs

-61
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

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

src/librustc_metadata/cstore_impl.rs

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

172172
dylib_dependency_formats => { Lrc::new(cdata.get_dylib_dependency_formats()) }
173-
is_panic_runtime => { cdata.is_panic_runtime() }
174-
is_compiler_builtins => { cdata.is_compiler_builtins() }
175-
has_global_allocator => { cdata.has_global_allocator() }
176-
is_sanitizer_runtime => { cdata.is_sanitizer_runtime() }
177-
is_profiler_runtime => { cdata.is_profiler_runtime() }
178-
panic_strategy => { cdata.panic_strategy() }
173+
is_panic_runtime => { cdata.root.panic_runtime }
174+
is_compiler_builtins => { cdata.root.compiler_builtins }
175+
has_global_allocator => { cdata.root.has_global_allocator }
176+
is_sanitizer_runtime => { cdata.root.sanitizer_runtime }
177+
is_profiler_runtime => { cdata.root.profiler_runtime }
178+
panic_strategy => { cdata.root.panic_strategy }
179179
extern_crate => {
180180
let r = Lrc::new(*cdata.extern_crate.lock());
181181
r
182182
}
183-
is_no_builtins => { cdata.is_no_builtins() }
183+
is_no_builtins => { cdata.root.no_builtins }
184184
impl_defaultness => { cdata.get_impl_defaultness(def_id.index) }
185185
reachable_non_generics => {
186186
let reachable_non_generics = tcx
@@ -209,9 +209,9 @@ provide! { <'tcx> tcx, def_id, other, cdata,
209209
DefId { krate: def_id.krate, index }
210210
})
211211
}
212-
crate_disambiguator => { cdata.disambiguator() }
213-
crate_hash => { cdata.hash() }
214-
original_crate_name => { cdata.name() }
212+
crate_disambiguator => { cdata.root.disambiguator }
213+
crate_hash => { cdata.root.hash }
214+
original_crate_name => { cdata.root.name }
215215

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

@@ -457,17 +457,17 @@ impl CrateStore for cstore::CStore {
457457

458458
fn crate_disambiguator_untracked(&self, cnum: CrateNum) -> CrateDisambiguator
459459
{
460-
self.get_crate_data(cnum).disambiguator()
460+
self.get_crate_data(cnum).root.disambiguator
461461
}
462462

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

468468
fn crate_edition_untracked(&self, cnum: CrateNum) -> Edition
469469
{
470-
self.get_crate_data(cnum).edition()
470+
self.get_crate_data(cnum).root.edition
471471
}
472472

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

0 commit comments

Comments
 (0)