metadata: Remove CrateMetadata::name

It duplicates `CrateRoot::name`
This commit is contained in:
Vadim Petrochenkov 2019-10-02 03:15:38 +03:00
parent f13adc5f9d
commit 0f96ba92b6
4 changed files with 6 additions and 11 deletions

View file

@ -112,7 +112,7 @@ impl<'a> CrateLoader<'a> {
-> Option<CrateNum> { -> Option<CrateNum> {
let mut ret = None; let mut ret = None;
self.cstore.iter_crate_data(|cnum, data| { self.cstore.iter_crate_data(|cnum, data| {
if data.name != name { return } if data.root.name != name { return }
match hash { match hash {
Some(hash) if *hash == data.root.hash => { ret = Some(cnum); return } Some(hash) if *hash == data.root.hash => { ret = Some(cnum); return }
@ -252,7 +252,6 @@ impl<'a> CrateLoader<'a> {
}); });
let cmeta = cstore::CrateMetadata { let cmeta = cstore::CrateMetadata {
name: crate_root.name,
extern_crate: Lock::new(None), extern_crate: Lock::new(None),
def_path_table: Lrc::new(def_path_table), def_path_table: Lrc::new(def_path_table),
trait_impls, trait_impls,
@ -789,7 +788,7 @@ impl<'a> CrateLoader<'a> {
let mut uses_std = false; let mut uses_std = false;
self.cstore.iter_crate_data(|_, data| { self.cstore.iter_crate_data(|_, data| {
if data.name == sym::std { if data.root.name == sym::std {
uses_std = true; uses_std = true;
} }
}); });

View file

@ -12,7 +12,6 @@ use rustc::util::nodemap::{FxHashMap, NodeMap};
use rustc_data_structures::sync::{Lrc, RwLock, Lock}; use rustc_data_structures::sync::{Lrc, RwLock, Lock};
use syntax::ast; use syntax::ast;
use syntax::ext::base::SyntaxExtension; use syntax::ext::base::SyntaxExtension;
use syntax::symbol::Symbol;
use syntax_pos; use syntax_pos;
pub use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind, LinkagePreference}; pub use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind, LinkagePreference};
@ -45,9 +44,6 @@ pub struct ImportedSourceFile {
} }
pub struct CrateMetadata { pub struct CrateMetadata {
/// Original name of the crate.
pub name: Symbol,
/// Information about the extern crate that caused this crate to /// Information about the extern crate that caused this crate to
/// be loaded. If this is `None`, then the crate was injected /// be loaded. If this is `None`, then the crate was injected
/// (e.g., by the allocator) /// (e.g., by the allocator)

View file

@ -220,7 +220,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
let r = *cdata.dep_kind.lock(); let r = *cdata.dep_kind.lock();
r r
} }
crate_name => { cdata.name } crate_name => { cdata.root.name }
item_children => { item_children => {
let mut result = SmallVec::<[_; 8]>::new(); let mut result = SmallVec::<[_; 8]>::new();
cdata.each_child_of_item(def_id.index, |child| result.push(child), tcx.sess); cdata.each_child_of_item(def_id.index, |child| result.push(child), tcx.sess);
@ -453,7 +453,7 @@ impl cstore::CStore {
} }
let def = data.get_macro(id.index); let def = data.get_macro(id.index);
let macro_full_name = data.def_path(id.index).to_string_friendly(|_| data.name); let macro_full_name = data.def_path(id.index).to_string_friendly(|_| data.root.name);
let source_name = FileName::Macros(macro_full_name); let source_name = FileName::Macros(macro_full_name);
let source_file = sess.parse_sess.source_map().new_source_file(source_name, def.body); let source_file = sess.parse_sess.source_map().new_source_file(source_name, def.body);
@ -503,7 +503,7 @@ impl CrateStore for cstore::CStore {
fn crate_name_untracked(&self, cnum: CrateNum) -> Symbol fn crate_name_untracked(&self, cnum: CrateNum) -> Symbol
{ {
self.get_crate_data(cnum).name self.get_crate_data(cnum).root.name
} }
fn crate_is_private_dep_untracked(&self, cnum: CrateNum) -> bool { fn crate_is_private_dep_untracked(&self, cnum: CrateNum) -> bool {

View file

@ -473,7 +473,7 @@ impl<'a, 'tcx> CrateMetadata {
None => { None => {
bug!("entry: id not found: {:?} in crate {:?} with number {}", bug!("entry: id not found: {:?} in crate {:?} with number {}",
item_id, item_id,
self.name, self.root.name,
self.cnum) self.cnum)
} }
Some(d) => d.decode(self), Some(d) => d.decode(self),