Skip to content

Commit

Permalink
Move deny(warnings) into rustbuild
Browse files Browse the repository at this point in the history
This permits easier iteration without having to worry about warnings
being denied.

Fixes #49517
  • Loading branch information
Mark-Simulacrum committed Apr 8, 2018
1 parent b7da1aa commit c115cc6
Show file tree
Hide file tree
Showing 56 changed files with 26 additions and 63 deletions.
3 changes: 3 additions & 0 deletions config.toml.example
Expand Up @@ -339,6 +339,9 @@
# rustc to execute.
#lld = false

# Whether to deny warnings in crates
#deny-warnings = true

# =============================================================================
# Options for specific targets
#
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/bin/rustc.rs
Expand Up @@ -279,6 +279,10 @@ fn main() {
cmd.arg("--color=always");
}

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

if verbose > 1 {
eprintln!("rustc command: {:?}", cmd);
eprintln!("sysroot: {:?}", sysroot);
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/builder.rs
Expand Up @@ -698,6 +698,11 @@ impl<'a> Builder<'a> {

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

// in std, we want to avoid denying warnings for stage 0 as that makes cfg's painful.
if self.config.deny_warnings && !(mode == Mode::Libstd && stage == 0) {
cargo.env("RUSTC_DENY_WARNINGS", "1");
}

// Throughout the build Cargo can execute a number of build scripts
// compiling C/C++ code and we need to pass compilers, archivers, flags, etc
// obtained previously to those build scripts.
Expand Down
8 changes: 8 additions & 0 deletions src/bootstrap/config.rs
Expand Up @@ -71,6 +71,8 @@ pub struct Config {
pub incremental: bool,
pub dry_run: bool,

pub deny_warnings: bool,

// llvm codegen options
pub llvm_enabled: bool,
pub llvm_assertions: bool,
Expand Down Expand Up @@ -301,6 +303,7 @@ struct Rust {
codegen_backends_dir: Option<String>,
wasm_syscall: Option<bool>,
lld: Option<bool>,
deny_warnings: Option<bool>,
}

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

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

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

if let Some(ref backends) = rust.codegen_backends {
config.rust_codegen_backends = backends.iter()
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap/flags.rs
Expand Up @@ -42,6 +42,9 @@ pub struct Flags {
pub exclude: Vec<PathBuf>,
pub rustc_error_format: Option<String>,
pub dry_run: bool,

// true => deny
pub warnings: Option<bool>,
}

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

// fn usage()
Expand Down Expand Up @@ -374,6 +379,7 @@ Arguments:
incremental: matches.opt_present("incremental"),
exclude: split(matches.opt_strs("exclude"))
.into_iter().map(|p| p.into()).collect::<Vec<_>>(),
warnings: matches.opt_str("warnings").map(|v| v == "deny"),
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/build_helper/lib.rs
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![deny(warnings)]

use std::fs::File;
use std::path::{Path, PathBuf};
Expand Down
2 changes: 0 additions & 2 deletions src/liballoc/benches/lib.rs
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![deny(warnings)]

#![feature(rand)]
#![feature(repr_simd)]
#![feature(slice_sort_by_cached_key)]
Expand Down
1 change: 0 additions & 1 deletion src/liballoc/lib.rs
Expand Up @@ -72,7 +72,6 @@
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
#![no_std]
#![needs_allocator]
#![deny(warnings)]
#![deny(missing_debug_implementations)]

#![cfg_attr(test, allow(deprecated))] // rand
Expand Down
2 changes: 0 additions & 2 deletions src/liballoc/tests/lib.rs
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![deny(warnings)]

#![feature(allocator_api)]
#![feature(alloc_system)]
#![feature(attr_literals)]
Expand Down
1 change: 0 additions & 1 deletion src/liballoc_jemalloc/lib.rs
Expand Up @@ -14,7 +14,6 @@
reason = "this library is unlikely to be stabilized in its current \
form or name",
issue = "27783")]
#![deny(warnings)]
#![feature(alloc_system)]
#![feature(libc)]
#![feature(linkage)]
Expand Down
1 change: 0 additions & 1 deletion src/liballoc_system/lib.rs
Expand Up @@ -10,7 +10,6 @@

#![no_std]
#![allow(unused_attributes)]
#![deny(warnings)]
#![unstable(feature = "alloc_system",
reason = "this library is unlikely to be stabilized in its current \
form or name",
Expand Down
1 change: 0 additions & 1 deletion src/libarena/lib.rs
Expand Up @@ -22,7 +22,6 @@
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/",
test(no_crate_inject, attr(deny(warnings))))]
#![deny(warnings)]

#![feature(alloc)]
#![feature(core_intrinsics)]
Expand Down
2 changes: 0 additions & 2 deletions src/libcore/benches/lib.rs
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![deny(warnings)]

#![feature(flt2dec)]
#![feature(test)]

Expand Down
1 change: 0 additions & 1 deletion src/libcore/lib.rs
Expand Up @@ -63,7 +63,6 @@
#![no_core]
#![deny(missing_docs)]
#![deny(missing_debug_implementations)]
#![deny(warnings)]

#![feature(allow_internal_unstable)]
#![feature(asm)]
Expand Down
2 changes: 0 additions & 2 deletions src/libcore/tests/lib.rs
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![deny(warnings)]

#![feature(ascii_ctype)]
#![feature(box_syntax)]
#![feature(core_float)]
Expand Down
1 change: 0 additions & 1 deletion src/libfmt_macros/lib.rs
Expand Up @@ -19,7 +19,6 @@
html_root_url = "https://doc.rust-lang.org/nightly/",
html_playground_url = "https://play.rust-lang.org/",
test(attr(deny(warnings))))]
#![deny(warnings)]

pub use self::Piece::*;
pub use self::Position::*;
Expand Down
1 change: 0 additions & 1 deletion src/libgraphviz/lib.rs
Expand Up @@ -287,7 +287,6 @@
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/",
test(attr(allow(unused_variables), deny(warnings))))]
#![deny(warnings)]

#![feature(str_escape)]

Expand Down
1 change: 0 additions & 1 deletion src/libpanic_abort/lib.rs
Expand Up @@ -19,7 +19,6 @@
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/",
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
#![deny(warnings)]
#![panic_runtime]
#![allow(unused_features)]

Expand Down
1 change: 0 additions & 1 deletion src/libpanic_unwind/lib.rs
Expand Up @@ -28,7 +28,6 @@
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/",
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
#![deny(warnings)]

#![feature(alloc)]
#![feature(core_intrinsics)]
Expand Down
1 change: 0 additions & 1 deletion src/libproc_macro/lib.rs
Expand Up @@ -24,7 +24,6 @@
//! See [the book](../book/first-edition/procedural-macros.html) for more.

#![stable(feature = "proc_macro_lib", since = "1.15.0")]
#![deny(warnings)]
#![deny(missing_docs)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
Expand Down
2 changes: 0 additions & 2 deletions src/librustc/benches/lib.rs
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![deny(warnings)]

#![feature(test)]

extern crate test;
Expand Down
1 change: 0 additions & 1 deletion src/librustc/lib.rs
Expand Up @@ -39,7 +39,6 @@
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

#![feature(box_patterns)]
#![feature(box_syntax)]
Expand Down
2 changes: 0 additions & 2 deletions src/librustc_allocator/lib.rs
Expand Up @@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![deny(warnings)]

#![feature(rustc_private)]

extern crate rustc;
Expand Down
1 change: 0 additions & 1 deletion src/librustc_apfloat/lib.rs
Expand Up @@ -43,7 +43,6 @@
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]
#![forbid(unsafe_code)]

// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
Expand Down
1 change: 0 additions & 1 deletion src/librustc_back/lib.rs
Expand Up @@ -24,7 +24,6 @@
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

#![feature(box_syntax)]
#![feature(const_fn)]
Expand Down
1 change: 0 additions & 1 deletion src/librustc_borrowck/lib.rs
Expand Up @@ -11,7 +11,6 @@
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

#![allow(non_camel_case_types)]

Expand Down
1 change: 0 additions & 1 deletion src/librustc_const_math/lib.rs
Expand Up @@ -17,7 +17,6 @@
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

extern crate rustc_apfloat;

Expand Down
1 change: 0 additions & 1 deletion src/librustc_data_structures/lib.rs
Expand Up @@ -19,7 +19,6 @@
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

#![feature(collections_range)]
#![feature(nonzero)]
Expand Down
1 change: 0 additions & 1 deletion src/librustc_driver/lib.rs
Expand Up @@ -17,7 +17,6 @@
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

#![feature(box_syntax)]
#![cfg_attr(unix, feature(libc))]
Expand Down
1 change: 0 additions & 1 deletion src/librustc_errors/lib.rs
Expand Up @@ -11,7 +11,6 @@
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

#![feature(custom_attribute)]
#![allow(unused_attributes)]
Expand Down
1 change: 0 additions & 1 deletion src/librustc_incremental/lib.rs
Expand Up @@ -13,7 +13,6 @@
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

#![feature(fs_read_write)]
#![feature(specialization)]
Expand Down
1 change: 0 additions & 1 deletion src/librustc_lint/lib.rs
Expand Up @@ -22,7 +22,6 @@
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

#![cfg_attr(test, feature(test))]
#![feature(box_patterns)]
Expand Down
1 change: 0 additions & 1 deletion src/librustc_llvm/lib.rs
Expand Up @@ -16,7 +16,6 @@
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

#![feature(box_syntax)]
#![feature(concat_idents)]
Expand Down
1 change: 0 additions & 1 deletion src/librustc_metadata/lib.rs
Expand Up @@ -11,7 +11,6 @@
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

#![feature(box_patterns)]
#![feature(fs_read_write)]
Expand Down
2 changes: 0 additions & 2 deletions src/librustc_mir/lib.rs
Expand Up @@ -14,8 +14,6 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
*/

#![deny(warnings)]

#![feature(slice_patterns)]
#![feature(from_ref)]
#![feature(box_patterns)]
Expand Down
1 change: 0 additions & 1 deletion src/librustc_passes/lib.rs
Expand Up @@ -17,7 +17,6 @@
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

#![feature(rustc_diagnostic_macros)]

Expand Down
1 change: 0 additions & 1 deletion src/librustc_platform_intrinsics/lib.rs
Expand Up @@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![deny(warnings)]
#![allow(bad_style)]

pub struct Intrinsic {
Expand Down
1 change: 0 additions & 1 deletion src/librustc_plugin/lib.rs
Expand Up @@ -63,7 +63,6 @@
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

#![feature(rustc_diagnostic_macros)]
#![feature(staged_api)]
Expand Down
1 change: 0 additions & 1 deletion src/librustc_privacy/lib.rs
Expand Up @@ -11,7 +11,6 @@
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

#![feature(rustc_diagnostic_macros)]

Expand Down
1 change: 0 additions & 1 deletion src/librustc_resolve/lib.rs
Expand Up @@ -11,7 +11,6 @@
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

#![feature(rustc_diagnostic_macros)]

Expand Down
1 change: 0 additions & 1 deletion src/librustc_save_analysis/lib.rs
Expand Up @@ -11,7 +11,6 @@
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]
#![feature(custom_attribute)]
#![feature(macro_lifetime_matcher)]
#![allow(unused_attributes)]
Expand Down

0 comments on commit c115cc6

Please sign in to comment.