Skip to content

Commit c6f868f

Browse files
Move warnings out of rustc wrapper
1 parent 27b0946 commit c6f868f

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

src/bootstrap/bin/rustc.rs

+3-13
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,9 @@ fn main() {
119119
cmd.arg(format!("-Cdebuginfo={}", debuginfo_level));
120120
}
121121

122-
if env::var_os("RUSTC_EXTERNAL_TOOL").is_none() {
123-
// When extending this list, add the new lints to the RUSTFLAGS of the
124-
// build_bootstrap function of src/bootstrap/bootstrap.py as well as
125-
// some code doesn't go through this `rustc` wrapper.
126-
cmd.arg("-Wrust_2018_idioms");
127-
cmd.arg("-Wunused_lifetimes");
128-
if use_internal_lints(crate_name) {
129-
cmd.arg("-Zunstable-options");
130-
cmd.arg("-Wrustc::internal");
131-
}
132-
if env::var_os("RUSTC_DENY_WARNINGS").is_some() {
133-
cmd.arg("-Dwarnings");
134-
}
122+
if use_internal_lints(crate_name) {
123+
cmd.arg("-Zunstable-options");
124+
cmd.arg("-Wrustc::internal");
135125
}
136126

137127
if let Some(target) = target {

src/bootstrap/builder.rs

+22-4
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,28 @@ impl<'a> Builder<'a> {
875875
extra_args.push_str("-Zforce-unstable-if-unmarked");
876876
}
877877

878+
match mode {
879+
Mode::ToolStd { in_tree: true } |
880+
Mode::ToolRustc { in_tree: true } |
881+
Mode::ToolBootstrap { in_tree: true } |
882+
Mode::Std |
883+
Mode::Rustc |
884+
Mode::Codegen => {
885+
// When extending this list, add the new lints to the RUSTFLAGS of the
886+
// build_bootstrap function of src/bootstrap/bootstrap.py as well as
887+
// some code doesn't go through this `rustc` wrapper.
888+
extra_args.push_str(" -Wrust_2018_idioms");
889+
extra_args.push_str(" -Wunused_lifetimes");
890+
}
891+
Mode::ToolStd { in_tree: false } |
892+
Mode::ToolRustc { in_tree: false } |
893+
Mode::ToolBootstrap { in_tree: false } => {}
894+
}
895+
896+
if self.config.deny_warnings {
897+
extra_args.push_str(" -Dwarnings");
898+
}
899+
878900
if !extra_args.is_empty() {
879901
cargo.env(
880902
"RUSTFLAGS",
@@ -1038,10 +1060,6 @@ impl<'a> Builder<'a> {
10381060

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

1041-
if self.config.deny_warnings {
1042-
cargo.env("RUSTC_DENY_WARNINGS", "1");
1043-
}
1044-
10451063
// Throughout the build Cargo can execute a number of build scripts
10461064
// compiling C/C++ code and we need to pass compilers, archivers, flags, etc
10471065
// obtained previously to those build scripts.

0 commit comments

Comments
 (0)