diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 84415baa3a140..936bed482e6f5 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -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 { diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index fbae3629c4bd9..6f2bf5f397bc8 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -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", @@ -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.