Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
metadata: Remove CrateMetadata::name
It duplicates `CrateRoot::name`
  • Loading branch information
petrochenkov committed Oct 3, 2019
commit 0f96ba92b643922c02f43cf0df4d780a95375692
5 changes: 2 additions & 3 deletions src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl<'a> CrateLoader<'a> {
-> Option<CrateNum> {
let mut ret = None;
self.cstore.iter_crate_data(|cnum, data| {
if data.name != name { return }
if data.root.name != name { return }

match hash {
Some(hash) if *hash == data.root.hash => { ret = Some(cnum); return }
Expand Down Expand Up @@ -252,7 +252,6 @@ impl<'a> CrateLoader<'a> {
});

let cmeta = cstore::CrateMetadata {
name: crate_root.name,
extern_crate: Lock::new(None),
def_path_table: Lrc::new(def_path_table),
trait_impls,
Expand Down Expand Up @@ -789,7 +788,7 @@ impl<'a> CrateLoader<'a> {

let mut uses_std = false;
self.cstore.iter_crate_data(|_, data| {
if data.name == sym::std {
if data.root.name == sym::std {
uses_std = true;
}
});
Expand Down
4 changes: 0 additions & 4 deletions src/librustc_metadata/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use rustc::util::nodemap::{FxHashMap, NodeMap};
use rustc_data_structures::sync::{Lrc, RwLock, Lock};
use syntax::ast;
use syntax::ext::base::SyntaxExtension;
use syntax::symbol::Symbol;
use syntax_pos;

pub use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind, LinkagePreference};
Expand Down Expand Up @@ -45,9 +44,6 @@ pub struct ImportedSourceFile {
}

pub struct CrateMetadata {
/// Original name of the crate.
pub name: Symbol,

/// Information about the extern crate that caused this crate to
/// be loaded. If this is `None`, then the crate was injected
/// (e.g., by the allocator)
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_metadata/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
let r = *cdata.dep_kind.lock();
r
}
crate_name => { cdata.name }
crate_name => { cdata.root.name }
item_children => {
let mut result = SmallVec::<[_; 8]>::new();
cdata.each_child_of_item(def_id.index, |child| result.push(child), tcx.sess);
Expand Down Expand Up @@ -453,7 +453,7 @@ impl cstore::CStore {
}

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_file = sess.parse_sess.source_map().new_source_file(source_name, def.body);
Expand Down Expand Up @@ -503,7 +503,7 @@ impl CrateStore for cstore::CStore {

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 {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ impl<'a, 'tcx> CrateMetadata {
None => {
bug!("entry: id not found: {:?} in crate {:?} with number {}",
item_id,
self.name,
self.root.name,
self.cnum)
}
Some(d) => d.decode(self),
Expand Down