Skip to content

Commit e098985

Browse files
committed
Deny bare_trait_objects globally
1 parent 4f1d4e4 commit e098985

File tree

52 files changed

+34
-87
lines changed

Some content is hidden

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

52 files changed

+34
-87
lines changed

src/bootstrap/bin/rustc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,9 @@ 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_EXT_TOOL").is_none() {
300300
cmd.arg("-Dwarnings");
301+
cmd.arg("-Dbare_trait_objects");
301302
}
302303

303304
if verbose > 1 {

src/bootstrap/check.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ impl Step for Rustdoc {
222222
Mode::ToolRustc,
223223
target,
224224
"check",
225-
"src/tools/rustdoc");
225+
"src/tools/rustdoc",
226+
false);
226227

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

src/bootstrap/doc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,7 @@ impl Step for Rustdoc {
814814
target,
815815
"doc",
816816
"src/tools/rustdoc",
817+
false
817818
);
818819

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

src/bootstrap/test.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ impl Step for Rls {
286286
Mode::ToolRustc,
287287
host,
288288
"test",
289-
"src/tools/rls");
289+
"src/tools/rls",
290+
true);
290291

291292
// Don't build tests dynamically, just a pain to work with
292293
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
@@ -341,7 +342,8 @@ impl Step for Rustfmt {
341342
Mode::ToolRustc,
342343
host,
343344
"test",
344-
"src/tools/rustfmt");
345+
"src/tools/rustfmt",
346+
true);
345347

346348
// Don't build tests dynamically, just a pain to work with
347349
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
@@ -1739,7 +1741,8 @@ impl Step for CrateRustdoc {
17391741
Mode::ToolRustc,
17401742
target,
17411743
test_kind.subcommand(),
1742-
"src/tools/rustdoc");
1744+
"src/tools/rustdoc",
1745+
false);
17431746
if test_kind.subcommand() == "test" && !builder.fail_fast {
17441747
cargo.arg("--no-fail-fast");
17451748
}

src/bootstrap/tool.rs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,15 @@ impl Step for ToolBuild {
115115
_ => panic!("unexpected Mode for tool build")
116116
}
117117

118-
let mut cargo = prepare_tool_cargo(builder, compiler, self.mode, target, "build", path);
118+
let mut cargo = prepare_tool_cargo(
119+
builder,
120+
compiler,
121+
self.mode,
122+
target,
123+
"build",
124+
path,
125+
is_ext_tool,
126+
);
119127
cargo.arg("--features").arg(self.extra_features.join(" "));
120128

121129
let _folder = builder.fold_output(|| format!("stage{}-{}", compiler.stage, tool));
@@ -238,6 +246,7 @@ pub fn prepare_tool_cargo(
238246
target: Interned<String>,
239247
command: &'static str,
240248
path: &'static str,
249+
is_ext_tool: bool,
241250
) -> Command {
242251
let mut cargo = builder.cargo(compiler, mode, target, command);
243252
let dir = builder.src.join(path);
@@ -247,6 +256,10 @@ pub fn prepare_tool_cargo(
247256
// stages and such and it's just easier if they're not dynamically linked.
248257
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
249258

259+
if is_ext_tool {
260+
cargo.env("RUSTC_EXT_TOOL", "1");
261+
}
262+
250263
if let Some(dir) = builder.openssl_install_dir(target) {
251264
cargo.env("OPENSSL_STATIC", "1");
252265
cargo.env("OPENSSL_DIR", dir);
@@ -449,12 +462,15 @@ impl Step for Rustdoc {
449462
target: builder.config.build,
450463
});
451464

452-
let mut cargo = prepare_tool_cargo(builder,
453-
build_compiler,
454-
Mode::ToolRustc,
455-
target,
456-
"build",
457-
"src/tools/rustdoc");
465+
let mut cargo = prepare_tool_cargo(
466+
builder,
467+
build_compiler,
468+
Mode::ToolRustc,
469+
target,
470+
"build",
471+
"src/tools/rustdoc",
472+
false,
473+
);
458474

459475
// Most tools don't get debuginfo, but rustdoc should.
460476
cargo.env("RUSTC_DEBUGINFO", builder.config.rust_debuginfo.to_string())

src/build_helper/lib.rs

Lines changed: 0 additions & 2 deletions
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};

src/liballoc/lib.rs

Lines changed: 0 additions & 1 deletion
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

src/liballoc_jemalloc/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#![no_std]
1212
#![allow(unused_attributes)]
13-
#![deny(bare_trait_objects)]
1413
#![unstable(feature = "alloc_jemalloc",
1514
reason = "implementation detail of std, does not provide any public API",
1615
issue = "0")]

src/liballoc_system/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#![no_std]
1212
#![allow(unused_attributes)]
13-
#![deny(bare_trait_objects)]
1413
#![unstable(feature = "alloc_system",
1514
reason = "this library is unlikely to be stabilized in its current \
1615
form or name",

src/libarena/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#![cfg_attr(test, feature(test))]
3131

3232
#![allow(deprecated)]
33-
#![deny(bare_trait_objects)]
3433

3534
extern crate alloc;
3635
extern crate rustc_data_structures;

0 commit comments

Comments
 (0)