Skip to content

Commit 7267bc2

Browse files
committed
librustc_metadata => 2018
1 parent 1efdda1 commit 7267bc2

15 files changed

+67
-66
lines changed

src/librustc_metadata/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
authors = ["The Rust Project Developers"]
33
name = "rustc_metadata"
44
version = "0.0.0"
5+
edition = "2018"
56

67
[lib]
78
name = "rustc_metadata"
@@ -14,7 +15,7 @@ log = "0.4"
1415
memmap = "0.6"
1516
rustc = { path = "../librustc" }
1617
rustc_data_structures = { path = "../librustc_data_structures" }
17-
rustc_errors = { path = "../librustc_errors" }
18+
errors = { path = "../librustc_errors", package = "rustc_errors" }
1819
rustc_target = { path = "../librustc_target" }
1920
serialize = { path = "../libserialize" }
2021
stable_deref_trait = "1.0.0"

src/librustc_metadata/creader.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! Validates all used crates and extern libraries and loads their metadata
22
3-
use cstore::{self, CStore, CrateSource, MetadataBlob};
4-
use locator::{self, CratePaths};
5-
use decoder::proc_macro_def_path_table;
6-
use schema::CrateRoot;
3+
use crate::cstore::{self, CStore, CrateSource, MetadataBlob};
4+
use crate::locator::{self, CratePaths};
5+
use crate::decoder::proc_macro_def_path_table;
6+
use crate::schema::CrateRoot;
77
use rustc_data_structures::sync::{Lrc, RwLock, Lock};
88

99
use rustc::hir::def_id::CrateNum;
@@ -29,8 +29,9 @@ use syntax::attr;
2929
use syntax::ext::base::SyntaxExtension;
3030
use syntax::symbol::Symbol;
3131
use syntax::visit;
32+
use syntax::{span_err, span_fatal};
3233
use syntax_pos::{Span, DUMMY_SP};
33-
use log;
34+
use log::{debug, info, log_enabled};
3435

3536
pub struct Library {
3637
pub dylib: Option<(PathBuf, PathKind)>,
@@ -342,7 +343,7 @@ impl<'a> CrateLoader<'a> {
342343
}
343344
}
344345

345-
fn load(&mut self, locate_ctxt: &mut locator::Context) -> Option<LoadResult> {
346+
fn load(&mut self, locate_ctxt: &mut locator::Context<'_>) -> Option<LoadResult> {
346347
let library = locate_ctxt.maybe_load_library_crate()?;
347348

348349
// In the case that we're loading a crate, but not matching
@@ -427,7 +428,7 @@ impl<'a> CrateLoader<'a> {
427428
// The map from crate numbers in the crate we're resolving to local crate numbers.
428429
// We map 0 and all other holes in the map to our parent crate. The "additional"
429430
// self-dependencies should be harmless.
430-
::std::iter::once(krate).chain(crate_root.crate_deps
431+
std::iter::once(krate).chain(crate_root.crate_deps
431432
.decode(metadata)
432433
.map(|dep| {
433434
info!("resolving dep crate {} hash: `{}` extra filename: `{}`", dep.name, dep.hash,
@@ -522,7 +523,7 @@ impl<'a> CrateLoader<'a> {
522523
fn load_derive_macros(&mut self, root: &CrateRoot, dylib: Option<PathBuf>, span: Span)
523524
-> Vec<(ast::Name, Lrc<SyntaxExtension>)> {
524525
use std::{env, mem};
525-
use dynamic_lib::DynamicLibrary;
526+
use crate::dynamic_lib::DynamicLibrary;
526527
use proc_macro::bridge::client::ProcMacro;
527528
use syntax_ext::deriving::custom::ProcMacroDerive;
528529
use syntax_ext::proc_macro_impl::{AttrProcMacro, BangProcMacro};
@@ -996,7 +997,7 @@ impl<'a> CrateLoader<'a> {
996997
item.ident, orig_name);
997998
let orig_name = match orig_name {
998999
Some(orig_name) => {
999-
::validate_crate_name(Some(self.sess), &orig_name.as_str(),
1000+
crate::validate_crate_name(Some(self.sess), &orig_name.as_str(),
10001001
Some(item.span));
10011002
orig_name
10021003
}

src/librustc_metadata/cstore.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// The crate store - a central repo for information collected about external
22
// crates and libraries
33

4-
use schema;
4+
use crate::schema;
55
use rustc::hir::def_id::{CrateNum, DefIndex};
66
use rustc::hir::map::definitions::DefPathTable;
77
use rustc::middle::cstore::{DepKind, ExternCrate, MetadataLoader};
@@ -19,7 +19,7 @@ pub use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind, LinkagePrefere
1919
pub use rustc::middle::cstore::NativeLibraryKind::*;
2020
pub use rustc::middle::cstore::{CrateSource, LibSource, ForeignModule};
2121

22-
pub use cstore_impl::{provide, provide_extern};
22+
pub use crate::cstore_impl::{provide, provide_extern};
2323

2424
// A map from external crate numbers (as decoded from some crate file) to
2525
// local crate numbers (as generated during this session). Each external

src/librustc_metadata/cstore_impl.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use cstore::{self, LoadedMacro};
2-
use encoder;
3-
use link_args;
4-
use native_libs;
5-
use foreign_modules;
6-
use schema;
1+
use crate::cstore::{self, LoadedMacro};
2+
use crate::encoder;
3+
use crate::link_args;
4+
use crate::native_libs;
5+
use crate::foreign_modules;
6+
use crate::schema;
77

88
use rustc::ty::query::QueryConfig;
99
use rustc::middle::cstore::{CrateStore, DepKind,
@@ -51,7 +51,7 @@ macro_rules! provide {
5151
index: CRATE_DEF_INDEX
5252
});
5353
let dep_node = def_path_hash
54-
.to_dep_node(::rustc::dep_graph::DepKind::CrateMetadata);
54+
.to_dep_node(rustc::dep_graph::DepKind::CrateMetadata);
5555
// The DepNodeIndex of the DepNode::CrateMetadata should be
5656
// cached somewhere, so that we can use read_index().
5757
$tcx.dep_graph.read(dep_node);
@@ -421,7 +421,7 @@ impl cstore::CStore {
421421
use syntax::ext::base::SyntaxExtension;
422422
use syntax_ext::proc_macro_impl::BangProcMacro;
423423

424-
let client = ::proc_macro::bridge::client::Client::expand1(::proc_macro::quote);
424+
let client = proc_macro::bridge::client::Client::expand1(proc_macro::quote);
425425
let ext = SyntaxExtension::ProcMacro {
426426
expander: Box::new(BangProcMacro { client }),
427427
allow_internal_unstable: true,

src/librustc_metadata/decoder.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Decoding metadata from a single crate's metadata
22

3-
use cstore::{self, CrateMetadata, MetadataBlob, NativeLibrary, ForeignModule};
4-
use schema::*;
3+
use crate::cstore::{self, CrateMetadata, MetadataBlob, NativeLibrary, ForeignModule};
4+
use crate::schema::*;
55

66
use rustc_data_structures::sync::{Lrc, ReadGuard};
77
use rustc::hir::map::{DefKey, DefPath, DefPathData, DefPathHash, Definitions};
@@ -34,6 +34,7 @@ use syntax::symbol::InternedString;
3434
use syntax::ext::base::{MacroKind, SyntaxExtension};
3535
use syntax::ext::hygiene::Mark;
3636
use syntax_pos::{self, Span, BytePos, Pos, DUMMY_SP, NO_EXPANSION};
37+
use log::debug;
3738

3839
pub struct DecodeContext<'a, 'tcx: 'a> {
3940
opaque: opaque::Decoder<'a>,
@@ -545,7 +546,7 @@ impl<'a, 'tcx> CrateMetadata {
545546

546547
fn get_variant(&self,
547548
tcx: TyCtxt<'a, 'tcx, 'tcx>,
548-
item: &Entry,
549+
item: &Entry<'_>,
549550
index: DefIndex,
550551
adt_kind: ty::AdtKind)
551552
-> ty::VariantDef

src/librustc_metadata/diagnostics.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#![allow(non_snake_case)]
22

3+
use syntax::{register_diagnostic, register_diagnostics, register_long_diagnostics};
4+
35
register_long_diagnostics! {
46
E0454: r##"
57
A link name was given with an empty name. Erroneous code example:

src/librustc_metadata/dynamic_lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ impl DynamicLibrary {
7676
#[cfg(test)]
7777
mod tests {
7878
use super::*;
79-
use libc;
8079
use std::mem;
8180

8281
#[test]
@@ -127,7 +126,6 @@ mod tests {
127126

128127
#[cfg(unix)]
129128
mod dl {
130-
use libc;
131129
use std::ffi::{CStr, OsStr, CString};
132130
use std::os::unix::prelude::*;
133131
use std::ptr;

src/librustc_metadata/encoder.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use index::Index;
2-
use index_builder::{FromId, IndexBuilder, Untracked};
3-
use isolated_encoder::IsolatedEncoder;
4-
use schema::*;
1+
use crate::index::Index;
2+
use crate::index_builder::{FromId, IndexBuilder, Untracked};
3+
use crate::isolated_encoder::IsolatedEncoder;
4+
use crate::schema::*;
55

66
use rustc::middle::cstore::{LinkagePreference, NativeLibrary,
77
EncodedMetadata, ForeignModule};
@@ -34,6 +34,7 @@ use syntax::attr;
3434
use syntax::source_map::Spanned;
3535
use syntax::symbol::keywords;
3636
use syntax_pos::{self, hygiene, FileName, SourceFile, Span};
37+
use log::{debug, trace};
3738

3839
use rustc::hir::{self, PatKind};
3940
use rustc::hir::itemlikevisit::ItemLikeVisitor;
@@ -1521,7 +1522,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
15211522
// symbol associated with them (they weren't translated) or if they're an FFI
15221523
// definition (as that's not defined in this crate).
15231524
fn encode_exported_symbols(&mut self,
1524-
exported_symbols: &[(ExportedSymbol, SymbolExportLevel)])
1525+
exported_symbols: &[(ExportedSymbol<'_>, SymbolExportLevel)])
15251526
-> EncodedExportedSymbols {
15261527
// The metadata symbol name is special. It should not show up in
15271528
// downstream crates.

src/librustc_metadata/index.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use schema::*;
1+
use crate::schema::*;
22

33
use rustc::hir::def_id::{DefId, DefIndex, DefIndexAddressSpace};
44
use rustc_serialize::opaque::Encoder;
55
use std::slice;
66
use std::u32;
7+
use log::debug;
78

89
/// While we are generating the metadata, we also track the position
910
/// of each DefIndex. It is not required that all definitions appear
@@ -24,12 +25,12 @@ impl Index {
2425
}
2526
}
2627

27-
pub fn record(&mut self, def_id: DefId, entry: Lazy<Entry>) {
28+
pub fn record(&mut self, def_id: DefId, entry: Lazy<Entry<'_>>) {
2829
assert!(def_id.is_local());
2930
self.record_index(def_id.index, entry);
3031
}
3132

32-
pub fn record_index(&mut self, item: DefIndex, entry: Lazy<Entry>) {
33+
pub fn record_index(&mut self, item: DefIndex, entry: Lazy<Entry<'_>>) {
3334
assert!(entry.position < (u32::MAX as usize));
3435
let position = entry.position as u32;
3536
let space_index = item.address_space().index();

src/librustc_metadata/index_builder.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545
//! give a callback fn, rather than taking a closure: it allows us to
4646
//! easily control precisely what data is given to that fn.
4747
48-
use encoder::EncodeContext;
49-
use index::Index;
50-
use schema::*;
51-
use isolated_encoder::IsolatedEncoder;
48+
use crate::encoder::EncodeContext;
49+
use crate::index::Index;
50+
use crate::schema::*;
51+
use crate::isolated_encoder::IsolatedEncoder;
5252

5353
use rustc::hir;
5454
use rustc::hir::def_id::DefId;
@@ -133,21 +133,21 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
133133
/// `DefId` index, or implement the `read` method so that it can add
134134
/// a read of whatever dep-graph nodes are appropriate.
135135
pub trait DepGraphRead {
136-
fn read(&self, tcx: TyCtxt);
136+
fn read(&self, tcx: TyCtxt<'_, '_, '_>);
137137
}
138138

139139
impl DepGraphRead for DefId {
140-
fn read(&self, _tcx: TyCtxt) {}
140+
fn read(&self, _tcx: TyCtxt<'_, '_, '_>) {}
141141
}
142142

143143
impl DepGraphRead for ast::NodeId {
144-
fn read(&self, _tcx: TyCtxt) {}
144+
fn read(&self, _tcx: TyCtxt<'_, '_, '_>) {}
145145
}
146146

147147
impl<T> DepGraphRead for Option<T>
148148
where T: DepGraphRead
149149
{
150-
fn read(&self, tcx: TyCtxt) {
150+
fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
151151
match *self {
152152
Some(ref v) => v.read(tcx),
153153
None => (),
@@ -158,7 +158,7 @@ impl<T> DepGraphRead for Option<T>
158158
impl<T> DepGraphRead for [T]
159159
where T: DepGraphRead
160160
{
161-
fn read(&self, tcx: TyCtxt) {
161+
fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
162162
for i in self {
163163
i.read(tcx);
164164
}
@@ -171,7 +171,7 @@ macro_rules! read_tuple {
171171
where $($name: DepGraphRead),*
172172
{
173173
#[allow(non_snake_case)]
174-
fn read(&self, tcx: TyCtxt) {
174+
fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
175175
let &($(ref $name),*) = self;
176176
$($name.read(tcx);)*
177177
}
@@ -184,7 +184,7 @@ read_tuple!(A, B, C);
184184
macro_rules! read_hir {
185185
($t:ty) => {
186186
impl<'tcx> DepGraphRead for &'tcx $t {
187-
fn read(&self, tcx: TyCtxt) {
187+
fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
188188
tcx.hir().read(self.id);
189189
}
190190
}
@@ -208,7 +208,7 @@ read_hir!(hir::MacroDef);
208208
pub struct Untracked<T>(pub T);
209209

210210
impl<T> DepGraphRead for Untracked<T> {
211-
fn read(&self, _tcx: TyCtxt) {}
211+
fn read(&self, _tcx: TyCtxt<'_, '_, '_>) {}
212212
}
213213

214214
/// Newtype that can be used to package up misc data extracted from a
@@ -218,7 +218,7 @@ impl<T> DepGraphRead for Untracked<T> {
218218
pub struct FromId<T>(pub ast::NodeId, pub T);
219219

220220
impl<T> DepGraphRead for FromId<T> {
221-
fn read(&self, tcx: TyCtxt) {
221+
fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
222222
tcx.hir().read(self.0);
223223
}
224224
}

src/librustc_metadata/isolated_encoder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use encoder::EncodeContext;
2-
use schema::{Lazy, LazySeq};
1+
use crate::encoder::EncodeContext;
2+
use crate::schema::{Lazy, LazySeq};
33
use rustc::ty::TyCtxt;
44
use rustc_serialize::Encodable;
55

src/librustc_metadata/lib.rs

+3-11
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,15 @@
1515

1616
#![recursion_limit="256"]
1717

18+
#![deny(rust_2018_idioms)]
19+
1820
extern crate libc;
19-
#[macro_use]
20-
extern crate log;
21-
extern crate memmap;
22-
extern crate stable_deref_trait;
23-
#[macro_use]
24-
extern crate syntax;
25-
extern crate syntax_pos;
26-
extern crate flate2;
21+
#[allow(unused_extern_crates)]
2722
extern crate serialize as rustc_serialize; // used by deriving
28-
extern crate rustc_errors as errors;
29-
extern crate syntax_ext;
3023
extern crate proc_macro;
3124

3225
#[macro_use]
3326
extern crate rustc;
34-
extern crate rustc_target;
3527
#[macro_use]
3628
extern crate rustc_data_structures;
3729

0 commit comments

Comments
 (0)