Skip to content

Commit

Permalink
Move warnings out of rustc wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed Sep 4, 2019
1 parent 669c3e3 commit a2384cb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
16 changes: 3 additions & 13 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,9 @@ fn main() {
cmd.arg(format!("-Cdebuginfo={}", debuginfo_level));
}

if env::var_os("RUSTC_EXTERNAL_TOOL").is_none() {
// When extending this list, add the new lints to the RUSTFLAGS of the
// build_bootstrap function of src/bootstrap/bootstrap.py as well as
// some code doesn't go through this `rustc` wrapper.
cmd.arg("-Wrust_2018_idioms");
cmd.arg("-Wunused_lifetimes");
if use_internal_lints(crate_name) {
cmd.arg("-Zunstable-options");
cmd.arg("-Wrustc::internal");
}
if env::var_os("RUSTC_DENY_WARNINGS").is_some() {
cmd.arg("-Dwarnings");
}
if use_internal_lints(crate_name) {
cmd.arg("-Zunstable-options");
cmd.arg("-Wrustc::internal");
}

if let Some(target) = target {
Expand Down
26 changes: 22 additions & 4 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,28 @@ impl<'a> Builder<'a> {
extra_args.push_str("-Zforce-unstable-if-unmarked");
}

match mode {
Mode::ToolStd { in_tree: true } |
Mode::ToolRustc { in_tree: true } |
Mode::ToolBootstrap { in_tree: true } |
Mode::Std |
Mode::Rustc |
Mode::Codegen => {
// When extending this list, add the new lints to the RUSTFLAGS of the
// build_bootstrap function of src/bootstrap/bootstrap.py as well as
// some code doesn't go through this `rustc` wrapper.
extra_args.push_str(" -Wrust_2018_idioms");
extra_args.push_str(" -Wunused_lifetimes");
}
Mode::ToolStd { in_tree: false } |
Mode::ToolRustc { in_tree: false } |
Mode::ToolBootstrap { in_tree: false } => {}
}

if self.config.deny_warnings {
extra_args.push_str(" -Dwarnings");
}

if !extra_args.is_empty() {
cargo.env(
"RUSTFLAGS",
Expand Down Expand Up @@ -1038,10 +1060,6 @@ impl<'a> Builder<'a> {

cargo.env("RUSTC_VERBOSE", self.verbosity.to_string());

if self.config.deny_warnings {
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

0 comments on commit a2384cb

Please sign in to comment.