Skip to content

Commit 4f1e235

Browse files
committed
Auto merge of #52336 - ishitatsuyuki:dyn-rollup, r=Mark-Simulacrum
Rollup of bare_trait_objects PRs All deny attributes were moved into bootstrap so they can be disabled with a line of config. Warnings for external tools are allowed and it's up to the tool's maintainer to keep it warnings free. r? @Mark-Simulacrum cc @ljedrz @kennytm
2 parents 43e6e2e + 62f73dc commit 4f1e235

File tree

112 files changed

+315
-345
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+315
-345
lines changed

Diff for: src/bootstrap/bin/rustc.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,10 @@ fn main() {
296296
cmd.arg("--color=always");
297297
}
298298

299-
if env::var_os("RUSTC_DENY_WARNINGS").is_some() {
299+
if env::var_os("RUSTC_DENY_WARNINGS").is_some() && env::var_os("RUSTC_EXTERNAL_TOOL").is_none()
300+
{
300301
cmd.arg("-Dwarnings");
302+
cmd.arg("-Dbare_trait_objects");
301303
}
302304

303305
if verbose > 1 {

Diff for: src/bootstrap/check.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
use compile::{run_cargo, std_cargo, test_cargo, rustc_cargo, rustc_cargo_env, add_to_sysroot};
1414
use builder::{RunConfig, Builder, ShouldRun, Step};
15-
use tool::{self, prepare_tool_cargo};
15+
use tool::{self, prepare_tool_cargo, SourceType};
1616
use {Compiler, Mode};
1717
use cache::{INTERNER, Interned};
1818
use std::path::PathBuf;
@@ -222,7 +222,8 @@ impl Step for Rustdoc {
222222
Mode::ToolRustc,
223223
target,
224224
"check",
225-
"src/tools/rustdoc");
225+
"src/tools/rustdoc",
226+
SourceType::InTree);
226227

227228
let _folder = builder.fold_output(|| format!("stage{}-rustdoc", compiler.stage));
228229
println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target);

Diff for: src/bootstrap/doc.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use build_helper::up_to_date;
2828

2929
use util::symlink_dir;
3030
use builder::{Builder, Compiler, RunConfig, ShouldRun, Step};
31-
use tool::{self, prepare_tool_cargo, Tool};
31+
use tool::{self, prepare_tool_cargo, Tool, SourceType};
3232
use compile;
3333
use cache::{INTERNER, Interned};
3434
use config::Config;
@@ -814,6 +814,7 @@ impl Step for Rustdoc {
814814
target,
815815
"doc",
816816
"src/tools/rustdoc",
817+
SourceType::InTree,
817818
);
818819

819820
cargo.env("RUSTDOCFLAGS", "--document-private-items");

Diff for: src/bootstrap/test.rs

+29-28
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use compile;
3030
use dist;
3131
use flags::Subcommand;
3232
use native;
33-
use tool::{self, Tool};
33+
use tool::{self, Tool, SourceType};
3434
use toolstate::ToolState;
3535
use util::{self, dylib_path, dylib_path_var};
3636
use Crate as CargoCrate;
@@ -222,17 +222,18 @@ impl Step for Cargo {
222222
compiler,
223223
target: self.host,
224224
});
225-
let mut cargo = builder.cargo(compiler, Mode::ToolRustc, self.host, "test");
226-
cargo
227-
.arg("--manifest-path")
228-
.arg(builder.src.join("src/tools/cargo/Cargo.toml"));
225+
let mut cargo = tool::prepare_tool_cargo(builder,
226+
compiler,
227+
Mode::ToolRustc,
228+
self.host,
229+
"test",
230+
"src/tools/cargo",
231+
SourceType::Submodule);
232+
229233
if !builder.fail_fast {
230234
cargo.arg("--no-fail-fast");
231235
}
232236

233-
// Don't build tests dynamically, just a pain to work with
234-
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
235-
236237
// Don't run cross-compile tests, we may not have cross-compiled libstd libs
237238
// available.
238239
cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
@@ -286,10 +287,8 @@ impl Step for Rls {
286287
Mode::ToolRustc,
287288
host,
288289
"test",
289-
"src/tools/rls");
290-
291-
// Don't build tests dynamically, just a pain to work with
292-
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
290+
"src/tools/rls",
291+
SourceType::Submodule);
293292

294293
builder.add_rustc_lib_path(compiler, &mut cargo);
295294

@@ -341,10 +340,9 @@ impl Step for Rustfmt {
341340
Mode::ToolRustc,
342341
host,
343342
"test",
344-
"src/tools/rustfmt");
343+
"src/tools/rustfmt",
344+
SourceType::Submodule);
345345

346-
// Don't build tests dynamically, just a pain to work with
347-
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
348346
let dir = testdir(builder, compiler.host);
349347
t!(fs::create_dir_all(&dir));
350348
cargo.env("RUSTFMT_TEST_DIR", dir);
@@ -392,13 +390,14 @@ impl Step for Miri {
392390
extra_features: Vec::new(),
393391
});
394392
if let Some(miri) = miri {
395-
let mut cargo = builder.cargo(compiler, Mode::ToolRustc, host, "test");
396-
cargo
397-
.arg("--manifest-path")
398-
.arg(builder.src.join("src/tools/miri/Cargo.toml"));
393+
let mut cargo = tool::prepare_tool_cargo(builder,
394+
compiler,
395+
Mode::ToolRustc,
396+
host,
397+
"test",
398+
"src/tools/miri",
399+
SourceType::Submodule);
399400

400-
// Don't build tests dynamically, just a pain to work with
401-
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
402401
// miri tests need to know about the stage sysroot
403402
cargo.env("MIRI_SYSROOT", builder.sysroot(compiler));
404403
cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
@@ -450,13 +449,14 @@ impl Step for Clippy {
450449
extra_features: Vec::new(),
451450
});
452451
if let Some(clippy) = clippy {
453-
let mut cargo = builder.cargo(compiler, Mode::ToolRustc, host, "test");
454-
cargo
455-
.arg("--manifest-path")
456-
.arg(builder.src.join("src/tools/clippy/Cargo.toml"));
452+
let mut cargo = tool::prepare_tool_cargo(builder,
453+
compiler,
454+
Mode::ToolRustc,
455+
host,
456+
"test",
457+
"src/tools/clippy",
458+
SourceType::Submodule);
457459

458-
// Don't build tests dynamically, just a pain to work with
459-
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
460460
// clippy tests need to know about the stage sysroot
461461
cargo.env("SYSROOT", builder.sysroot(compiler));
462462
cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
@@ -1739,7 +1739,8 @@ impl Step for CrateRustdoc {
17391739
Mode::ToolRustc,
17401740
target,
17411741
test_kind.subcommand(),
1742-
"src/tools/rustdoc");
1742+
"src/tools/rustdoc",
1743+
SourceType::InTree);
17431744
if test_kind.subcommand() == "test" && !builder.fail_fast {
17441745
cargo.arg("--no-fail-fast");
17451746
}

Diff for: src/bootstrap/tool.rs

+49-16
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,21 @@ impl Step for CleanTools {
7575
}
7676
}
7777

78+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
79+
pub enum SourceType {
80+
InTree,
81+
Submodule,
82+
}
83+
7884
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
7985
struct ToolBuild {
8086
compiler: Compiler,
8187
target: Interned<String>,
8288
tool: &'static str,
8389
path: &'static str,
8490
mode: Mode,
85-
is_ext_tool: bool,
91+
is_optional_tool: bool,
92+
source_type: SourceType,
8693
extra_features: Vec<String>,
8794
}
8895

@@ -102,7 +109,7 @@ impl Step for ToolBuild {
102109
let target = self.target;
103110
let tool = self.tool;
104111
let path = self.path;
105-
let is_ext_tool = self.is_ext_tool;
112+
let is_optional_tool = self.is_optional_tool;
106113

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

118-
let mut cargo = prepare_tool_cargo(builder, compiler, self.mode, target, "build", path);
125+
let mut cargo = prepare_tool_cargo(
126+
builder,
127+
compiler,
128+
self.mode,
129+
target,
130+
"build",
131+
path,
132+
self.source_type,
133+
);
119134
cargo.arg("--features").arg(self.extra_features.join(" "));
120135

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

218233
if !is_expected {
219-
if !is_ext_tool {
234+
if !is_optional_tool {
220235
exit(1);
221236
} else {
222237
return None;
@@ -238,6 +253,7 @@ pub fn prepare_tool_cargo(
238253
target: Interned<String>,
239254
command: &'static str,
240255
path: &'static str,
256+
source_type: SourceType,
241257
) -> Command {
242258
let mut cargo = builder.cargo(compiler, mode, target, command);
243259
let dir = builder.src.join(path);
@@ -247,6 +263,10 @@ pub fn prepare_tool_cargo(
247263
// stages and such and it's just easier if they're not dynamically linked.
248264
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
249265

266+
if source_type == SourceType::Submodule {
267+
cargo.env("RUSTC_EXTERNAL_TOOL", "1");
268+
}
269+
250270
if let Some(dir) = builder.openssl_install_dir(target) {
251271
cargo.env("OPENSSL_STATIC", "1");
252272
cargo.env("OPENSSL_DIR", dir);
@@ -274,7 +294,8 @@ pub fn prepare_tool_cargo(
274294
}
275295

276296
macro_rules! tool {
277-
($($name:ident, $path:expr, $tool_name:expr, $mode:expr $(,llvm_tools = $llvm:expr)*;)+) => {
297+
($($name:ident, $path:expr, $tool_name:expr, $mode:expr
298+
$(,llvm_tools = $llvm:expr)* $(,is_external_tool = $external:expr)*;)+) => {
278299
#[derive(Copy, PartialEq, Eq, Clone)]
279300
pub enum Tool {
280301
$(
@@ -351,7 +372,12 @@ macro_rules! tool {
351372
tool: $tool_name,
352373
mode: $mode,
353374
path: $path,
354-
is_ext_tool: false,
375+
is_optional_tool: false,
376+
source_type: if false $(|| $external)* {
377+
SourceType::Submodule
378+
} else {
379+
SourceType::InTree
380+
},
355381
extra_features: Vec::new(),
356382
}).expect("expected to build -- essential tool")
357383
}
@@ -370,7 +396,8 @@ tool!(
370396
Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolBootstrap, llvm_tools = true;
371397
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolBootstrap;
372398
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolBootstrap;
373-
RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolBootstrap;
399+
RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolBootstrap,
400+
is_external_tool = true;
374401
RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes", Mode::ToolBootstrap;
375402
);
376403

@@ -401,7 +428,8 @@ impl Step for RemoteTestServer {
401428
tool: "remote-test-server",
402429
mode: Mode::ToolStd,
403430
path: "src/tools/remote-test-server",
404-
is_ext_tool: false,
431+
is_optional_tool: false,
432+
source_type: SourceType::InTree,
405433
extra_features: Vec::new(),
406434
}).expect("expected to build -- essential tool")
407435
}
@@ -449,12 +477,15 @@ impl Step for Rustdoc {
449477
target: builder.config.build,
450478
});
451479

452-
let mut cargo = prepare_tool_cargo(builder,
453-
build_compiler,
454-
Mode::ToolRustc,
455-
target,
456-
"build",
457-
"src/tools/rustdoc");
480+
let mut cargo = prepare_tool_cargo(
481+
builder,
482+
build_compiler,
483+
Mode::ToolRustc,
484+
target,
485+
"build",
486+
"src/tools/rustdoc",
487+
SourceType::InTree,
488+
);
458489

459490
// Most tools don't get debuginfo, but rustdoc should.
460491
cargo.env("RUSTC_DEBUGINFO", builder.config.rust_debuginfo.to_string())
@@ -525,7 +556,8 @@ impl Step for Cargo {
525556
tool: "cargo",
526557
mode: Mode::ToolRustc,
527558
path: "src/tools/cargo",
528-
is_ext_tool: false,
559+
is_optional_tool: false,
560+
source_type: SourceType::Submodule,
529561
extra_features: Vec::new(),
530562
}).expect("expected to build -- essential tool")
531563
}
@@ -574,7 +606,8 @@ macro_rules! tool_extended {
574606
mode: Mode::ToolRustc,
575607
path: $path,
576608
extra_features: $sel.extra_features,
577-
is_ext_tool: true,
609+
is_optional_tool: true,
610+
source_type: SourceType::Submodule,
578611
})
579612
}
580613
}

Diff for: src/build_helper/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![deny(bare_trait_objects)]
12-
1311
use std::fs::File;
1412
use std::path::{Path, PathBuf};
1513
use std::process::{Command, Stdio};

Diff for: src/liballoc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
7373
#![no_std]
7474
#![needs_allocator]
75-
#![deny(bare_trait_objects)]
7675
#![deny(missing_debug_implementations)]
7776

7877
#![cfg_attr(test, allow(deprecated))] // rand

Diff for: src/liballoc/tests/arc.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn uninhabited() {
1818
a = a.clone();
1919
assert!(a.upgrade().is_none());
2020

21-
let mut a: Weak<Any> = a; // Unsizing
21+
let mut a: Weak<dyn Any> = a; // Unsizing
2222
a = a.clone();
2323
assert!(a.upgrade().is_none());
2424
}
@@ -39,7 +39,7 @@ fn slice() {
3939
#[test]
4040
fn trait_object() {
4141
let a: Arc<u32> = Arc::new(4);
42-
let a: Arc<Any> = a; // Unsizing
42+
let a: Arc<dyn Any> = a; // Unsizing
4343

4444
// Exercise is_dangling() with a DST
4545
let mut a = Arc::downgrade(&a);
@@ -49,7 +49,7 @@ fn trait_object() {
4949
let mut b = Weak::<u32>::new();
5050
b = b.clone();
5151
assert!(b.upgrade().is_none());
52-
let mut b: Weak<Any> = b; // Unsizing
52+
let mut b: Weak<dyn Any> = b; // Unsizing
5353
b = b.clone();
5454
assert!(b.upgrade().is_none());
5555
}

Diff for: src/liballoc/tests/btree/set.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn test_hash() {
4040
}
4141

4242
fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F)
43-
where F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, &mut FnMut(&i32) -> bool) -> bool
43+
where F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, &mut dyn FnMut(&i32) -> bool) -> bool
4444
{
4545
let mut set_a = BTreeSet::new();
4646
let mut set_b = BTreeSet::new();

Diff for: src/liballoc/tests/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn test_boxed_hasher() {
6363
5u32.hash(&mut hasher_1);
6464
assert_eq!(ordinary_hash, hasher_1.finish());
6565

66-
let mut hasher_2 = Box::new(DefaultHasher::new()) as Box<Hasher>;
66+
let mut hasher_2 = Box::new(DefaultHasher::new()) as Box<dyn Hasher>;
6767
5u32.hash(&mut hasher_2);
6868
assert_eq!(ordinary_hash, hasher_2.finish());
6969
}

0 commit comments

Comments
 (0)