未验证 提交 8cbee1c6 编写于 作者: M Mazdak Farrokhzad 提交者: GitHub

Rollup merge of #58255 - taiki-e:librustc_metadata-2018, r=Centril

librustc_metadata => 2018

Transitions `librustc_metadata` to Rust 2018; cc #58099

r? @Centril
......@@ -2,6 +2,7 @@
authors = ["The Rust Project Developers"]
name = "rustc_metadata"
version = "0.0.0"
edition = "2018"
[lib]
name = "rustc_metadata"
......@@ -14,7 +15,7 @@ log = "0.4"
memmap = "0.6"
rustc = { path = "../librustc" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_errors = { path = "../librustc_errors" }
errors = { path = "../librustc_errors", package = "rustc_errors" }
rustc_target = { path = "../librustc_target" }
serialize = { path = "../libserialize" }
stable_deref_trait = "1.0.0"
......
//! Validates all used crates and extern libraries and loads their metadata
use cstore::{self, CStore, CrateSource, MetadataBlob};
use locator::{self, CratePaths};
use decoder::proc_macro_def_path_table;
use schema::CrateRoot;
use crate::cstore::{self, CStore, CrateSource, MetadataBlob};
use crate::locator::{self, CratePaths};
use crate::decoder::proc_macro_def_path_table;
use crate::schema::CrateRoot;
use rustc_data_structures::sync::{Lrc, RwLock, Lock};
use rustc::hir::def_id::CrateNum;
......@@ -29,8 +29,9 @@
use syntax::ext::base::SyntaxExtension;
use syntax::symbol::Symbol;
use syntax::visit;
use syntax::{span_err, span_fatal};
use syntax_pos::{Span, DUMMY_SP};
use log;
use log::{debug, info, log_enabled};
pub struct Library {
pub dylib: Option<(PathBuf, PathKind)>,
......@@ -342,7 +343,7 @@ fn resolve_crate<'b>(
}
}
fn load(&mut self, locate_ctxt: &mut locator::Context) -> Option<LoadResult> {
fn load(&mut self, locate_ctxt: &mut locator::Context<'_>) -> Option<LoadResult> {
let library = locate_ctxt.maybe_load_library_crate()?;
// In the case that we're loading a crate, but not matching
......@@ -427,7 +428,7 @@ fn resolve_crate_deps(&mut self,
// The map from crate numbers in the crate we're resolving to local crate numbers.
// We map 0 and all other holes in the map to our parent crate. The "additional"
// self-dependencies should be harmless.
::std::iter::once(krate).chain(crate_root.crate_deps
std::iter::once(krate).chain(crate_root.crate_deps
.decode(metadata)
.map(|dep| {
info!("resolving dep crate {} hash: `{}` extra filename: `{}`", dep.name, dep.hash,
......@@ -522,7 +523,7 @@ fn read_extension_crate(&mut self, span: Span, orig_name: Symbol, rename: Symbol
fn load_derive_macros(&mut self, root: &CrateRoot, dylib: Option<PathBuf>, span: Span)
-> Vec<(ast::Name, Lrc<SyntaxExtension>)> {
use std::{env, mem};
use dynamic_lib::DynamicLibrary;
use crate::dynamic_lib::DynamicLibrary;
use proc_macro::bridge::client::ProcMacro;
use syntax_ext::deriving::custom::ProcMacroDerive;
use syntax_ext::proc_macro_impl::{AttrProcMacro, BangProcMacro};
......@@ -996,7 +997,7 @@ pub fn process_extern_crate(
item.ident, orig_name);
let orig_name = match orig_name {
Some(orig_name) => {
::validate_crate_name(Some(self.sess), &orig_name.as_str(),
crate::validate_crate_name(Some(self.sess), &orig_name.as_str(),
Some(item.span));
orig_name
}
......
// The crate store - a central repo for information collected about external
// crates and libraries
use schema;
use crate::schema;
use rustc::hir::def_id::{CrateNum, DefIndex};
use rustc::hir::map::definitions::DefPathTable;
use rustc::middle::cstore::{DepKind, ExternCrate, MetadataLoader};
......@@ -19,7 +19,7 @@
pub use rustc::middle::cstore::NativeLibraryKind::*;
pub use rustc::middle::cstore::{CrateSource, LibSource, ForeignModule};
pub use cstore_impl::{provide, provide_extern};
pub use crate::cstore_impl::{provide, provide_extern};
// A map from external crate numbers (as decoded from some crate file) to
// local crate numbers (as generated during this session). Each external
......
use cstore::{self, LoadedMacro};
use encoder;
use link_args;
use native_libs;
use foreign_modules;
use schema;
use crate::cstore::{self, LoadedMacro};
use crate::encoder;
use crate::link_args;
use crate::native_libs;
use crate::foreign_modules;
use crate::schema;
use rustc::ty::query::QueryConfig;
use rustc::middle::cstore::{CrateStore, DepKind,
......@@ -51,7 +51,7 @@ pub fn provide_extern<$lt>(providers: &mut Providers<$lt>) {
index: CRATE_DEF_INDEX
});
let dep_node = def_path_hash
.to_dep_node(::rustc::dep_graph::DepKind::CrateMetadata);
.to_dep_node(rustc::dep_graph::DepKind::CrateMetadata);
// The DepNodeIndex of the DepNode::CrateMetadata should be
// cached somewhere, so that we can use read_index().
$tcx.dep_graph.read(dep_node);
......@@ -421,7 +421,7 @@ pub fn load_macro_untracked(&self, id: DefId, sess: &Session) -> LoadedMacro {
use syntax::ext::base::SyntaxExtension;
use syntax_ext::proc_macro_impl::BangProcMacro;
let client = ::proc_macro::bridge::client::Client::expand1(::proc_macro::quote);
let client = proc_macro::bridge::client::Client::expand1(proc_macro::quote);
let ext = SyntaxExtension::ProcMacro {
expander: Box::new(BangProcMacro { client }),
allow_internal_unstable: true,
......
// Decoding metadata from a single crate's metadata
use cstore::{self, CrateMetadata, MetadataBlob, NativeLibrary, ForeignModule};
use schema::*;
use crate::cstore::{self, CrateMetadata, MetadataBlob, NativeLibrary, ForeignModule};
use crate::schema::*;
use rustc_data_structures::sync::{Lrc, ReadGuard};
use rustc::hir::map::{DefKey, DefPath, DefPathData, DefPathHash, Definitions};
......@@ -34,6 +34,7 @@
use syntax::ext::base::{MacroKind, SyntaxExtension};
use syntax::ext::hygiene::Mark;
use syntax_pos::{self, Span, BytePos, Pos, DUMMY_SP, NO_EXPANSION};
use log::debug;
pub struct DecodeContext<'a, 'tcx: 'a> {
opaque: opaque::Decoder<'a>,
......@@ -545,7 +546,7 @@ pub fn get_trait_def(&self, item_id: DefIndex, sess: &Session) -> ty::TraitDef {
fn get_variant(&self,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
item: &Entry,
item: &Entry<'_>,
index: DefIndex,
adt_kind: ty::AdtKind)
-> ty::VariantDef
......
#![allow(non_snake_case)]
use syntax::{register_diagnostic, register_diagnostics, register_long_diagnostics};
register_long_diagnostics! {
E0454: r##"
A link name was given with an empty name. Erroneous code example:
......
......@@ -76,7 +76,6 @@ pub unsafe fn symbol<T>(&self, symbol: &str) -> Result<*mut T, String> {
#[cfg(test)]
mod tests {
use super::*;
use libc;
use std::mem;
#[test]
......@@ -127,7 +126,6 @@ fn test_errors_do_not_crash() {
#[cfg(unix)]
mod dl {
use libc;
use std::ffi::{CStr, OsStr, CString};
use std::os::unix::prelude::*;
use std::ptr;
......
use index::Index;
use index_builder::{FromId, IndexBuilder, Untracked};
use isolated_encoder::IsolatedEncoder;
use schema::*;
use crate::index::Index;
use crate::index_builder::{FromId, IndexBuilder, Untracked};
use crate::isolated_encoder::IsolatedEncoder;
use crate::schema::*;
use rustc::middle::cstore::{LinkagePreference, NativeLibrary,
EncodedMetadata, ForeignModule};
......@@ -34,6 +34,7 @@
use syntax::source_map::Spanned;
use syntax::symbol::keywords;
use syntax_pos::{self, hygiene, FileName, SourceFile, Span};
use log::{debug, trace};
use rustc::hir::{self, PatKind};
use rustc::hir::itemlikevisit::ItemLikeVisitor;
......@@ -1521,7 +1522,7 @@ fn encode_impls(&mut self, _: ()) -> LazySeq<TraitImpls> {
// symbol associated with them (they weren't translated) or if they're an FFI
// definition (as that's not defined in this crate).
fn encode_exported_symbols(&mut self,
exported_symbols: &[(ExportedSymbol, SymbolExportLevel)])
exported_symbols: &[(ExportedSymbol<'_>, SymbolExportLevel)])
-> EncodedExportedSymbols {
// The metadata symbol name is special. It should not show up in
// downstream crates.
......
use schema::*;
use crate::schema::*;
use rustc::hir::def_id::{DefId, DefIndex, DefIndexAddressSpace};
use rustc_serialize::opaque::Encoder;
use std::slice;
use std::u32;
use log::debug;
/// While we are generating the metadata, we also track the position
/// of each DefIndex. It is not required that all definitions appear
......@@ -24,12 +25,12 @@ pub fn new((max_index_lo, max_index_hi): (usize, usize)) -> Index {
}
}
pub fn record(&mut self, def_id: DefId, entry: Lazy<Entry>) {
pub fn record(&mut self, def_id: DefId, entry: Lazy<Entry<'_>>) {
assert!(def_id.is_local());
self.record_index(def_id.index, entry);
}
pub fn record_index(&mut self, item: DefIndex, entry: Lazy<Entry>) {
pub fn record_index(&mut self, item: DefIndex, entry: Lazy<Entry<'_>>) {
assert!(entry.position < (u32::MAX as usize));
let position = entry.position as u32;
let space_index = item.address_space().index();
......
......@@ -45,10 +45,10 @@
//! give a callback fn, rather than taking a closure: it allows us to
//! easily control precisely what data is given to that fn.
use encoder::EncodeContext;
use index::Index;
use schema::*;
use isolated_encoder::IsolatedEncoder;
use crate::encoder::EncodeContext;
use crate::index::Index;
use crate::schema::*;
use crate::isolated_encoder::IsolatedEncoder;
use rustc::hir;
use rustc::hir::def_id::DefId;
......@@ -133,21 +133,21 @@ pub fn into_items(self) -> Index {
/// `DefId` index, or implement the `read` method so that it can add
/// a read of whatever dep-graph nodes are appropriate.
pub trait DepGraphRead {
fn read(&self, tcx: TyCtxt);
fn read(&self, tcx: TyCtxt<'_, '_, '_>);
}
impl DepGraphRead for DefId {
fn read(&self, _tcx: TyCtxt) {}
fn read(&self, _tcx: TyCtxt<'_, '_, '_>) {}
}
impl DepGraphRead for ast::NodeId {
fn read(&self, _tcx: TyCtxt) {}
fn read(&self, _tcx: TyCtxt<'_, '_, '_>) {}
}
impl<T> DepGraphRead for Option<T>
where T: DepGraphRead
{
fn read(&self, tcx: TyCtxt) {
fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
match *self {
Some(ref v) => v.read(tcx),
None => (),
......@@ -158,7 +158,7 @@ fn read(&self, tcx: TyCtxt) {
impl<T> DepGraphRead for [T]
where T: DepGraphRead
{
fn read(&self, tcx: TyCtxt) {
fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
for i in self {
i.read(tcx);
}
......@@ -171,7 +171,7 @@ impl<$($name),*> DepGraphRead for ($($name),*)
where $($name: DepGraphRead),*
{
#[allow(non_snake_case)]
fn read(&self, tcx: TyCtxt) {
fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
let &($(ref $name),*) = self;
$($name.read(tcx);)*
}
......@@ -184,7 +184,7 @@ fn read(&self, tcx: TyCtxt) {
macro_rules! read_hir {
($t:ty) => {
impl<'tcx> DepGraphRead for &'tcx $t {
fn read(&self, tcx: TyCtxt) {
fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
tcx.hir().read(self.id);
}
}
......@@ -208,7 +208,7 @@ fn read(&self, tcx: TyCtxt) {
pub struct Untracked<T>(pub T);
impl<T> DepGraphRead for Untracked<T> {
fn read(&self, _tcx: TyCtxt) {}
fn read(&self, _tcx: TyCtxt<'_, '_, '_>) {}
}
/// Newtype that can be used to package up misc data extracted from a
......@@ -218,7 +218,7 @@ fn read(&self, _tcx: TyCtxt) {}
pub struct FromId<T>(pub ast::NodeId, pub T);
impl<T> DepGraphRead for FromId<T> {
fn read(&self, tcx: TyCtxt) {
fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
tcx.hir().read(self.0);
}
}
use encoder::EncodeContext;
use schema::{Lazy, LazySeq};
use crate::encoder::EncodeContext;
use crate::schema::{Lazy, LazySeq};
use rustc::ty::TyCtxt;
use rustc_serialize::Encodable;
......
......@@ -13,23 +13,15 @@
#![recursion_limit="256"]
#![deny(rust_2018_idioms)]
extern crate libc;
#[macro_use]
extern crate log;
extern crate memmap;
extern crate stable_deref_trait;
#[macro_use]
extern crate syntax;
extern crate syntax_pos;
extern crate flate2;
#[allow(unused_extern_crates)]
extern crate serialize as rustc_serialize; // used by deriving
extern crate rustc_errors as errors;
extern crate syntax_ext;
extern crate proc_macro;
#[macro_use]
extern crate rustc;
extern crate rustc_target;
#[macro_use]
extern crate rustc_data_structures;
......
......@@ -212,9 +212,9 @@
//! 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 cstore::{MetadataRef, MetadataBlob};
use creader::Library;
use schema::{METADATA_HEADER, rustc_version};
use crate::cstore::{MetadataRef, MetadataBlob};
use crate::creader::Library;
use crate::schema::{METADATA_HEADER, rustc_version};
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::svh::Svh;
......@@ -226,6 +226,7 @@
use errors::DiagnosticBuilder;
use syntax::symbol::Symbol;
use syntax::struct_span_err;
use syntax_pos::Span;
use rustc_target::spec::{Target, TargetTriple};
......@@ -241,6 +242,8 @@
use rustc_data_structures::owning_ref::OwningRef;
use log::{debug, info, warn};
pub struct CrateMismatch {
path: PathBuf,
got: String,
......@@ -283,7 +286,7 @@ enum CrateFlavor {
}
impl fmt::Display for CrateFlavor {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match *self {
CrateFlavor::Rlib => "rlib",
CrateFlavor::Rmeta => "rmeta",
......@@ -600,7 +603,7 @@ fn extract_one(&mut self,
}
}
let mut err: Option<DiagnosticBuilder> = None;
let mut err: Option<DiagnosticBuilder<'_>> = None;
for (lib, kind) in m {
info!("{} reading metadata from: {}", flavor, lib.display());
let (hash, metadata) =
......
......@@ -9,6 +9,7 @@
use syntax::source_map::Span;
use syntax::feature_gate::{self, GateIssue};
use syntax::symbol::Symbol;
use syntax::{span_err, struct_span_err};
pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Vec<NativeLibrary> {
let mut collector = Collector {
......
use index;
use crate::index;
use rustc::hir;
use rustc::hir::def::{self, CtorKind};
......@@ -518,7 +518,7 @@ pub enum AssociatedContainer {
ImplFinal,
}
impl_stable_hash_for!(enum ::schema::AssociatedContainer {
impl_stable_hash_for!(enum crate::schema::AssociatedContainer {
TraitRequired,
TraitWithDefault,
ImplDefault,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册