Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of bare_trait_objects PRs #52336

Merged
merged 13 commits into from
Jul 27, 2018
4 changes: 3 additions & 1 deletion src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,10 @@ fn main() {
cmd.arg("--color=always");
}

if env::var_os("RUSTC_DENY_WARNINGS").is_some() {
if env::var_os("RUSTC_DENY_WARNINGS").is_some() && env::var_os("RUSTC_EXTERNAL_TOOL").is_none()
{
cmd.arg("-Dwarnings");
cmd.arg("-Dbare_trait_objects");
}

if verbose > 1 {
Expand Down
5 changes: 3 additions & 2 deletions src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use compile::{run_cargo, std_cargo, test_cargo, rustc_cargo, rustc_cargo_env, add_to_sysroot};
use builder::{RunConfig, Builder, ShouldRun, Step};
use tool::{self, prepare_tool_cargo};
use tool::{self, prepare_tool_cargo, SourceType};
use {Compiler, Mode};
use cache::{INTERNER, Interned};
use std::path::PathBuf;
Expand Down Expand Up @@ -222,7 +222,8 @@ impl Step for Rustdoc {
Mode::ToolRustc,
target,
"check",
"src/tools/rustdoc");
"src/tools/rustdoc",
SourceType::InTree);

let _folder = builder.fold_output(|| format!("stage{}-rustdoc", compiler.stage));
println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target);
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use build_helper::up_to_date;

use util::symlink_dir;
use builder::{Builder, Compiler, RunConfig, ShouldRun, Step};
use tool::{self, prepare_tool_cargo, Tool};
use tool::{self, prepare_tool_cargo, Tool, SourceType};
use compile;
use cache::{INTERNER, Interned};
use config::Config;
Expand Down Expand Up @@ -814,6 +814,7 @@ impl Step for Rustdoc {
target,
"doc",
"src/tools/rustdoc",
SourceType::InTree,
);

cargo.env("RUSTDOCFLAGS", "--document-private-items");
Expand Down
57 changes: 29 additions & 28 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use compile;
use dist;
use flags::Subcommand;
use native;
use tool::{self, Tool};
use tool::{self, Tool, SourceType};
use toolstate::ToolState;
use util::{self, dylib_path, dylib_path_var};
use Crate as CargoCrate;
Expand Down Expand Up @@ -222,17 +222,18 @@ impl Step for Cargo {
compiler,
target: self.host,
});
let mut cargo = builder.cargo(compiler, Mode::ToolRustc, self.host, "test");
cargo
.arg("--manifest-path")
.arg(builder.src.join("src/tools/cargo/Cargo.toml"));
let mut cargo = tool::prepare_tool_cargo(builder,
compiler,
Mode::ToolRustc,
self.host,
"test",
"src/tools/cargo",
SourceType::Submodule);

if !builder.fail_fast {
cargo.arg("--no-fail-fast");
}

// Don't build tests dynamically, just a pain to work with
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");

// Don't run cross-compile tests, we may not have cross-compiled libstd libs
// available.
cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
Expand Down Expand Up @@ -286,10 +287,8 @@ impl Step for Rls {
Mode::ToolRustc,
host,
"test",
"src/tools/rls");

// Don't build tests dynamically, just a pain to work with
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
"src/tools/rls",
SourceType::Submodule);

builder.add_rustc_lib_path(compiler, &mut cargo);

Expand Down Expand Up @@ -341,10 +340,9 @@ impl Step for Rustfmt {
Mode::ToolRustc,
host,
"test",
"src/tools/rustfmt");
"src/tools/rustfmt",
SourceType::Submodule);

// Don't build tests dynamically, just a pain to work with
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
let dir = testdir(builder, compiler.host);
t!(fs::create_dir_all(&dir));
cargo.env("RUSTFMT_TEST_DIR", dir);
Expand Down Expand Up @@ -392,13 +390,14 @@ impl Step for Miri {
extra_features: Vec::new(),
});
if let Some(miri) = miri {
let mut cargo = builder.cargo(compiler, Mode::ToolRustc, host, "test");
cargo
.arg("--manifest-path")
.arg(builder.src.join("src/tools/miri/Cargo.toml"));
let mut cargo = tool::prepare_tool_cargo(builder,
compiler,
Mode::ToolRustc,
host,
"test",
"src/tools/miri",
SourceType::Submodule);

// Don't build tests dynamically, just a pain to work with
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
// miri tests need to know about the stage sysroot
cargo.env("MIRI_SYSROOT", builder.sysroot(compiler));
cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
Expand Down Expand Up @@ -450,13 +449,14 @@ impl Step for Clippy {
extra_features: Vec::new(),
});
if let Some(clippy) = clippy {
let mut cargo = builder.cargo(compiler, Mode::ToolRustc, host, "test");
cargo
.arg("--manifest-path")
.arg(builder.src.join("src/tools/clippy/Cargo.toml"));
let mut cargo = tool::prepare_tool_cargo(builder,
compiler,
Mode::ToolRustc,
host,
"test",
"src/tools/clippy",
SourceType::Submodule);

// Don't build tests dynamically, just a pain to work with
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
// clippy tests need to know about the stage sysroot
cargo.env("SYSROOT", builder.sysroot(compiler));
cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
Expand Down Expand Up @@ -1739,7 +1739,8 @@ impl Step for CrateRustdoc {
Mode::ToolRustc,
target,
test_kind.subcommand(),
"src/tools/rustdoc");
"src/tools/rustdoc",
SourceType::InTree);
if test_kind.subcommand() == "test" && !builder.fail_fast {
cargo.arg("--no-fail-fast");
}
Expand Down
65 changes: 49 additions & 16 deletions src/bootstrap/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,21 @@ impl Step for CleanTools {
}
}

#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub enum SourceType {
InTree,
Submodule,
}

#[derive(Debug, Clone, Hash, PartialEq, Eq)]
struct ToolBuild {
compiler: Compiler,
target: Interned<String>,
tool: &'static str,
path: &'static str,
mode: Mode,
is_ext_tool: bool,
is_optional_tool: bool,
source_type: SourceType,
extra_features: Vec<String>,
}

Expand All @@ -102,7 +109,7 @@ impl Step for ToolBuild {
let target = self.target;
let tool = self.tool;
let path = self.path;
let is_ext_tool = self.is_ext_tool;
let is_optional_tool = self.is_optional_tool;

match self.mode {
Mode::ToolRustc => {
Expand All @@ -115,7 +122,15 @@ impl Step for ToolBuild {
_ => panic!("unexpected Mode for tool build")
}

let mut cargo = prepare_tool_cargo(builder, compiler, self.mode, target, "build", path);
let mut cargo = prepare_tool_cargo(
builder,
compiler,
self.mode,
target,
"build",
path,
self.source_type,
);
cargo.arg("--features").arg(self.extra_features.join(" "));

let _folder = builder.fold_output(|| format!("stage{}-{}", compiler.stage, tool));
Expand Down Expand Up @@ -216,7 +231,7 @@ impl Step for ToolBuild {
});

if !is_expected {
if !is_ext_tool {
if !is_optional_tool {
exit(1);
} else {
return None;
Expand All @@ -238,6 +253,7 @@ pub fn prepare_tool_cargo(
target: Interned<String>,
command: &'static str,
path: &'static str,
source_type: SourceType,
) -> Command {
let mut cargo = builder.cargo(compiler, mode, target, command);
let dir = builder.src.join(path);
Expand All @@ -247,6 +263,10 @@ pub fn prepare_tool_cargo(
// stages and such and it's just easier if they're not dynamically linked.
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");

if source_type == SourceType::Submodule {
cargo.env("RUSTC_EXTERNAL_TOOL", "1");
}

if let Some(dir) = builder.openssl_install_dir(target) {
cargo.env("OPENSSL_STATIC", "1");
cargo.env("OPENSSL_DIR", dir);
Expand Down Expand Up @@ -274,7 +294,8 @@ pub fn prepare_tool_cargo(
}

macro_rules! tool {
($($name:ident, $path:expr, $tool_name:expr, $mode:expr $(,llvm_tools = $llvm:expr)*;)+) => {
($($name:ident, $path:expr, $tool_name:expr, $mode:expr
$(,llvm_tools = $llvm:expr)* $(,is_external_tool = $external:expr)*;)+) => {
#[derive(Copy, PartialEq, Eq, Clone)]
pub enum Tool {
$(
Expand Down Expand Up @@ -351,7 +372,12 @@ macro_rules! tool {
tool: $tool_name,
mode: $mode,
path: $path,
is_ext_tool: false,
is_optional_tool: false,
source_type: if false $(|| $external)* {
SourceType::Submodule
} else {
SourceType::InTree
},
extra_features: Vec::new(),
}).expect("expected to build -- essential tool")
}
Expand All @@ -370,7 +396,8 @@ tool!(
Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolBootstrap, llvm_tools = true;
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolBootstrap;
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolBootstrap;
RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolBootstrap;
RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolBootstrap,
is_external_tool = true;
RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes", Mode::ToolBootstrap;
);

Expand Down Expand Up @@ -401,7 +428,8 @@ impl Step for RemoteTestServer {
tool: "remote-test-server",
mode: Mode::ToolStd,
path: "src/tools/remote-test-server",
is_ext_tool: false,
is_optional_tool: false,
source_type: SourceType::InTree,
extra_features: Vec::new(),
}).expect("expected to build -- essential tool")
}
Expand Down Expand Up @@ -449,12 +477,15 @@ impl Step for Rustdoc {
target: builder.config.build,
});

let mut cargo = prepare_tool_cargo(builder,
build_compiler,
Mode::ToolRustc,
target,
"build",
"src/tools/rustdoc");
let mut cargo = prepare_tool_cargo(
builder,
build_compiler,
Mode::ToolRustc,
target,
"build",
"src/tools/rustdoc",
SourceType::InTree,
);

// Most tools don't get debuginfo, but rustdoc should.
cargo.env("RUSTC_DEBUGINFO", builder.config.rust_debuginfo.to_string())
Expand Down Expand Up @@ -525,7 +556,8 @@ impl Step for Cargo {
tool: "cargo",
mode: Mode::ToolRustc,
path: "src/tools/cargo",
is_ext_tool: false,
is_optional_tool: false,
source_type: SourceType::Submodule,
extra_features: Vec::new(),
}).expect("expected to build -- essential tool")
}
Expand Down Expand Up @@ -574,7 +606,8 @@ macro_rules! tool_extended {
mode: Mode::ToolRustc,
path: $path,
extra_features: $sel.extra_features,
is_ext_tool: true,
is_optional_tool: true,
source_type: SourceType::Submodule,
})
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/build_helper/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![deny(bare_trait_objects)]

use std::fs::File;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
Expand Down
1 change: 0 additions & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
#![no_std]
#![needs_allocator]
#![deny(bare_trait_objects)]
#![deny(missing_debug_implementations)]

#![cfg_attr(test, allow(deprecated))] // rand
Expand Down
6 changes: 3 additions & 3 deletions src/liballoc/tests/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn uninhabited() {
a = a.clone();
assert!(a.upgrade().is_none());

let mut a: Weak<Any> = a; // Unsizing
let mut a: Weak<dyn Any> = a; // Unsizing
a = a.clone();
assert!(a.upgrade().is_none());
}
Expand All @@ -39,7 +39,7 @@ fn slice() {
#[test]
fn trait_object() {
let a: Arc<u32> = Arc::new(4);
let a: Arc<Any> = a; // Unsizing
let a: Arc<dyn Any> = a; // Unsizing

// Exercise is_dangling() with a DST
let mut a = Arc::downgrade(&a);
Expand All @@ -49,7 +49,7 @@ fn trait_object() {
let mut b = Weak::<u32>::new();
b = b.clone();
assert!(b.upgrade().is_none());
let mut b: Weak<Any> = b; // Unsizing
let mut b: Weak<dyn Any> = b; // Unsizing
b = b.clone();
assert!(b.upgrade().is_none());
}
2 changes: 1 addition & 1 deletion src/liballoc/tests/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn test_hash() {
}

fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F)
where F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, &mut FnMut(&i32) -> bool) -> bool
where F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, &mut dyn FnMut(&i32) -> bool) -> bool
{
let mut set_a = BTreeSet::new();
let mut set_b = BTreeSet::new();
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn test_boxed_hasher() {
5u32.hash(&mut hasher_1);
assert_eq!(ordinary_hash, hasher_1.finish());

let mut hasher_2 = Box::new(DefaultHasher::new()) as Box<Hasher>;
let mut hasher_2 = Box::new(DefaultHasher::new()) as Box<dyn Hasher>;
5u32.hash(&mut hasher_2);
assert_eq!(ordinary_hash, hasher_2.finish());
}
Loading