From 81ac104e89d9fa059a571e0935320c23f83b1977 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sun, 2 Dec 2018 22:47:41 +0200 Subject: [PATCH 1/3] Start using serde_derive in a couple places in the compiler. --- Cargo.lock | 5 +++++ src/librustc_cratesio_shim/Cargo.toml | 1 + src/librustc_cratesio_shim/src/lib.rs | 1 + src/librustc_errors/Cargo.toml | 2 ++ src/librustc_errors/lib.rs | 8 +++++++- src/libsyntax_pos/Cargo.toml | 2 ++ src/libsyntax_pos/lib.rs | 8 +++++++- src/tools/tidy/src/deps.rs | 6 ++++++ 8 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 72f3077d2be40..1231a60be8662 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2223,6 +2223,7 @@ version = "0.0.0" dependencies = [ "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2288,6 +2289,8 @@ dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_cratesio_shim 0.0.0", "rustc_data_structures 0.0.0", + "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "serialize 0.0.0", "syntax_pos 0.0.0", "termcolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2901,6 +2904,8 @@ dependencies = [ "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_data_structures 0.0.0", "scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.75 (registry+https://github.com/rust-lang/crates.io-index)", "serialize 0.0.0", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/src/librustc_cratesio_shim/Cargo.toml b/src/librustc_cratesio_shim/Cargo.toml index b8e494e4040ec..a0886cd314baf 100644 --- a/src/librustc_cratesio_shim/Cargo.toml +++ b/src/librustc_cratesio_shim/Cargo.toml @@ -22,4 +22,5 @@ crate-type = ["dylib"] [dependencies] bitflags = "1.0" log = "0.4" +serde = "1.0" unicode-width = "0.1.4" diff --git a/src/librustc_cratesio_shim/src/lib.rs b/src/librustc_cratesio_shim/src/lib.rs index 56e480208e1c3..16caf0e129eaf 100644 --- a/src/librustc_cratesio_shim/src/lib.rs +++ b/src/librustc_cratesio_shim/src/lib.rs @@ -16,4 +16,5 @@ extern crate bitflags; extern crate log; extern crate proc_macro; +extern crate serde; extern crate unicode_width; diff --git a/src/librustc_errors/Cargo.toml b/src/librustc_errors/Cargo.toml index b24f8ddf4d9f7..c8725709de555 100644 --- a/src/librustc_errors/Cargo.toml +++ b/src/librustc_errors/Cargo.toml @@ -14,6 +14,8 @@ serialize = { path = "../libserialize" } syntax_pos = { path = "../libsyntax_pos" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_cratesio_shim = { path = "../librustc_cratesio_shim" } +serde = "1.0" +serde_derive = "1.0" unicode-width = "0.1.4" atty = "0.2" termcolor = "1.0" diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 0fb77a7a3ab52..15b522036045f 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -26,6 +26,9 @@ extern crate libc; #[macro_use] extern crate log; extern crate rustc_data_structures; +#[macro_use] +extern crate serde_derive; +extern crate serde; extern crate serialize as rustc_serialize; extern crate syntax_pos; extern crate unicode_width; @@ -66,7 +69,10 @@ use syntax_pos::{BytePos, Span, NO_EXPANSION}; -#[derive(Copy, Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)] +#[derive(Copy, Clone, Debug, PartialEq, Hash, + RustcDecodable, RustcEncodable, + Serialize, Deserialize, +)] pub enum Applicability { MachineApplicable, HasPlaceholders, diff --git a/src/libsyntax_pos/Cargo.toml b/src/libsyntax_pos/Cargo.toml index 08ee2e0f37626..f61749a2b5d45 100644 --- a/src/libsyntax_pos/Cargo.toml +++ b/src/libsyntax_pos/Cargo.toml @@ -13,5 +13,7 @@ serialize = { path = "../libserialize" } rustc_data_structures = { path = "../librustc_data_structures" } arena = { path = "../libarena" } scoped-tls = { version = "0.1.1", features = ["nightly"] } +serde = "1.0" +serde_derive = "1.0" unicode-width = "0.1.4" cfg-if = "0.1.2" diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 34fb71e4ddf68..7d688b1f9912a 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -43,6 +43,9 @@ extern crate rustc_data_structures; #[macro_use] extern crate scoped_tls; +#[macro_use] +extern crate serde_derive; +extern crate serde; use serialize::{Encodable, Decodable, Encoder, Decoder}; @@ -84,7 +87,10 @@ impl Globals { scoped_thread_local!(pub static GLOBALS: Globals); /// Differentiates between real files and common virtual files -#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash, RustcDecodable, RustcEncodable)] +#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash, + RustcDecodable, RustcEncodable, + Serialize, Deserialize, +)] pub enum FileName { Real(PathBuf), /// A macro. This includes the full name of the macro, so that there are no clashes. diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index a40ae8894d5e7..b467a284d9e9d 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -107,7 +107,9 @@ const WHITELIST: &[Crate] = &[ Crate("parking_lot_core"), Crate("pkg-config"), Crate("polonius-engine"), + Crate("proc-macro2"), Crate("quick-error"), + Crate("quote"), Crate("rand"), Crate("rand_core"), Crate("redox_syscall"), @@ -121,8 +123,11 @@ const WHITELIST: &[Crate] = &[ Crate("rustc-rayon-core"), Crate("scoped-tls"), Crate("scopeguard"), + Crate("serde"), + Crate("serde_derive"), Crate("smallvec"), Crate("stable_deref_trait"), + Crate("syn"), Crate("tempfile"), Crate("termcolor"), Crate("terminon"), @@ -130,6 +135,7 @@ const WHITELIST: &[Crate] = &[ Crate("thread_local"), Crate("ucd-util"), Crate("unicode-width"), + Crate("unicode-xid"), Crate("unreachable"), Crate("utf8-ranges"), Crate("version_check"), From 7b22fcb4eab4cd6b83c784f4228e9111e06c617b Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sun, 2 Dec 2018 23:38:54 +0200 Subject: [PATCH 2/3] bootstrap: include host deps, not just target ones, in `run_cargo`. --- src/bootstrap/compile.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index b6bb11d07ef04..4f290f6664ea8 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -1064,15 +1064,9 @@ pub fn run_cargo(builder: &Builder, let filename = Path::new(&*filename); - // If this was an output file in the "host dir" we don't actually - // worry about it, it's not relevant for us. - if filename.starts_with(&host_root_dir) { - continue; - } - // If this was output in the `deps` dir then this is a precise file // name (hash included) so we start tracking it. - if filename.starts_with(&target_deps_dir) { + if filename.starts_with(&host_root_dir) || filename.starts_with(&target_deps_dir) { deps.push(filename.to_path_buf()); continue; } From eb1bca5718e0eaf497fec54a2d547507ffb36b01 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Mon, 3 Dec 2018 08:17:21 +0200 Subject: [PATCH 3/3] bootstrap: respect `RUSTC_FORCE_UNSTABLE` for build script/proc macro crates, too. --- src/bootstrap/bin/rustc.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index d18a48e5d2270..e0e124fb4831f 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -268,13 +268,6 @@ fn main() { } } - // Force all crates compiled by this compiler to (a) be unstable and (b) - // allow the `rustc_private` feature to link to other unstable crates - // also in the sysroot. - if env::var_os("RUSTC_FORCE_UNSTABLE").is_some() { - cmd.arg("-Z").arg("force-unstable-if-unmarked"); - } - if let Ok(map) = env::var("RUSTC_DEBUGINFO_MAP") { cmd.arg("--remap-path-prefix").arg(&map); } @@ -294,6 +287,13 @@ fn main() { } } + // Force all crates compiled by this compiler to (a) be unstable and (b) + // allow the `rustc_private` feature to link to other unstable crates + // also in the sysroot. + if env::var_os("RUSTC_FORCE_UNSTABLE").is_some() { + cmd.arg("-Z").arg("force-unstable-if-unmarked"); + } + if env::var_os("RUSTC_PARALLEL_QUERIES").is_some() { cmd.arg("--cfg").arg("parallel_queries"); }