Skip to content

Commit 43e994c

Browse files
committed
Auto merge of #49715 - Mark-Simulacrum:deny-warnings, r=alexcrichton
Move deny(warnings) into rustbuild This permits easier iteration without having to worry about warnings being denied. Fixes #49517
2 parents 88ebd97 + 53718d2 commit 43e994c

File tree

58 files changed

+29
-63
lines changed

Some content is hidden

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

58 files changed

+29
-63
lines changed

config.toml.example

+3
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@
339339
# rustc to execute.
340340
#lld = false
341341

342+
# Whether to deny warnings in crates
343+
#deny-warnings = true
344+
342345
# =============================================================================
343346
# Options for specific targets
344347
#

src/bootstrap/bin/rustc.rs

+4
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ fn main() {
279279
cmd.arg("--color=always");
280280
}
281281

282+
if env::var_os("RUSTC_DENY_WARNINGS").is_some() {
283+
cmd.arg("-Dwarnings");
284+
}
285+
282286
if verbose > 1 {
283287
eprintln!("rustc command: {:?}", cmd);
284288
eprintln!("sysroot: {:?}", sysroot);

src/bootstrap/builder.rs

+5
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,11 @@ impl<'a> Builder<'a> {
698698

699699
cargo.env("RUSTC_VERBOSE", format!("{}", self.verbosity));
700700

701+
// in std, we want to avoid denying warnings for stage 0 as that makes cfg's painful.
702+
if self.config.deny_warnings && !(mode == Mode::Libstd && stage == 0) {
703+
cargo.env("RUSTC_DENY_WARNINGS", "1");
704+
}
705+
701706
// Throughout the build Cargo can execute a number of build scripts
702707
// compiling C/C++ code and we need to pass compilers, archivers, flags, etc
703708
// obtained previously to those build scripts.

src/bootstrap/config.rs

+8
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ pub struct Config {
7171
pub incremental: bool,
7272
pub dry_run: bool,
7373

74+
pub deny_warnings: bool,
75+
7476
// llvm codegen options
7577
pub llvm_enabled: bool,
7678
pub llvm_assertions: bool,
@@ -301,6 +303,7 @@ struct Rust {
301303
codegen_backends_dir: Option<String>,
302304
wasm_syscall: Option<bool>,
303305
lld: Option<bool>,
306+
deny_warnings: Option<bool>,
304307
}
305308

306309
/// TOML representation of how each build target is configured.
@@ -340,6 +343,7 @@ impl Config {
340343
config.test_miri = false;
341344
config.rust_codegen_backends = vec![INTERNER.intern_str("llvm")];
342345
config.rust_codegen_backends_dir = "codegen-backends".to_owned();
346+
config.deny_warnings = true;
343347

344348
// set by bootstrap.py
345349
config.src = env::var_os("SRC").map(PathBuf::from).expect("'SRC' to be set");
@@ -366,6 +370,9 @@ impl Config {
366370
config.incremental = flags.incremental;
367371
config.dry_run = flags.dry_run;
368372
config.keep_stage = flags.keep_stage;
373+
if let Some(value) = flags.warnings {
374+
config.deny_warnings = value;
375+
}
369376

370377
if config.dry_run {
371378
let dir = config.out.join("tmp-dry-run");
@@ -511,6 +518,7 @@ impl Config {
511518
config.rustc_default_linker = rust.default_linker.clone();
512519
config.musl_root = rust.musl_root.clone().map(PathBuf::from);
513520
config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
521+
set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
514522

515523
if let Some(ref backends) = rust.codegen_backends {
516524
config.rust_codegen_backends = backends.iter()

src/bootstrap/flags.rs

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ pub struct Flags {
4242
pub exclude: Vec<PathBuf>,
4343
pub rustc_error_format: Option<String>,
4444
pub dry_run: bool,
45+
46+
// true => deny
47+
pub warnings: Option<bool>,
4548
}
4649

4750
pub enum Subcommand {
@@ -118,6 +121,8 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
118121
opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
119122
opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS");
120123
opts.optflag("h", "help", "print this help message");
124+
opts.optopt("", "warnings", "if value is deny, will deny warnings, otherwise use default",
125+
"VALUE");
121126
opts.optopt("", "error-format", "rustc error format", "FORMAT");
122127

123128
// fn usage()
@@ -374,6 +379,7 @@ Arguments:
374379
incremental: matches.opt_present("incremental"),
375380
exclude: split(matches.opt_strs("exclude"))
376381
.into_iter().map(|p| p.into()).collect::<Vec<_>>(),
382+
warnings: matches.opt_str("warnings").map(|v| v == "deny"),
377383
}
378384
}
379385
}

src/build_helper/lib.rs

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

11-
#![deny(warnings)]
1211

1312
use std::fs::File;
1413
use std::path::{Path, PathBuf};

src/liballoc/benches/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(warnings)]
12-
1311
#![feature(rand)]
1412
#![feature(repr_simd)]
1513
#![feature(slice_sort_by_cached_key)]

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(warnings)]
7675
#![deny(missing_debug_implementations)]
7776

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

src/liballoc/tests/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(warnings)]
12-
1311
#![feature(allocator_api)]
1412
#![feature(alloc_system)]
1513
#![feature(attr_literals)]

src/liballoc_jemalloc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
reason = "this library is unlikely to be stabilized in its current \
1515
form or name",
1616
issue = "27783")]
17-
#![deny(warnings)]
1817
#![feature(alloc_system)]
1918
#![feature(libc)]
2019
#![feature(linkage)]

src/liballoc_system/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#![no_std]
1212
#![allow(unused_attributes)]
13-
#![deny(warnings)]
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

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
2323
html_root_url = "https://doc.rust-lang.org/nightly/",
2424
test(no_crate_inject, attr(deny(warnings))))]
25-
#![deny(warnings)]
2625

2726
#![feature(alloc)]
2827
#![feature(core_intrinsics)]

src/libcore/benches/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(warnings)]
12-
1311
#![feature(flt2dec)]
1412
#![feature(test)]
1513

src/libcore/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
#![no_core]
6464
#![deny(missing_docs)]
6565
#![deny(missing_debug_implementations)]
66-
#![deny(warnings)]
6766

6867
#![feature(allow_internal_unstable)]
6968
#![feature(asm)]

src/libcore/tests/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(warnings)]
12-
1311
#![feature(ascii_ctype)]
1412
#![feature(box_syntax)]
1513
#![feature(core_float)]

src/libfmt_macros/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
html_root_url = "https://doc.rust-lang.org/nightly/",
2020
html_playground_url = "https://play.rust-lang.org/",
2121
test(attr(deny(warnings))))]
22-
#![deny(warnings)]
2322

2423
pub use self::Piece::*;
2524
pub use self::Position::*;

src/libgraphviz/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@
287287
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
288288
html_root_url = "https://doc.rust-lang.org/nightly/",
289289
test(attr(allow(unused_variables), deny(warnings))))]
290-
#![deny(warnings)]
291290

292291
#![feature(str_escape)]
293292

src/libpanic_abort/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
2020
html_root_url = "https://doc.rust-lang.org/nightly/",
2121
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
22-
#![deny(warnings)]
2322
#![panic_runtime]
2423
#![allow(unused_features)]
2524

src/libpanic_unwind/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
2929
html_root_url = "https://doc.rust-lang.org/nightly/",
3030
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
31-
#![deny(warnings)]
3231

3332
#![feature(alloc)]
3433
#![feature(core_intrinsics)]

src/libproc_macro/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
//! See [the book](../book/first-edition/procedural-macros.html) for more.
2525
2626
#![stable(feature = "proc_macro_lib", since = "1.15.0")]
27-
#![deny(warnings)]
2827
#![deny(missing_docs)]
2928
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
3029
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",

src/librustc/benches/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(warnings)]
12-
1311
#![feature(test)]
1412

1513
extern crate test;

src/librustc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
4040
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
4141
html_root_url = "https://doc.rust-lang.org/nightly/")]
42-
#![deny(warnings)]
4342

4443
#![feature(box_patterns)]
4544
#![feature(box_syntax)]

src/librustc_allocator/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(warnings)]
12-
1311
#![feature(rustc_private)]
1412

1513
extern crate rustc;

src/librustc_apfloat/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
4444
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
4545
html_root_url = "https://doc.rust-lang.org/nightly/")]
46-
#![deny(warnings)]
4746
#![forbid(unsafe_code)]
4847

4948
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.

src/librustc_back/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2525
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
2626
html_root_url = "https://doc.rust-lang.org/nightly/")]
27-
#![deny(warnings)]
2827

2928
#![feature(box_syntax)]
3029
#![feature(const_fn)]

src/librustc_borrowck/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1212
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
1313
html_root_url = "https://doc.rust-lang.org/nightly/")]
14-
#![deny(warnings)]
1514

1615
#![allow(non_camel_case_types)]
1716

src/librustc_const_math/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1818
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
1919
html_root_url = "https://doc.rust-lang.org/nightly/")]
20-
#![deny(warnings)]
2120

2221
extern crate rustc_apfloat;
2322

src/librustc_data_structures/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2020
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
2121
html_root_url = "https://doc.rust-lang.org/nightly/")]
22-
#![deny(warnings)]
2322

2423
#![feature(collections_range)]
2524
#![feature(nonzero)]

src/librustc_driver/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1818
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
1919
html_root_url = "https://doc.rust-lang.org/nightly/")]
20-
#![deny(warnings)]
2120

2221
#![feature(box_syntax)]
2322
#![cfg_attr(unix, feature(libc))]

src/librustc_errors/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1212
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
1313
html_root_url = "https://doc.rust-lang.org/nightly/")]
14-
#![deny(warnings)]
1514

1615
#![feature(custom_attribute)]
1716
#![allow(unused_attributes)]

src/librustc_incremental/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1414
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
1515
html_root_url = "https://doc.rust-lang.org/nightly/")]
16-
#![deny(warnings)]
1716

1817
#![feature(fs_read_write)]
1918
#![feature(specialization)]

src/librustc_lint/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2323
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
2424
html_root_url = "https://doc.rust-lang.org/nightly/")]
25-
#![deny(warnings)]
2625

2726
#![cfg_attr(test, feature(test))]
2827
#![feature(box_patterns)]

src/librustc_llvm/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1717
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
1818
html_root_url = "https://doc.rust-lang.org/nightly/")]
19-
#![deny(warnings)]
2019

2120
#![feature(box_syntax)]
2221
#![feature(concat_idents)]

src/librustc_metadata/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1212
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
1313
html_root_url = "https://doc.rust-lang.org/nightly/")]
14-
#![deny(warnings)]
1514

1615
#![feature(box_patterns)]
1716
#![feature(fs_read_write)]

src/librustc_mir/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
1414
1515
*/
1616

17-
#![deny(warnings)]
18-
1917
#![feature(slice_patterns)]
2018
#![feature(from_ref)]
2119
#![feature(box_patterns)]

src/librustc_passes/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1818
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
1919
html_root_url = "https://doc.rust-lang.org/nightly/")]
20-
#![deny(warnings)]
2120

2221
#![feature(rustc_diagnostic_macros)]
2322

src/librustc_platform_intrinsics/lib.rs

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

11-
#![deny(warnings)]
1211
#![allow(bad_style)]
1312

1413
pub struct Intrinsic {

src/librustc_plugin/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
6464
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
6565
html_root_url = "https://doc.rust-lang.org/nightly/")]
66-
#![deny(warnings)]
6766

6867
#![feature(rustc_diagnostic_macros)]
6968
#![feature(staged_api)]

src/librustc_privacy/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1212
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
1313
html_root_url = "https://doc.rust-lang.org/nightly/")]
14-
#![deny(warnings)]
1514

1615
#![feature(rustc_diagnostic_macros)]
1716

src/librustc_resolve/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1212
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
1313
html_root_url = "https://doc.rust-lang.org/nightly/")]
14-
#![deny(warnings)]
1514

1615
#![feature(rustc_diagnostic_macros)]
1716

src/librustc_save_analysis/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
1212
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
1313
html_root_url = "https://doc.rust-lang.org/nightly/")]
14-
#![deny(warnings)]
1514
#![feature(custom_attribute)]
1615
#![feature(macro_lifetime_matcher)]
1716
#![allow(unused_attributes)]

0 commit comments

Comments
 (0)