rustc_metadata: Privatize private code and remove dead code
This commit is contained in:
parent
446e5e57b6
commit
e8c28e24b9
17 changed files with 202 additions and 257 deletions
|
@ -616,7 +616,7 @@ impl RustcDefaultCalls {
|
|||
let mut v = Vec::new();
|
||||
locator::list_file_metadata(&sess.target.target,
|
||||
path,
|
||||
&*cstore.metadata_loader,
|
||||
cstore,
|
||||
&mut v)
|
||||
.unwrap();
|
||||
println!("{}", String::from_utf8(v).unwrap());
|
||||
|
|
|
@ -663,16 +663,15 @@ fn write_out_deps(compiler: &Compiler, outputs: &OutputFilenames, out_filenames:
|
|||
|
||||
if sess.binary_dep_depinfo() {
|
||||
for cnum in compiler.cstore.crates_untracked() {
|
||||
let metadata = compiler.cstore.crate_data_as_rc_any(cnum);
|
||||
let metadata = metadata.downcast_ref::<cstore::CrateMetadata>().unwrap();
|
||||
if let Some((path, _)) = &metadata.source.dylib {
|
||||
files.push(escape_dep_filename(&FileName::Real(path.clone())));
|
||||
let source = compiler.cstore.crate_source_untracked(cnum);
|
||||
if let Some((path, _)) = source.dylib {
|
||||
files.push(escape_dep_filename(&FileName::Real(path)));
|
||||
}
|
||||
if let Some((path, _)) = &metadata.source.rlib {
|
||||
files.push(escape_dep_filename(&FileName::Real(path.clone())));
|
||||
if let Some((path, _)) = source.rlib {
|
||||
files.push(escape_dep_filename(&FileName::Real(path)));
|
||||
}
|
||||
if let Some((path, _)) = &metadata.source.rmeta {
|
||||
files.push(escape_dep_filename(&FileName::Real(path.clone())));
|
||||
if let Some((path, _)) = source.rmeta {
|
||||
files.push(escape_dep_filename(&FileName::Real(path)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! Validates all used crates and extern libraries and loads their metadata
|
||||
|
||||
use crate::cstore::{self, CStore, CrateSource, MetadataBlob};
|
||||
use crate::cstore::{self, CStore, MetadataBlob};
|
||||
use crate::locator::{self, CratePaths};
|
||||
use crate::schema::{CrateRoot, CrateDep};
|
||||
use rustc_data_structures::sync::{Lrc, RwLock, Lock, AtomicCell};
|
||||
|
@ -14,7 +14,7 @@ use rustc::session::{Session, CrateDisambiguator};
|
|||
use rustc::session::config::{Sanitizer, self};
|
||||
use rustc_target::spec::{PanicStrategy, TargetTriple};
|
||||
use rustc::session::search_paths::PathKind;
|
||||
use rustc::middle::cstore::{ExternCrate, ExternCrateSource};
|
||||
use rustc::middle::cstore::{CrateSource, ExternCrate, ExternCrateSource};
|
||||
use rustc::util::common::record_time;
|
||||
use rustc::util::nodemap::FxHashSet;
|
||||
use rustc::hir::map::Definitions;
|
||||
|
@ -33,7 +33,7 @@ use syntax_pos::{Span, DUMMY_SP};
|
|||
use log::{debug, info, log_enabled};
|
||||
use proc_macro::bridge::client::ProcMacro;
|
||||
|
||||
pub struct Library {
|
||||
crate struct Library {
|
||||
pub dylib: Option<(PathBuf, PathKind)>,
|
||||
pub rlib: Option<(PathBuf, PathKind)>,
|
||||
pub rmeta: Option<(PathBuf, PathKind)>,
|
||||
|
@ -41,7 +41,7 @@ pub struct Library {
|
|||
}
|
||||
|
||||
pub struct CrateLoader<'a> {
|
||||
pub sess: &'a Session,
|
||||
sess: &'a Session,
|
||||
cstore: &'a CStore,
|
||||
local_crate_name: Symbol,
|
||||
}
|
||||
|
@ -268,13 +268,12 @@ impl<'a> CrateLoader<'a> {
|
|||
source_map_import_info: RwLock::new(vec![]),
|
||||
alloc_decoding_state: AllocDecodingState::new(interpret_alloc_index),
|
||||
dep_kind: Lock::new(dep_kind),
|
||||
source: cstore::CrateSource {
|
||||
source: CrateSource {
|
||||
dylib,
|
||||
rlib,
|
||||
rmeta,
|
||||
},
|
||||
private_dep,
|
||||
span,
|
||||
raw_proc_macros,
|
||||
dep_node_index: AtomicCell::new(DepNodeIndex::INVALID),
|
||||
};
|
||||
|
|
|
@ -5,19 +5,15 @@ use crate::schema;
|
|||
use rustc::dep_graph::DepNodeIndex;
|
||||
use rustc::hir::def_id::{CrateNum, DefIndex};
|
||||
use rustc::hir::map::definitions::DefPathTable;
|
||||
use rustc::middle::cstore::{DepKind, ExternCrate, MetadataLoader};
|
||||
use rustc::middle::cstore::{CrateSource, DepKind, ExternCrate, MetadataLoader};
|
||||
use rustc::mir::interpret::AllocDecodingState;
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc::util::nodemap::{FxHashMap, NodeMap};
|
||||
|
||||
use rustc_data_structures::sync::{Lrc, RwLock, Lock, AtomicCell};
|
||||
use rustc_data_structures::sync::{Lrc, RwLock, Lock, MetadataRef, AtomicCell};
|
||||
use syntax::ast;
|
||||
use syntax::ext::base::SyntaxExtension;
|
||||
use syntax_pos;
|
||||
|
||||
pub use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind, LinkagePreference};
|
||||
pub use rustc::middle::cstore::NativeLibraryKind::*;
|
||||
pub use rustc::middle::cstore::{CrateSource, LibSource, ForeignModule};
|
||||
use proc_macro::bridge::client::ProcMacro;
|
||||
|
||||
pub use crate::cstore_impl::{provide, provide_extern};
|
||||
|
||||
|
@ -25,17 +21,13 @@ pub use crate::cstore_impl::{provide, provide_extern};
|
|||
// local crate numbers (as generated during this session). Each external
|
||||
// crate may refer to types in other external crates, and each has their
|
||||
// own crate numbers.
|
||||
pub type CrateNumMap = IndexVec<CrateNum, CrateNum>;
|
||||
crate type CrateNumMap = IndexVec<CrateNum, CrateNum>;
|
||||
|
||||
pub use rustc_data_structures::sync::MetadataRef;
|
||||
use syntax_pos::Span;
|
||||
use proc_macro::bridge::client::ProcMacro;
|
||||
|
||||
pub struct MetadataBlob(pub MetadataRef);
|
||||
crate struct MetadataBlob(pub MetadataRef);
|
||||
|
||||
/// Holds information about a syntax_pos::SourceFile imported from another crate.
|
||||
/// See `imported_source_files()` for more information.
|
||||
pub struct ImportedSourceFile {
|
||||
crate struct ImportedSourceFile {
|
||||
/// This SourceFile's byte-offset within the source_map of its original crate
|
||||
pub original_start_pos: syntax_pos::BytePos,
|
||||
/// The end of this SourceFile within the source_map of its original crate
|
||||
|
@ -48,56 +40,54 @@ pub struct CrateMetadata {
|
|||
/// 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)
|
||||
pub extern_crate: Lock<Option<ExternCrate>>,
|
||||
crate extern_crate: Lock<Option<ExternCrate>>,
|
||||
|
||||
pub blob: MetadataBlob,
|
||||
pub cnum_map: CrateNumMap,
|
||||
pub cnum: CrateNum,
|
||||
pub dependencies: Lock<Vec<CrateNum>>,
|
||||
pub source_map_import_info: RwLock<Vec<ImportedSourceFile>>,
|
||||
crate blob: MetadataBlob,
|
||||
crate cnum_map: CrateNumMap,
|
||||
crate cnum: CrateNum,
|
||||
crate dependencies: Lock<Vec<CrateNum>>,
|
||||
crate source_map_import_info: RwLock<Vec<ImportedSourceFile>>,
|
||||
|
||||
/// Used for decoding interpret::AllocIds in a cached & thread-safe manner.
|
||||
pub alloc_decoding_state: AllocDecodingState,
|
||||
crate alloc_decoding_state: AllocDecodingState,
|
||||
|
||||
// NOTE(eddyb) we pass `'static` to a `'tcx` parameter because this
|
||||
// lifetime is only used behind `Lazy`, and therefore acts like an
|
||||
// universal (`for<'tcx>`), that is paired up with whichever `TyCtxt`
|
||||
// is being used to decode those values.
|
||||
pub root: schema::CrateRoot<'static>,
|
||||
crate root: schema::CrateRoot<'static>,
|
||||
|
||||
/// For each definition in this crate, we encode a key. When the
|
||||
/// crate is loaded, we read all the keys and put them in this
|
||||
/// hashmap, which gives the reverse mapping. This allows us to
|
||||
/// quickly retrace a `DefPath`, which is needed for incremental
|
||||
/// compilation support.
|
||||
pub def_path_table: Lrc<DefPathTable>,
|
||||
crate def_path_table: Lrc<DefPathTable>,
|
||||
|
||||
pub trait_impls: FxHashMap<(u32, DefIndex), schema::Lazy<[DefIndex]>>,
|
||||
crate trait_impls: FxHashMap<(u32, DefIndex), schema::Lazy<[DefIndex]>>,
|
||||
|
||||
pub dep_kind: Lock<DepKind>,
|
||||
pub source: CrateSource,
|
||||
crate dep_kind: Lock<DepKind>,
|
||||
crate source: CrateSource,
|
||||
|
||||
/// Whether or not this crate should be consider a private dependency
|
||||
/// for purposes of the 'exported_private_dependencies' lint
|
||||
pub private_dep: bool,
|
||||
crate private_dep: bool,
|
||||
|
||||
pub span: Span,
|
||||
|
||||
pub raw_proc_macros: Option<&'static [ProcMacro]>,
|
||||
crate raw_proc_macros: Option<&'static [ProcMacro]>,
|
||||
|
||||
/// The `DepNodeIndex` of the `DepNode` representing this upstream crate.
|
||||
/// It is initialized on the first access in `get_crate_dep_node_index()`.
|
||||
/// Do not access the value directly, as it might not have been initialized
|
||||
/// yet.
|
||||
/// The field must always be initialized to `DepNodeIndex::INVALID`.
|
||||
pub(super) dep_node_index: AtomicCell<DepNodeIndex>,
|
||||
crate dep_node_index: AtomicCell<DepNodeIndex>,
|
||||
}
|
||||
|
||||
pub struct CStore {
|
||||
metas: RwLock<IndexVec<CrateNum, Option<Lrc<CrateMetadata>>>>,
|
||||
/// Map from NodeId's of local extern crate statements to crate numbers
|
||||
extern_mod_crate_map: Lock<NodeMap<CrateNum>>,
|
||||
pub metadata_loader: Box<dyn MetadataLoader + Sync>,
|
||||
crate metadata_loader: Box<dyn MetadataLoader + Sync>,
|
||||
}
|
||||
|
||||
pub enum LoadedMacro {
|
||||
|
@ -118,25 +108,25 @@ impl CStore {
|
|||
}
|
||||
}
|
||||
|
||||
pub(super) fn alloc_new_crate_num(&self) -> CrateNum {
|
||||
crate fn alloc_new_crate_num(&self) -> CrateNum {
|
||||
let mut metas = self.metas.borrow_mut();
|
||||
let cnum = CrateNum::new(metas.len());
|
||||
metas.push(None);
|
||||
cnum
|
||||
}
|
||||
|
||||
pub(super) fn get_crate_data(&self, cnum: CrateNum) -> Lrc<CrateMetadata> {
|
||||
crate fn get_crate_data(&self, cnum: CrateNum) -> Lrc<CrateMetadata> {
|
||||
self.metas.borrow()[cnum].clone()
|
||||
.unwrap_or_else(|| panic!("Failed to get crate data for {:?}", cnum))
|
||||
}
|
||||
|
||||
pub(super) fn set_crate_data(&self, cnum: CrateNum, data: Lrc<CrateMetadata>) {
|
||||
crate fn set_crate_data(&self, cnum: CrateNum, data: Lrc<CrateMetadata>) {
|
||||
let mut metas = self.metas.borrow_mut();
|
||||
assert!(metas[cnum].is_none(), "Overwriting crate metadata entry");
|
||||
metas[cnum] = Some(data);
|
||||
}
|
||||
|
||||
pub(super) fn iter_crate_data<I>(&self, mut i: I)
|
||||
crate fn iter_crate_data<I>(&self, mut i: I)
|
||||
where I: FnMut(CrateNum, &Lrc<CrateMetadata>)
|
||||
{
|
||||
for (k, v) in self.metas.borrow().iter_enumerated() {
|
||||
|
@ -146,16 +136,14 @@ impl CStore {
|
|||
}
|
||||
}
|
||||
|
||||
pub(super) fn crate_dependencies_in_rpo(&self, krate: CrateNum) -> Vec<CrateNum> {
|
||||
crate fn crate_dependencies_in_rpo(&self, krate: CrateNum) -> Vec<CrateNum> {
|
||||
let mut ordering = Vec::new();
|
||||
self.push_dependencies_in_postorder(&mut ordering, krate);
|
||||
ordering.reverse();
|
||||
ordering
|
||||
}
|
||||
|
||||
pub(super) fn push_dependencies_in_postorder(&self,
|
||||
ordering: &mut Vec<CrateNum>,
|
||||
krate: CrateNum) {
|
||||
crate fn push_dependencies_in_postorder(&self, ordering: &mut Vec<CrateNum>, krate: CrateNum) {
|
||||
if ordering.contains(&krate) {
|
||||
return;
|
||||
}
|
||||
|
@ -170,7 +158,7 @@ impl CStore {
|
|||
ordering.push(krate);
|
||||
}
|
||||
|
||||
pub(super) fn do_postorder_cnums_untracked(&self) -> Vec<CrateNum> {
|
||||
crate fn do_postorder_cnums_untracked(&self) -> Vec<CrateNum> {
|
||||
let mut ordering = Vec::new();
|
||||
for (num, v) in self.metas.borrow().iter_enumerated() {
|
||||
if let &Some(_) = v {
|
||||
|
@ -180,11 +168,11 @@ impl CStore {
|
|||
return ordering
|
||||
}
|
||||
|
||||
pub(super) fn add_extern_mod_stmt_cnum(&self, emod_id: ast::NodeId, cnum: CrateNum) {
|
||||
crate fn add_extern_mod_stmt_cnum(&self, emod_id: ast::NodeId, cnum: CrateNum) {
|
||||
self.extern_mod_crate_map.borrow_mut().insert(emod_id, cnum);
|
||||
}
|
||||
|
||||
pub(super) fn do_extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<CrateNum> {
|
||||
crate fn do_extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<CrateNum> {
|
||||
self.extern_mod_crate_map.borrow().get(&emod_id).cloned()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,7 @@ use crate::foreign_modules;
|
|||
use crate::schema;
|
||||
|
||||
use rustc::ty::query::QueryConfig;
|
||||
use rustc::middle::cstore::{CrateStore, DepKind,
|
||||
EncodedMetadata, NativeLibraryKind};
|
||||
use rustc::middle::cstore::{CrateSource, CrateStore, DepKind, EncodedMetadata, NativeLibraryKind};
|
||||
use rustc::middle::exported_symbols::ExportedSymbol;
|
||||
use rustc::middle::stability::DeprecationEntry;
|
||||
use rustc::middle::dependency_format::Linkage;
|
||||
|
@ -414,12 +413,6 @@ impl cstore::CStore {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn dep_kind_untracked(&self, cnum: CrateNum) -> DepKind {
|
||||
let data = self.get_crate_data(cnum);
|
||||
let r = *data.dep_kind.lock();
|
||||
r
|
||||
}
|
||||
|
||||
pub fn crate_edition_untracked(&self, cnum: CrateNum) -> Edition {
|
||||
self.get_crate_data(cnum).root.edition
|
||||
}
|
||||
|
@ -428,14 +421,6 @@ impl cstore::CStore {
|
|||
self.get_crate_data(def.krate).get_struct_field_names(def.index, sess)
|
||||
}
|
||||
|
||||
pub fn ctor_kind_untracked(&self, def: DefId) -> def::CtorKind {
|
||||
self.get_crate_data(def.krate).get_ctor_kind(def.index)
|
||||
}
|
||||
|
||||
pub fn item_attrs_untracked(&self, def: DefId, sess: &Session) -> Lrc<[ast::Attribute]> {
|
||||
self.get_crate_data(def.krate).get_item_attrs(def.index, sess)
|
||||
}
|
||||
|
||||
pub fn item_children_untracked(
|
||||
&self,
|
||||
def_id: DefId,
|
||||
|
@ -493,6 +478,10 @@ impl cstore::CStore {
|
|||
pub fn associated_item_cloned_untracked(&self, def: DefId) -> ty::AssocItem {
|
||||
self.get_crate_data(def.krate).get_associated_item(def.index)
|
||||
}
|
||||
|
||||
pub fn crate_source_untracked(&self, cnum: CrateNum) -> CrateSource {
|
||||
self.get_crate_data(cnum).source.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl CrateStore for cstore::CStore {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
// Decoding metadata from a single crate's metadata
|
||||
|
||||
use crate::cstore::{self, CrateMetadata, MetadataBlob, NativeLibrary, ForeignModule};
|
||||
use crate::cstore::{self, CrateMetadata, MetadataBlob};
|
||||
use crate::schema::*;
|
||||
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_data_structures::sync::{Lrc, ReadGuard};
|
||||
use rustc::hir::map::{DefKey, DefPath, DefPathData, DefPathHash};
|
||||
use rustc::hir;
|
||||
use rustc::middle::cstore::LinkagePreference;
|
||||
use rustc::middle::cstore::{LinkagePreference, NativeLibrary, ForeignModule};
|
||||
use rustc::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
|
||||
use rustc::hir::def::{self, Res, DefKind, CtorOf, CtorKind};
|
||||
use rustc::hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
|
||||
|
@ -38,7 +38,7 @@ use log::debug;
|
|||
use proc_macro::bridge::client::ProcMacro;
|
||||
use syntax::ext::proc_macro::{AttrProcMacro, ProcMacroDerive, BangProcMacro};
|
||||
|
||||
pub struct DecodeContext<'a, 'tcx> {
|
||||
crate struct DecodeContext<'a, 'tcx> {
|
||||
opaque: opaque::Decoder<'a>,
|
||||
cdata: Option<&'a CrateMetadata>,
|
||||
sess: Option<&'tcx Session>,
|
||||
|
@ -54,7 +54,7 @@ pub struct DecodeContext<'a, 'tcx> {
|
|||
}
|
||||
|
||||
/// Abstract over the various ways one can create metadata decoders.
|
||||
pub trait Metadata<'a, 'tcx>: Copy {
|
||||
crate trait Metadata<'a, 'tcx>: Copy {
|
||||
fn raw_bytes(self) -> &'a [u8];
|
||||
fn cdata(self) -> Option<&'a CrateMetadata> { None }
|
||||
fn sess(self) -> Option<&'tcx Session> { None }
|
||||
|
@ -130,7 +130,7 @@ impl<'a, 'tcx> Metadata<'a, 'tcx> for (&'a CrateMetadata, TyCtxt<'tcx>) {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx, T: Decodable> Lazy<T> {
|
||||
pub fn decode<M: Metadata<'a, 'tcx>>(self, meta: M) -> T {
|
||||
crate fn decode<M: Metadata<'a, 'tcx>>(self, meta: M) -> T {
|
||||
let mut dcx = meta.decoder(self.position);
|
||||
dcx.lazy_state = LazyState::NodeStart(self.position);
|
||||
T::decode(&mut dcx).unwrap()
|
||||
|
@ -138,7 +138,7 @@ impl<'a, 'tcx, T: Decodable> Lazy<T> {
|
|||
}
|
||||
|
||||
impl<'a: 'x, 'tcx: 'x, 'x, T: Decodable> Lazy<[T]> {
|
||||
pub fn decode<M: Metadata<'a, 'tcx>>(
|
||||
crate fn decode<M: Metadata<'a, 'tcx>>(
|
||||
self,
|
||||
meta: M,
|
||||
) -> impl ExactSizeIterator<Item = T> + Captures<'a> + Captures<'tcx> + 'x {
|
||||
|
@ -149,11 +149,11 @@ impl<'a: 'x, 'tcx: 'x, 'x, T: Decodable> Lazy<[T]> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> DecodeContext<'a, 'tcx> {
|
||||
pub fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx.expect("missing TyCtxt in DecodeContext")
|
||||
}
|
||||
|
||||
pub fn cdata(&self) -> &'a CrateMetadata {
|
||||
fn cdata(&self) -> &'a CrateMetadata {
|
||||
self.cdata.expect("missing CrateMetadata in DecodeContext")
|
||||
}
|
||||
|
||||
|
@ -379,15 +379,15 @@ for DecodeContext<'a, 'tcx> {
|
|||
implement_ty_decoder!( DecodeContext<'a, 'tcx> );
|
||||
|
||||
impl<'tcx> MetadataBlob {
|
||||
pub fn is_compatible(&self) -> bool {
|
||||
crate fn is_compatible(&self) -> bool {
|
||||
self.raw_bytes().starts_with(METADATA_HEADER)
|
||||
}
|
||||
|
||||
pub fn get_rustc_version(&self) -> String {
|
||||
crate fn get_rustc_version(&self) -> String {
|
||||
Lazy::<String>::from_position(METADATA_HEADER.len() + 4).decode(self)
|
||||
}
|
||||
|
||||
pub fn get_root(&self) -> CrateRoot<'tcx> {
|
||||
crate fn get_root(&self) -> CrateRoot<'tcx> {
|
||||
let slice = self.raw_bytes();
|
||||
let offset = METADATA_HEADER.len();
|
||||
let pos = (((slice[offset + 0] as u32) << 24) | ((slice[offset + 1] as u32) << 16) |
|
||||
|
@ -396,7 +396,7 @@ impl<'tcx> MetadataBlob {
|
|||
Lazy::<CrateRoot<'tcx>>::from_position(pos).decode(self)
|
||||
}
|
||||
|
||||
pub fn list_crate_metadata(&self,
|
||||
crate fn list_crate_metadata(&self,
|
||||
out: &mut dyn io::Write) -> io::Result<()> {
|
||||
write!(out, "=External Dependencies=\n")?;
|
||||
let root = self.get_root();
|
||||
|
@ -449,7 +449,7 @@ impl<'tcx> EntryKind<'tcx> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> CrateMetadata {
|
||||
pub fn is_proc_macro_crate(&self) -> bool {
|
||||
crate fn is_proc_macro_crate(&self) -> bool {
|
||||
self.root.proc_macro_decls_static.is_some()
|
||||
}
|
||||
|
||||
|
@ -499,7 +499,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
&self.raw_proc_macros.unwrap()[pos]
|
||||
}
|
||||
|
||||
pub fn item_name(&self, item_index: DefIndex) -> Symbol {
|
||||
crate fn item_name(&self, item_index: DefIndex) -> Symbol {
|
||||
if !self.is_proc_macro(item_index) {
|
||||
self.def_key(item_index)
|
||||
.disambiguated_data
|
||||
|
@ -512,7 +512,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn def_kind(&self, index: DefIndex) -> Option<DefKind> {
|
||||
crate fn def_kind(&self, index: DefIndex) -> Option<DefKind> {
|
||||
if !self.is_proc_macro(index) {
|
||||
self.entry(index).kind.def_kind()
|
||||
} else {
|
||||
|
@ -522,7 +522,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_span(&self, index: DefIndex, sess: &Session) -> Span {
|
||||
crate fn get_span(&self, index: DefIndex, sess: &Session) -> Span {
|
||||
self.entry(index).span.decode((self, sess))
|
||||
}
|
||||
|
||||
|
@ -556,7 +556,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn get_trait_def(&self, item_id: DefIndex, sess: &Session) -> ty::TraitDef {
|
||||
crate fn get_trait_def(&self, item_id: DefIndex, sess: &Session) -> ty::TraitDef {
|
||||
match self.entry(item_id).kind {
|
||||
EntryKind::Trait(data) => {
|
||||
let data = data.decode((self, sess));
|
||||
|
@ -622,7 +622,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn get_adt_def(&self, item_id: DefIndex, tcx: TyCtxt<'tcx>) -> &'tcx ty::AdtDef {
|
||||
crate fn get_adt_def(&self, item_id: DefIndex, tcx: TyCtxt<'tcx>) -> &'tcx ty::AdtDef {
|
||||
let item = self.entry(item_id);
|
||||
let did = self.local_def_id(item_id);
|
||||
|
||||
|
@ -647,7 +647,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
tcx.alloc_adt_def(did, kind, variants, repr)
|
||||
}
|
||||
|
||||
pub fn get_predicates(
|
||||
crate fn get_predicates(
|
||||
&self,
|
||||
item_id: DefIndex,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
@ -655,7 +655,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
self.entry(item_id).predicates.unwrap().decode((self, tcx))
|
||||
}
|
||||
|
||||
pub fn get_predicates_defined_on(
|
||||
crate fn get_predicates_defined_on(
|
||||
&self,
|
||||
item_id: DefIndex,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
@ -663,7 +663,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
self.entry(item_id).predicates_defined_on.unwrap().decode((self, tcx))
|
||||
}
|
||||
|
||||
pub fn get_super_predicates(
|
||||
crate fn get_super_predicates(
|
||||
&self,
|
||||
item_id: DefIndex,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
@ -677,30 +677,27 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
super_predicates.decode((self, tcx))
|
||||
}
|
||||
|
||||
pub fn get_generics(&self,
|
||||
item_id: DefIndex,
|
||||
sess: &Session)
|
||||
-> ty::Generics {
|
||||
crate fn get_generics(&self, item_id: DefIndex, sess: &Session) -> ty::Generics {
|
||||
self.entry(item_id).generics.unwrap().decode((self, sess))
|
||||
}
|
||||
|
||||
pub fn get_type(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
|
||||
crate fn get_type(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
|
||||
self.entry(id).ty.unwrap().decode((self, tcx))
|
||||
}
|
||||
|
||||
pub fn get_stability(&self, id: DefIndex) -> Option<attr::Stability> {
|
||||
crate fn get_stability(&self, id: DefIndex) -> Option<attr::Stability> {
|
||||
match self.is_proc_macro(id) {
|
||||
true => self.root.proc_macro_stability.clone(),
|
||||
false => self.entry(id).stability.map(|stab| stab.decode(self)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_deprecation(&self, id: DefIndex) -> Option<attr::Deprecation> {
|
||||
crate fn get_deprecation(&self, id: DefIndex) -> Option<attr::Deprecation> {
|
||||
self.entry_unless_proc_macro(id)
|
||||
.and_then(|entry| entry.deprecation.map(|depr| depr.decode(self)))
|
||||
}
|
||||
|
||||
pub fn get_visibility(&self, id: DefIndex) -> ty::Visibility {
|
||||
crate fn get_visibility(&self, id: DefIndex) -> ty::Visibility {
|
||||
match self.is_proc_macro(id) {
|
||||
true => ty::Visibility::Public,
|
||||
false => self.entry(id).visibility.decode(self),
|
||||
|
@ -714,30 +711,31 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_parent_impl(&self, id: DefIndex) -> Option<DefId> {
|
||||
crate fn get_parent_impl(&self, id: DefIndex) -> Option<DefId> {
|
||||
self.get_impl_data(id).parent_impl
|
||||
}
|
||||
|
||||
pub fn get_impl_polarity(&self, id: DefIndex) -> ty::ImplPolarity {
|
||||
crate fn get_impl_polarity(&self, id: DefIndex) -> ty::ImplPolarity {
|
||||
self.get_impl_data(id).polarity
|
||||
}
|
||||
|
||||
pub fn get_impl_defaultness(&self, id: DefIndex) -> hir::Defaultness {
|
||||
crate fn get_impl_defaultness(&self, id: DefIndex) -> hir::Defaultness {
|
||||
self.get_impl_data(id).defaultness
|
||||
}
|
||||
|
||||
pub fn get_coerce_unsized_info(&self,
|
||||
id: DefIndex)
|
||||
-> Option<ty::adjustment::CoerceUnsizedInfo> {
|
||||
crate fn get_coerce_unsized_info(
|
||||
&self,
|
||||
id: DefIndex,
|
||||
) -> Option<ty::adjustment::CoerceUnsizedInfo> {
|
||||
self.get_impl_data(id).coerce_unsized_info
|
||||
}
|
||||
|
||||
pub fn get_impl_trait(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Option<ty::TraitRef<'tcx>> {
|
||||
crate fn get_impl_trait(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> Option<ty::TraitRef<'tcx>> {
|
||||
self.get_impl_data(id).trait_ref.map(|tr| tr.decode((self, tcx)))
|
||||
}
|
||||
|
||||
/// Iterates over all the stability attributes in the given crate.
|
||||
pub fn get_lib_features(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(ast::Name, Option<ast::Name>)] {
|
||||
crate fn get_lib_features(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(ast::Name, Option<ast::Name>)] {
|
||||
// FIXME: For a proc macro crate, not sure whether we should return the "host"
|
||||
// features or an empty Vec. Both don't cause ICEs.
|
||||
tcx.arena.alloc_from_iter(self.root
|
||||
|
@ -746,7 +744,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
|
||||
/// Iterates over the language items in the given crate.
|
||||
pub fn get_lang_items(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(DefId, usize)] {
|
||||
crate fn get_lang_items(&self, tcx: TyCtxt<'tcx>) -> &'tcx [(DefId, usize)] {
|
||||
if self.is_proc_macro_crate() {
|
||||
// Proc macro crates do not export any lang-items to the target.
|
||||
&[]
|
||||
|
@ -759,7 +757,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
|
||||
/// Iterates over the diagnostic items in the given crate.
|
||||
pub fn get_diagnostic_items(
|
||||
crate fn get_diagnostic_items(
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> &'tcx FxHashMap<Symbol, DefId> {
|
||||
|
@ -776,7 +774,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
|
||||
/// Iterates over each child of the given item.
|
||||
pub fn each_child_of_item<F>(&self, id: DefIndex, mut callback: F, sess: &Session)
|
||||
crate fn each_child_of_item<F>(&self, id: DefIndex, mut callback: F, sess: &Session)
|
||||
where F: FnMut(def::Export<hir::HirId>)
|
||||
{
|
||||
if let Some(proc_macros_ids) = self.root.proc_macro_data.map(|d| d.decode(self)) {
|
||||
|
@ -911,12 +909,12 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_item_mir_available(&self, id: DefIndex) -> bool {
|
||||
crate fn is_item_mir_available(&self, id: DefIndex) -> bool {
|
||||
!self.is_proc_macro(id) &&
|
||||
self.maybe_entry(id).and_then(|item| item.decode(self).mir).is_some()
|
||||
}
|
||||
|
||||
pub fn get_optimized_mir(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> Body<'tcx> {
|
||||
crate fn get_optimized_mir(&self, tcx: TyCtxt<'tcx>, id: DefIndex) -> Body<'tcx> {
|
||||
self.entry_unless_proc_macro(id)
|
||||
.and_then(|entry| entry.mir.map(|mir| mir.decode((self, tcx))))
|
||||
.unwrap_or_else(|| {
|
||||
|
@ -924,7 +922,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn get_promoted_mir(
|
||||
crate fn get_promoted_mir(
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
id: DefIndex,
|
||||
|
@ -936,7 +934,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn mir_const_qualif(&self, id: DefIndex) -> u8 {
|
||||
crate fn mir_const_qualif(&self, id: DefIndex) -> u8 {
|
||||
match self.entry(id).kind {
|
||||
EntryKind::Const(qualif, _) |
|
||||
EntryKind::AssocConst(AssocContainer::ImplDefault, qualif, _) |
|
||||
|
@ -947,7 +945,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_associated_item(&self, id: DefIndex) -> ty::AssocItem {
|
||||
crate fn get_associated_item(&self, id: DefIndex) -> ty::AssocItem {
|
||||
let item = self.entry(id);
|
||||
let def_key = self.def_key(id);
|
||||
let parent = self.local_def_id(def_key.parent.unwrap());
|
||||
|
@ -981,11 +979,11 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_item_variances(&self, id: DefIndex) -> Vec<ty::Variance> {
|
||||
crate fn get_item_variances(&self, id: DefIndex) -> Vec<ty::Variance> {
|
||||
self.entry(id).variances.decode(self).collect()
|
||||
}
|
||||
|
||||
pub fn get_ctor_kind(&self, node_id: DefIndex) -> CtorKind {
|
||||
crate fn get_ctor_kind(&self, node_id: DefIndex) -> CtorKind {
|
||||
match self.entry(node_id).kind {
|
||||
EntryKind::Struct(data, _) |
|
||||
EntryKind::Union(data, _) |
|
||||
|
@ -994,7 +992,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_ctor_def_id(&self, node_id: DefIndex) -> Option<DefId> {
|
||||
crate fn get_ctor_def_id(&self, node_id: DefIndex) -> Option<DefId> {
|
||||
match self.entry(node_id).kind {
|
||||
EntryKind::Struct(data, _) => {
|
||||
data.decode(self).ctor.map(|index| self.local_def_id(index))
|
||||
|
@ -1006,8 +1004,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn get_item_attrs(&self, node_id: DefIndex, sess: &Session) -> Lrc<[ast::Attribute]> {
|
||||
crate fn get_item_attrs(&self, node_id: DefIndex, sess: &Session) -> Lrc<[ast::Attribute]> {
|
||||
// The attributes for a tuple struct/variant are attached to the definition, not the ctor;
|
||||
// we assume that someone passing in a tuple struct ctor is actually wanting to
|
||||
// look at the definition
|
||||
|
@ -1022,7 +1019,11 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
Lrc::from(self.get_attributes(&item, sess))
|
||||
}
|
||||
|
||||
pub fn get_struct_field_names(&self, id: DefIndex, sess: &Session) -> Vec<Spanned<ast::Name>> {
|
||||
crate fn get_struct_field_names(
|
||||
&self,
|
||||
id: DefIndex,
|
||||
sess: &Session,
|
||||
) -> Vec<Spanned<ast::Name>> {
|
||||
self.entry(id)
|
||||
.children
|
||||
.decode(self)
|
||||
|
@ -1049,7 +1050,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
None
|
||||
}
|
||||
|
||||
pub fn get_inherent_implementations_for_type(
|
||||
crate fn get_inherent_implementations_for_type(
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
id: DefIndex,
|
||||
|
@ -1060,7 +1061,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
.map(|index| self.local_def_id(index)))
|
||||
}
|
||||
|
||||
pub fn get_implementations_for_trait(
|
||||
crate fn get_implementations_for_trait(
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
filter: Option<DefId>,
|
||||
|
@ -1091,7 +1092,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_trait_of_item(&self, id: DefIndex) -> Option<DefId> {
|
||||
crate fn get_trait_of_item(&self, id: DefIndex) -> Option<DefId> {
|
||||
let def_key = self.def_key(id);
|
||||
match def_key.disambiguated_data.data {
|
||||
DefPathData::TypeNs(..) | DefPathData::ValueNs(..) => (),
|
||||
|
@ -1108,7 +1109,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
|
||||
|
||||
pub fn get_native_libraries(&self, sess: &Session) -> Vec<NativeLibrary> {
|
||||
crate fn get_native_libraries(&self, sess: &Session) -> Vec<NativeLibrary> {
|
||||
if self.is_proc_macro_crate() {
|
||||
// Proc macro crates do not have any *target* native libraries.
|
||||
vec![]
|
||||
|
@ -1117,7 +1118,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_foreign_modules(&self, tcx: TyCtxt<'tcx>) -> &'tcx [ForeignModule] {
|
||||
crate fn get_foreign_modules(&self, tcx: TyCtxt<'tcx>) -> &'tcx [ForeignModule] {
|
||||
if self.is_proc_macro_crate() {
|
||||
// Proc macro crates do not have any *target* foreign modules.
|
||||
&[]
|
||||
|
@ -1126,7 +1127,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_dylib_dependency_formats(
|
||||
crate fn get_dylib_dependency_formats(
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> &'tcx [(CrateNum, LinkagePreference)] {
|
||||
|
@ -1140,7 +1141,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}))
|
||||
}
|
||||
|
||||
pub fn get_missing_lang_items(&self, tcx: TyCtxt<'tcx>) -> &'tcx [lang_items::LangItem] {
|
||||
crate fn get_missing_lang_items(&self, tcx: TyCtxt<'tcx>) -> &'tcx [lang_items::LangItem] {
|
||||
if self.is_proc_macro_crate() {
|
||||
// Proc macro crates do not depend on any target weak lang-items.
|
||||
&[]
|
||||
|
@ -1151,7 +1152,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_fn_param_names(&self, id: DefIndex) -> Vec<ast::Name> {
|
||||
crate fn get_fn_param_names(&self, id: DefIndex) -> Vec<ast::Name> {
|
||||
let param_names = match self.entry(id).kind {
|
||||
EntryKind::Fn(data) |
|
||||
EntryKind::ForeignFn(data) => data.decode(self).param_names,
|
||||
|
@ -1161,7 +1162,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
param_names.decode(self).collect()
|
||||
}
|
||||
|
||||
pub fn exported_symbols(
|
||||
crate fn exported_symbols(
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
) -> Vec<(ExportedSymbol<'tcx>, SymbolExportLevel)> {
|
||||
|
@ -1174,7 +1175,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_rendered_const(&self, id: DefIndex) -> String {
|
||||
crate fn get_rendered_const(&self, id: DefIndex) -> String {
|
||||
match self.entry(id).kind {
|
||||
EntryKind::Const(_, data) |
|
||||
EntryKind::AssocConst(_, _, data) => data.decode(self).0,
|
||||
|
@ -1182,7 +1183,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_macro(&self, id: DefIndex) -> MacroDef {
|
||||
crate fn get_macro(&self, id: DefIndex) -> MacroDef {
|
||||
let entry = self.entry(id);
|
||||
match entry.kind {
|
||||
EntryKind::MacroDef(macro_def) => macro_def.decode(self),
|
||||
|
@ -1200,7 +1201,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
constness == hir::Constness::Const
|
||||
}
|
||||
|
||||
pub fn asyncness(&self, id: DefIndex) -> hir::IsAsync {
|
||||
crate fn asyncness(&self, id: DefIndex) -> hir::IsAsync {
|
||||
match self.entry(id).kind {
|
||||
EntryKind::Fn(data) => data.decode(self).asyncness,
|
||||
EntryKind::Method(data) => data.decode(self).fn_data.asyncness,
|
||||
|
@ -1209,7 +1210,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_foreign_item(&self, id: DefIndex) -> bool {
|
||||
crate fn is_foreign_item(&self, id: DefIndex) -> bool {
|
||||
match self.entry(id).kind {
|
||||
EntryKind::ForeignImmStatic |
|
||||
EntryKind::ForeignMutStatic |
|
||||
|
@ -1228,7 +1229,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn fn_sig(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> ty::PolyFnSig<'tcx> {
|
||||
crate fn fn_sig(&self, id: DefIndex, tcx: TyCtxt<'tcx>) -> ty::PolyFnSig<'tcx> {
|
||||
let sig = match self.entry(id).kind {
|
||||
EntryKind::Fn(data) |
|
||||
EntryKind::ForeignFn(data) => data.decode(self).sig,
|
||||
|
@ -1242,7 +1243,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn def_key(&self, index: DefIndex) -> DefKey {
|
||||
crate fn def_key(&self, index: DefIndex) -> DefKey {
|
||||
let mut key = self.def_path_table.def_key(index);
|
||||
if self.is_proc_macro(index) {
|
||||
let name = self.raw_proc_macro(index).name();
|
||||
|
@ -1252,13 +1253,13 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
}
|
||||
|
||||
// Returns the path leading to the thing with this `id`.
|
||||
pub fn def_path(&self, id: DefIndex) -> DefPath {
|
||||
crate fn def_path(&self, id: DefIndex) -> DefPath {
|
||||
debug!("def_path(cnum={:?}, id={:?})", self.cnum, id);
|
||||
DefPath::make(self.cnum, id, |parent| self.def_key(parent))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn def_path_hash(&self, index: DefIndex) -> DefPathHash {
|
||||
crate fn def_path_hash(&self, index: DefIndex) -> DefPathHash {
|
||||
self.def_path_table.def_path_hash(index)
|
||||
}
|
||||
|
||||
|
@ -1287,9 +1288,10 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
///
|
||||
/// Proc macro crates don't currently export spans, so this function does not have
|
||||
/// to work for them.
|
||||
pub fn imported_source_files(&'a self,
|
||||
local_source_map: &source_map::SourceMap)
|
||||
-> ReadGuard<'a, Vec<cstore::ImportedSourceFile>> {
|
||||
fn imported_source_files(
|
||||
&'a self,
|
||||
local_source_map: &source_map::SourceMap,
|
||||
) -> ReadGuard<'a, Vec<cstore::ImportedSourceFile>> {
|
||||
{
|
||||
let source_files = self.source_map_import_info.borrow();
|
||||
if !source_files.is_empty() {
|
||||
|
|
|
@ -60,7 +60,7 @@ use rustc::ty::TyCtxt;
|
|||
use rustc::util::nodemap::FxHashMap;
|
||||
use rustc_target::spec::PanicStrategy;
|
||||
|
||||
pub fn calculate(tcx: TyCtxt<'_>) -> Dependencies {
|
||||
crate fn calculate(tcx: TyCtxt<'_>) -> Dependencies {
|
||||
tcx.sess.crate_types.borrow().iter().map(|&ty| {
|
||||
let linkage = calculate_type(tcx, ty);
|
||||
verify_ok(tcx, &linkage);
|
||||
|
|
|
@ -32,30 +32,6 @@ impl DynamicLibrary {
|
|||
}
|
||||
}
|
||||
|
||||
/// Loads a dynamic library into the global namespace (RTLD_GLOBAL on Unix)
|
||||
/// and do it now (don't use RTLD_LAZY on Unix).
|
||||
pub fn open_global_now(filename: &Path) -> Result<DynamicLibrary, String> {
|
||||
let maybe_library = dl::open_global_now(filename.as_os_str());
|
||||
match maybe_library {
|
||||
Err(err) => Err(err),
|
||||
Ok(handle) => Ok(DynamicLibrary { handle })
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the environment variable for this process's dynamic library
|
||||
/// search path
|
||||
pub fn envvar() -> &'static str {
|
||||
if cfg!(windows) {
|
||||
"PATH"
|
||||
} else if cfg!(target_os = "macos") {
|
||||
"DYLD_LIBRARY_PATH"
|
||||
} else if cfg!(target_os = "haiku") {
|
||||
"LIBRARY_PATH"
|
||||
} else {
|
||||
"LD_LIBRARY_PATH"
|
||||
}
|
||||
}
|
||||
|
||||
/// Accesses the value at the symbol of the dynamic library.
|
||||
pub unsafe fn symbol<T>(&self, symbol: &str) -> Result<*mut T, String> {
|
||||
// This function should have a lifetime constraint of 'a on
|
||||
|
@ -83,7 +59,7 @@ mod dl {
|
|||
use std::ptr;
|
||||
use std::str;
|
||||
|
||||
pub fn open(filename: Option<&OsStr>) -> Result<*mut u8, String> {
|
||||
pub(super) fn open(filename: Option<&OsStr>) -> Result<*mut u8, String> {
|
||||
check_for_errors_in(|| {
|
||||
unsafe {
|
||||
match filename {
|
||||
|
@ -94,13 +70,6 @@ mod dl {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn open_global_now(filename: &OsStr) -> Result<*mut u8, String> {
|
||||
check_for_errors_in(|| unsafe {
|
||||
let s = CString::new(filename.as_bytes()).unwrap();
|
||||
libc::dlopen(s.as_ptr(), libc::RTLD_GLOBAL | libc::RTLD_NOW) as *mut u8
|
||||
})
|
||||
}
|
||||
|
||||
unsafe fn open_external(filename: &OsStr) -> *mut u8 {
|
||||
let s = CString::new(filename.as_bytes()).unwrap();
|
||||
libc::dlopen(s.as_ptr(), libc::RTLD_LAZY) as *mut u8
|
||||
|
@ -110,8 +79,8 @@ mod dl {
|
|||
libc::dlopen(ptr::null(), libc::RTLD_LAZY) as *mut u8
|
||||
}
|
||||
|
||||
pub fn check_for_errors_in<T, F>(f: F) -> Result<T, String> where
|
||||
F: FnOnce() -> T,
|
||||
fn check_for_errors_in<T, F>(f: F) -> Result<T, String>
|
||||
where F: FnOnce() -> T,
|
||||
{
|
||||
use std::sync::{Mutex, Once};
|
||||
static INIT: Once = Once::new();
|
||||
|
@ -139,14 +108,15 @@ mod dl {
|
|||
}
|
||||
}
|
||||
|
||||
pub unsafe fn symbol(handle: *mut u8,
|
||||
symbol: *const libc::c_char)
|
||||
-> Result<*mut u8, String> {
|
||||
pub(super) unsafe fn symbol(
|
||||
handle: *mut u8,
|
||||
symbol: *const libc::c_char,
|
||||
) -> Result<*mut u8, String> {
|
||||
check_for_errors_in(|| {
|
||||
libc::dlsym(handle as *mut libc::c_void, symbol) as *mut u8
|
||||
})
|
||||
}
|
||||
pub unsafe fn close(handle: *mut u8) {
|
||||
pub(super) unsafe fn close(handle: *mut u8) {
|
||||
libc::dlclose(handle as *mut libc::c_void); ()
|
||||
}
|
||||
}
|
||||
|
@ -178,11 +148,7 @@ mod dl {
|
|||
fn FreeLibrary(handle: HMODULE) -> BOOL;
|
||||
}
|
||||
|
||||
pub fn open_global_now(filename: &OsStr) -> Result<*mut u8, String> {
|
||||
open(Some(filename))
|
||||
}
|
||||
|
||||
pub fn open(filename: Option<&OsStr>) -> Result<*mut u8, String> {
|
||||
pub(super) fn open(filename: Option<&OsStr>) -> Result<*mut u8, String> {
|
||||
// disable "dll load failed" error dialog.
|
||||
let prev_error_mode = unsafe {
|
||||
// SEM_FAILCRITICALERRORS 0x01
|
||||
|
@ -225,14 +191,15 @@ mod dl {
|
|||
result
|
||||
}
|
||||
|
||||
pub unsafe fn symbol(handle: *mut u8,
|
||||
symbol: *const c_char)
|
||||
-> Result<*mut u8, String> {
|
||||
pub(super) unsafe fn symbol(
|
||||
handle: *mut u8,
|
||||
symbol: *const c_char,
|
||||
) -> Result<*mut u8, String> {
|
||||
let ptr = GetProcAddress(handle as HMODULE, symbol) as *mut u8;
|
||||
ptr_result(ptr)
|
||||
}
|
||||
|
||||
pub unsafe fn close(handle: *mut u8) {
|
||||
pub(super) unsafe fn close(handle: *mut u8) {
|
||||
FreeLibrary(handle as HMODULE);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,9 +42,9 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor;
|
|||
use rustc::hir::intravisit::{Visitor, NestedVisitorMap};
|
||||
use rustc::hir::intravisit;
|
||||
|
||||
pub struct EncodeContext<'tcx> {
|
||||
struct EncodeContext<'tcx> {
|
||||
opaque: opaque::Encoder,
|
||||
pub tcx: TyCtxt<'tcx>,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
||||
entries_index: Index<'tcx>,
|
||||
|
||||
|
@ -313,11 +313,12 @@ impl<'tcx> EncodeContext<'tcx> {
|
|||
/// the `Entry` (which may point to other encoded information)
|
||||
/// and will then record the `Lazy<Entry>` for use in the index.
|
||||
// FIXME(eddyb) remove this.
|
||||
pub fn record<DATA>(&mut self,
|
||||
id: DefId,
|
||||
op: impl FnOnce(&mut Self, DATA) -> Entry<'tcx>,
|
||||
data: DATA)
|
||||
{
|
||||
fn record<DATA>(
|
||||
&mut self,
|
||||
id: DefId,
|
||||
op: impl FnOnce(&mut Self, DATA) -> Entry<'tcx>,
|
||||
data: DATA,
|
||||
) {
|
||||
assert!(id.is_local());
|
||||
|
||||
let entry = op(self, data);
|
||||
|
@ -1920,7 +1921,7 @@ impl<'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'tcx> {
|
|||
// will allow us to slice the metadata to the precise length that we just
|
||||
// generated regardless of trailing bytes that end up in it.
|
||||
|
||||
pub fn encode_metadata(tcx: TyCtxt<'_>) -> EncodedMetadata {
|
||||
crate fn encode_metadata(tcx: TyCtxt<'_>) -> EncodedMetadata {
|
||||
let mut encoder = opaque::Encoder::new(vec![]);
|
||||
encoder.emit_raw_bytes(METADATA_HEADER);
|
||||
|
||||
|
@ -1962,7 +1963,7 @@ pub fn encode_metadata(tcx: TyCtxt<'_>) -> EncodedMetadata {
|
|||
EncodedMetadata { raw_data: result }
|
||||
}
|
||||
|
||||
pub fn get_repr_options(tcx: TyCtxt<'_>, did: DefId) -> ReprOptions {
|
||||
fn get_repr_options(tcx: TyCtxt<'_>, did: DefId) -> ReprOptions {
|
||||
let ty = tcx.type_of(did);
|
||||
match ty.kind {
|
||||
ty::Adt(ref def, _) => return def.repr,
|
||||
|
|
|
@ -3,7 +3,7 @@ use rustc::hir;
|
|||
use rustc::middle::cstore::ForeignModule;
|
||||
use rustc::ty::TyCtxt;
|
||||
|
||||
pub fn collect(tcx: TyCtxt<'_>) -> Vec<ForeignModule> {
|
||||
crate fn collect(tcx: TyCtxt<'_>) -> Vec<ForeignModule> {
|
||||
let mut collector = Collector {
|
||||
tcx,
|
||||
modules: Vec::new(),
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::u32;
|
|||
use log::debug;
|
||||
|
||||
/// Helper trait, for encoding to, and decoding from, a fixed number of bytes.
|
||||
pub trait FixedSizeEncoding {
|
||||
trait FixedSizeEncoding {
|
||||
const BYTE_LEN: usize;
|
||||
|
||||
// FIXME(eddyb) convert to and from `[u8; Self::BYTE_LEN]` instead,
|
||||
|
@ -75,25 +75,25 @@ impl FixedSizeEncoding for u32 {
|
|||
/// `u32::MAX`. Whenever an index is visited, we fill in the
|
||||
/// appropriate spot by calling `record_position`. We should never
|
||||
/// visit the same index twice.
|
||||
pub struct Index<'tcx> {
|
||||
crate struct Index<'tcx> {
|
||||
positions: Vec<u8>,
|
||||
_marker: PhantomData<&'tcx ()>,
|
||||
}
|
||||
|
||||
impl Index<'tcx> {
|
||||
pub fn new(max_index: usize) -> Self {
|
||||
crate fn new(max_index: usize) -> Self {
|
||||
Index {
|
||||
positions: vec![0xff; max_index * 4],
|
||||
_marker: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn record(&mut self, def_id: DefId, entry: Lazy<Entry<'tcx>>) {
|
||||
crate fn record(&mut self, def_id: DefId, entry: Lazy<Entry<'tcx>>) {
|
||||
assert!(def_id.is_local());
|
||||
self.record_index(def_id.index, entry);
|
||||
}
|
||||
|
||||
pub fn record_index(&mut self, item: DefIndex, entry: Lazy<Entry<'tcx>>) {
|
||||
fn record_index(&mut self, item: DefIndex, entry: Lazy<Entry<'tcx>>) {
|
||||
assert!(entry.position < (u32::MAX as usize));
|
||||
let position = entry.position as u32;
|
||||
let array_index = item.index();
|
||||
|
@ -108,7 +108,7 @@ impl Index<'tcx> {
|
|||
position.write_to_bytes_at(positions, array_index)
|
||||
}
|
||||
|
||||
pub fn write_index(&self, buf: &mut Encoder) -> Lazy<[Self]> {
|
||||
crate fn write_index(&self, buf: &mut Encoder) -> Lazy<[Self]> {
|
||||
let pos = buf.position();
|
||||
|
||||
// First we write the length of the lower range ...
|
||||
|
@ -123,7 +123,7 @@ impl Lazy<[Index<'tcx>]> {
|
|||
/// Given the metadata, extract out the offset of a particular
|
||||
/// DefIndex (if any).
|
||||
#[inline(never)]
|
||||
pub fn lookup(&self, bytes: &[u8], def_index: DefIndex) -> Option<Lazy<Entry<'tcx>>> {
|
||||
crate fn lookup(&self, bytes: &[u8], def_index: DefIndex) -> Option<Lazy<Entry<'tcx>>> {
|
||||
let bytes = &bytes[self.position..];
|
||||
debug!("Index::lookup: index={:?} len={:?}",
|
||||
def_index,
|
||||
|
|
|
@ -4,7 +4,7 @@ use rustc::ty::TyCtxt;
|
|||
use rustc_target::spec::abi::Abi;
|
||||
use syntax::symbol::sym;
|
||||
|
||||
pub fn collect(tcx: TyCtxt<'_>) -> Vec<String> {
|
||||
crate fn collect(tcx: TyCtxt<'_>) -> Vec<String> {
|
||||
let mut collector = Collector {
|
||||
args: Vec::new(),
|
||||
};
|
||||
|
|
|
@ -212,12 +212,13 @@
|
|||
//! no means all of the necessary details. Take a look at the rest of
|
||||
//! metadata::locator or metadata::creader for all the juicy details!
|
||||
|
||||
use crate::cstore::{MetadataRef, MetadataBlob};
|
||||
use crate::cstore::{MetadataBlob, CStore};
|
||||
use crate::creader::Library;
|
||||
use crate::schema::{METADATA_HEADER, rustc_version};
|
||||
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_data_structures::svh::Svh;
|
||||
use rustc_data_structures::sync::MetadataRef;
|
||||
use rustc::middle::cstore::MetadataLoader;
|
||||
use rustc::session::{config, Session};
|
||||
use rustc::session::filesearch::{FileSearch, FileMatches, FileDoesntMatch};
|
||||
|
@ -245,13 +246,13 @@ use rustc_data_structures::owning_ref::OwningRef;
|
|||
use log::{debug, info, warn};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct CrateMismatch {
|
||||
crate struct CrateMismatch {
|
||||
path: PathBuf,
|
||||
got: String,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Context<'a> {
|
||||
crate struct Context<'a> {
|
||||
pub sess: &'a Session,
|
||||
pub span: Span,
|
||||
pub crate_name: Symbol,
|
||||
|
@ -272,7 +273,7 @@ pub struct Context<'a> {
|
|||
pub metadata_loader: &'a dyn MetadataLoader,
|
||||
}
|
||||
|
||||
pub struct CratePaths {
|
||||
crate struct CratePaths {
|
||||
pub ident: String,
|
||||
pub dylib: Option<PathBuf>,
|
||||
pub rlib: Option<PathBuf>,
|
||||
|
@ -303,7 +304,7 @@ impl CratePaths {
|
|||
}
|
||||
|
||||
impl<'a> Context<'a> {
|
||||
pub fn reset(&mut self) {
|
||||
crate fn reset(&mut self) {
|
||||
self.rejected_via_hash.clear();
|
||||
self.rejected_via_triple.clear();
|
||||
self.rejected_via_kind.clear();
|
||||
|
@ -311,7 +312,7 @@ impl<'a> Context<'a> {
|
|||
self.rejected_via_filename.clear();
|
||||
}
|
||||
|
||||
pub fn maybe_load_library_crate(&mut self) -> Option<Library> {
|
||||
crate fn maybe_load_library_crate(&mut self) -> Option<Library> {
|
||||
let mut seen_paths = FxHashSet::default();
|
||||
match self.extra_filename {
|
||||
Some(s) => self.find_library_crate(s, &mut seen_paths)
|
||||
|
@ -320,7 +321,7 @@ impl<'a> Context<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn report_errs(self) -> ! {
|
||||
crate fn report_errs(self) -> ! {
|
||||
let add = match self.root {
|
||||
None => String::new(),
|
||||
Some(r) => format!(" which `{}` depends on", r.ident),
|
||||
|
@ -931,7 +932,7 @@ fn get_metadata_section_imp(target: &Target,
|
|||
/// A diagnostic function for dumping crate metadata to an output stream.
|
||||
pub fn list_file_metadata(target: &Target,
|
||||
path: &Path,
|
||||
loader: &dyn MetadataLoader,
|
||||
cstore: &CStore,
|
||||
out: &mut dyn io::Write)
|
||||
-> io::Result<()> {
|
||||
let filename = path.file_name().unwrap().to_str().unwrap();
|
||||
|
@ -942,7 +943,7 @@ pub fn list_file_metadata(target: &Target,
|
|||
} else {
|
||||
CrateFlavor::Dylib
|
||||
};
|
||||
match get_metadata_section(target, flavor, path, loader) {
|
||||
match get_metadata_section(target, flavor, path, &*cstore.metadata_loader) {
|
||||
Ok(metadata) => metadata.list_crate_metadata(out),
|
||||
Err(msg) => write!(out, "{}\n", msg),
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ use syntax::feature_gate::{self, GateIssue};
|
|||
use syntax::symbol::{kw, sym, Symbol};
|
||||
use syntax::{span_err, struct_span_err};
|
||||
|
||||
pub fn collect(tcx: TyCtxt<'_>) -> Vec<NativeLibrary> {
|
||||
crate fn collect(tcx: TyCtxt<'_>) -> Vec<NativeLibrary> {
|
||||
let mut collector = Collector {
|
||||
tcx,
|
||||
libs: Vec::new(),
|
||||
|
@ -21,7 +21,7 @@ pub fn collect(tcx: TyCtxt<'_>) -> Vec<NativeLibrary> {
|
|||
return collector.libs;
|
||||
}
|
||||
|
||||
pub fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool {
|
||||
crate fn relevant_lib(sess: &Session, lib: &NativeLibrary) -> bool {
|
||||
match lib.cfg {
|
||||
Some(ref cfg) => attr::cfg_matches(cfg, &sess.parse_sess, None),
|
||||
None => true,
|
||||
|
|
|
@ -21,7 +21,7 @@ use syntax_pos::{self, Span};
|
|||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
pub fn rustc_version() -> String {
|
||||
crate fn rustc_version() -> String {
|
||||
format!("rustc {}",
|
||||
option_env!("CFG_VERSION").unwrap_or("unknown version"))
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ pub fn rustc_version() -> String {
|
|||
/// Metadata encoding version.
|
||||
/// N.B., increment this if you change the format of metadata such that
|
||||
/// the rustc version can't be found to compare with `rustc_version()`.
|
||||
pub const METADATA_VERSION: u8 = 4;
|
||||
const METADATA_VERSION: u8 = 4;
|
||||
|
||||
/// Metadata header which includes `METADATA_VERSION`.
|
||||
/// To get older versions of rustc to ignore this metadata,
|
||||
|
@ -39,12 +39,12 @@ pub const METADATA_VERSION: u8 = 4;
|
|||
/// This header is followed by the position of the `CrateRoot`,
|
||||
/// which is encoded as a 32-bit big-endian unsigned integer,
|
||||
/// and further followed by the rustc version string.
|
||||
pub const METADATA_HEADER: &[u8; 12] =
|
||||
crate const METADATA_HEADER: &[u8; 12] =
|
||||
&[0, 0, 0, 0, b'r', b'u', b's', b't', 0, 0, 0, METADATA_VERSION];
|
||||
|
||||
/// Additional metadata for a `Lazy<T>` where `T` may not be `Sized`,
|
||||
/// e.g. for `Lazy<[T]>`, this is the length (count of `T` values).
|
||||
pub trait LazyMeta {
|
||||
crate trait LazyMeta {
|
||||
type Meta: Copy + 'static;
|
||||
|
||||
/// Returns the minimum encoded size.
|
||||
|
@ -98,7 +98,7 @@ impl<T> LazyMeta for [T] {
|
|||
#[must_use]
|
||||
// FIXME(#59875) the `Meta` parameter only exists to dodge
|
||||
// invariance wrt `T` (coming from the `meta: T::Meta` field).
|
||||
pub struct Lazy<T, Meta = <T as LazyMeta>::Meta>
|
||||
crate struct Lazy<T, Meta = <T as LazyMeta>::Meta>
|
||||
where T: ?Sized + LazyMeta<Meta = Meta>,
|
||||
Meta: 'static + Copy,
|
||||
{
|
||||
|
@ -108,7 +108,7 @@ pub struct Lazy<T, Meta = <T as LazyMeta>::Meta>
|
|||
}
|
||||
|
||||
impl<T: ?Sized + LazyMeta> Lazy<T> {
|
||||
pub fn from_position_and_meta(position: usize, meta: T::Meta) -> Lazy<T> {
|
||||
crate fn from_position_and_meta(position: usize, meta: T::Meta) -> Lazy<T> {
|
||||
Lazy {
|
||||
position,
|
||||
meta,
|
||||
|
@ -118,13 +118,13 @@ impl<T: ?Sized + LazyMeta> Lazy<T> {
|
|||
}
|
||||
|
||||
impl<T> Lazy<T> {
|
||||
pub fn from_position(position: usize) -> Lazy<T> {
|
||||
crate fn from_position(position: usize) -> Lazy<T> {
|
||||
Lazy::from_position_and_meta(position, ())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Lazy<[T]> {
|
||||
pub fn empty() -> Lazy<[T]> {
|
||||
crate fn empty() -> Lazy<[T]> {
|
||||
Lazy::from_position_and_meta(0, 0)
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ impl<T: ?Sized + LazyMeta> rustc_serialize::UseSpecializedDecodable for Lazy<T>
|
|||
|
||||
/// Encoding / decoding state for `Lazy`.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
pub enum LazyState {
|
||||
crate enum LazyState {
|
||||
/// Outside of a metadata node.
|
||||
NoNode,
|
||||
|
||||
|
@ -156,7 +156,7 @@ pub enum LazyState {
|
|||
}
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct CrateRoot<'tcx> {
|
||||
crate struct CrateRoot<'tcx> {
|
||||
pub name: Symbol,
|
||||
pub triple: TargetTriple,
|
||||
pub extra_filename: String,
|
||||
|
@ -202,7 +202,7 @@ pub struct CrateRoot<'tcx> {
|
|||
}
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct CrateDep {
|
||||
crate struct CrateDep {
|
||||
pub name: ast::Name,
|
||||
pub hash: Svh,
|
||||
pub kind: DepKind,
|
||||
|
@ -210,13 +210,13 @@ pub struct CrateDep {
|
|||
}
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct TraitImpls {
|
||||
crate struct TraitImpls {
|
||||
pub trait_id: (u32, DefIndex),
|
||||
pub impls: Lazy<[DefIndex]>,
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct Entry<'tcx> {
|
||||
crate struct Entry<'tcx> {
|
||||
pub kind: EntryKind<'tcx>,
|
||||
pub visibility: Lazy<ty::Visibility>,
|
||||
pub span: Lazy<Span>,
|
||||
|
@ -237,7 +237,7 @@ pub struct Entry<'tcx> {
|
|||
}
|
||||
|
||||
#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
|
||||
pub enum EntryKind<'tcx> {
|
||||
crate enum EntryKind<'tcx> {
|
||||
Const(ConstQualif, Lazy<RenderedConst>),
|
||||
ImmStatic,
|
||||
MutStatic,
|
||||
|
@ -272,28 +272,28 @@ pub enum EntryKind<'tcx> {
|
|||
|
||||
/// Additional data for EntryKind::Const and EntryKind::AssocConst
|
||||
#[derive(Clone, Copy, RustcEncodable, RustcDecodable)]
|
||||
pub struct ConstQualif {
|
||||
crate struct ConstQualif {
|
||||
pub mir: u8,
|
||||
}
|
||||
|
||||
/// Contains a constant which has been rendered to a String.
|
||||
/// Used by rustdoc.
|
||||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct RenderedConst(pub String);
|
||||
crate struct RenderedConst(pub String);
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct ModData {
|
||||
crate struct ModData {
|
||||
pub reexports: Lazy<[def::Export<hir::HirId>]>,
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct MacroDef {
|
||||
crate struct MacroDef {
|
||||
pub body: String,
|
||||
pub legacy: bool,
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct FnData<'tcx> {
|
||||
crate struct FnData<'tcx> {
|
||||
pub asyncness: hir::IsAsync,
|
||||
pub constness: hir::Constness,
|
||||
pub param_names: Lazy<[ast::Name]>,
|
||||
|
@ -301,7 +301,7 @@ pub struct FnData<'tcx> {
|
|||
}
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct VariantData<'tcx> {
|
||||
crate struct VariantData<'tcx> {
|
||||
pub ctor_kind: CtorKind,
|
||||
pub discr: ty::VariantDiscr,
|
||||
/// If this is unit or tuple-variant/struct, then this is the index of the ctor id.
|
||||
|
@ -312,7 +312,7 @@ pub struct VariantData<'tcx> {
|
|||
}
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct TraitData<'tcx> {
|
||||
crate struct TraitData<'tcx> {
|
||||
pub unsafety: hir::Unsafety,
|
||||
pub paren_sugar: bool,
|
||||
pub has_auto_impl: bool,
|
||||
|
@ -321,12 +321,12 @@ pub struct TraitData<'tcx> {
|
|||
}
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct TraitAliasData<'tcx> {
|
||||
crate struct TraitAliasData<'tcx> {
|
||||
pub super_predicates: Lazy<ty::GenericPredicates<'tcx>>,
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct ImplData<'tcx> {
|
||||
crate struct ImplData<'tcx> {
|
||||
pub polarity: ty::ImplPolarity,
|
||||
pub defaultness: hir::Defaultness,
|
||||
pub parent_impl: Option<DefId>,
|
||||
|
@ -341,7 +341,7 @@ pub struct ImplData<'tcx> {
|
|||
/// is a trait or an impl and whether, in a trait, it has
|
||||
/// a default, or an in impl, whether it's marked "default".
|
||||
#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
|
||||
pub enum AssocContainer {
|
||||
crate enum AssocContainer {
|
||||
TraitRequired,
|
||||
TraitWithDefault,
|
||||
ImplDefault,
|
||||
|
@ -349,7 +349,7 @@ pub enum AssocContainer {
|
|||
}
|
||||
|
||||
impl AssocContainer {
|
||||
pub fn with_def_id(&self, def_id: DefId) -> ty::AssocItemContainer {
|
||||
crate fn with_def_id(&self, def_id: DefId) -> ty::AssocItemContainer {
|
||||
match *self {
|
||||
AssocContainer::TraitRequired |
|
||||
AssocContainer::TraitWithDefault => ty::TraitContainer(def_id),
|
||||
|
@ -359,7 +359,7 @@ impl AssocContainer {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn defaultness(&self) -> hir::Defaultness {
|
||||
crate fn defaultness(&self) -> hir::Defaultness {
|
||||
match *self {
|
||||
AssocContainer::TraitRequired => hir::Defaultness::Default {
|
||||
has_value: false,
|
||||
|
@ -376,22 +376,22 @@ impl AssocContainer {
|
|||
}
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct MethodData<'tcx> {
|
||||
crate struct MethodData<'tcx> {
|
||||
pub fn_data: FnData<'tcx>,
|
||||
pub container: AssocContainer,
|
||||
pub has_self: bool,
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct ClosureData<'tcx> {
|
||||
crate struct ClosureData<'tcx> {
|
||||
pub sig: Lazy<ty::PolyFnSig<'tcx>>,
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, RustcDecodable)]
|
||||
pub struct GeneratorData<'tcx> {
|
||||
crate struct GeneratorData<'tcx> {
|
||||
pub layout: mir::GeneratorLayout<'tcx>,
|
||||
}
|
||||
|
||||
// Tags used for encoding Spans:
|
||||
pub const TAG_VALID_SPAN: u8 = 0;
|
||||
pub const TAG_INVALID_SPAN: u8 = 1;
|
||||
crate const TAG_VALID_SPAN: u8 = 0;
|
||||
crate const TAG_INVALID_SPAN: u8 = 1;
|
||||
|
|
|
@ -104,8 +104,7 @@ impl<'a> Resolver<'a> {
|
|||
return self.module_map[&def_id]
|
||||
}
|
||||
|
||||
let macros_only = self.cstore.dep_kind_untracked(def_id.krate).macros_only();
|
||||
if let Some(&module) = self.extern_module_map.get(&(def_id, macros_only)) {
|
||||
if let Some(&module) = self.extern_module_map.get(&def_id) {
|
||||
return module;
|
||||
}
|
||||
|
||||
|
@ -121,7 +120,7 @@ impl<'a> Resolver<'a> {
|
|||
let module = self.arenas.alloc_module(ModuleData::new(
|
||||
parent, kind, def_id, ExpnId::root(), DUMMY_SP
|
||||
));
|
||||
self.extern_module_map.insert((def_id, macros_only), module);
|
||||
self.extern_module_map.insert(def_id, module);
|
||||
module
|
||||
}
|
||||
|
||||
|
|
|
@ -878,7 +878,7 @@ pub struct Resolver<'a> {
|
|||
/// language items.
|
||||
empty_module: Module<'a>,
|
||||
module_map: FxHashMap<DefId, Module<'a>>,
|
||||
extern_module_map: FxHashMap<(DefId, bool /* MacrosOnly? */), Module<'a>>,
|
||||
extern_module_map: FxHashMap<DefId, Module<'a>>,
|
||||
binding_parent_modules: FxHashMap<PtrKey<'a, NameBinding<'a>>, Module<'a>>,
|
||||
|
||||
/// Maps glob imports to the names of items actually imported.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue