Skip to content

Commit 439ec56

Browse files
committed
Auto merge of #64216 - Centril:rollup-5cc1w7o, r=Centril
Rollup of 9 pull requests Successful merges: - #64067 (Remove no-prefer-dynamic from valgrind tests) - #64078 (compiletest: disable -Aunused for run-pass tests) - #64096 (Fix regex replacement in theme detection) - #64098 (Ensure edition lints and internal lints are enabled with deny-warnings=false) - #64166 (Better way of conditioning the sanitizer builds) - #64189 (annotate-snippet emitter: Deal with multispans from macros, too) - #64202 (Fixed grammar/style in some error messages) - #64206 (annotate-snippet emitter: Update an issue number) - #64208 (it's more pythonic to use 'is not None' in python files) Failed merges: r? @ghost
2 parents 4894123 + 4ac73a1 commit 439ec56

File tree

212 files changed

+746
-689
lines changed

Some content is hidden

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

212 files changed

+746
-689
lines changed

src/bootstrap/bin/rustc.rs

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

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

136127
if let Some(target) = target {

src/bootstrap/bootstrap.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,9 @@ def build_bootstrap(self):
631631
target_linker = self.get_toml("linker", build_section)
632632
if target_linker is not None:
633633
env["RUSTFLAGS"] += "-C linker=" + target_linker + " "
634+
env["RUSTFLAGS"] += " -Wrust_2018_idioms -Wunused_lifetimes "
634635
if self.get_toml("deny-warnings", "rust") != "false":
635-
env["RUSTFLAGS"] += "-Dwarnings -Drust_2018_idioms -Dunused_lifetimes "
636+
env["RUSTFLAGS"] += "-Dwarnings "
636637

637638
env["PATH"] = os.path.join(self.bin_root(), "bin") + \
638639
os.pathsep + env["PATH"]
@@ -668,7 +669,7 @@ def check_submodule(self, module, slow_submodules):
668669
def update_submodule(self, module, checked_out, recorded_submodules):
669670
module_path = os.path.join(self.rust_root, module)
670671

671-
if checked_out != None:
672+
if checked_out is not None:
672673
default_encoding = sys.getdefaultencoding()
673674
checked_out = checked_out.communicate()[0].decode(default_encoding).strip()
674675
if recorded_submodules[module] == checked_out:

src/bootstrap/builder.rs

+35-10
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,9 @@ impl<'a> Builder<'a> {
765765
if cmd == "doc" || cmd == "rustdoc" {
766766
let my_out = match mode {
767767
// This is the intended out directory for compiler documentation.
768-
Mode::Rustc | Mode::ToolRustc | Mode::Codegen => self.compiler_doc_out(target),
768+
Mode::Rustc | Mode::ToolRustc { .. } | Mode::Codegen => {
769+
self.compiler_doc_out(target)
770+
}
769771
_ => self.crate_doc_out(target),
770772
};
771773
let rustdoc = self.rustdoc(compiler);
@@ -797,8 +799,8 @@ impl<'a> Builder<'a> {
797799
}
798800

799801
match mode {
800-
Mode::Std | Mode::ToolBootstrap | Mode::ToolStd => {},
801-
Mode::Rustc | Mode::Codegen | Mode::ToolRustc => {
802+
Mode::Std | Mode::ToolBootstrap { .. } | Mode::ToolStd { .. } => {},
803+
Mode::Rustc | Mode::Codegen | Mode::ToolRustc { .. } => {
802804
// Build proc macros both for the host and the target
803805
if target != compiler.host && cmd != "check" {
804806
cargo.arg("-Zdual-proc-macros");
@@ -873,6 +875,28 @@ impl<'a> Builder<'a> {
873875
extra_args.push_str("-Zforce-unstable-if-unmarked");
874876
}
875877

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+
876900
if !extra_args.is_empty() {
877901
cargo.env(
878902
"RUSTFLAGS",
@@ -891,7 +915,11 @@ impl<'a> Builder<'a> {
891915
// the stage0 build means it uses libraries build by the stage0
892916
// compiler, but for tools we just use the precompiled libraries that
893917
// we've downloaded
894-
let use_snapshot = mode == Mode::ToolBootstrap;
918+
let use_snapshot = if let Mode::ToolBootstrap { .. } = mode {
919+
true
920+
} else {
921+
false
922+
};
895923
assert!(!use_snapshot || stage == 0 || self.local_rebuild);
896924

897925
let maybe_sysroot = self.sysroot(compiler);
@@ -944,8 +972,9 @@ impl<'a> Builder<'a> {
944972
let debuginfo_level = match mode {
945973
Mode::Rustc | Mode::Codegen => self.config.rust_debuginfo_level_rustc,
946974
Mode::Std => self.config.rust_debuginfo_level_std,
947-
Mode::ToolBootstrap | Mode::ToolStd |
948-
Mode::ToolRustc => self.config.rust_debuginfo_level_tools,
975+
Mode::ToolBootstrap { .. } | Mode::ToolStd { .. } | Mode::ToolRustc { .. } => {
976+
self.config.rust_debuginfo_level_tools
977+
}
949978
};
950979
cargo.env("RUSTC_DEBUGINFO_LEVEL", debuginfo_level.to_string());
951980

@@ -1031,10 +1060,6 @@ impl<'a> Builder<'a> {
10311060

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

1034-
if self.config.deny_warnings {
1035-
cargo.env("RUSTC_DENY_WARNINGS", "1");
1036-
}
1037-
10381063
// Throughout the build Cargo can execute a number of build scripts
10391064
// compiling C/C++ code and we need to pass compilers, archivers, flags, etc
10401065
// obtained previously to those build scripts.

src/bootstrap/check.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use crate::compile::{run_cargo, std_cargo, rustc_cargo, rustc_cargo_env,
44
add_to_sysroot};
55
use crate::builder::{RunConfig, Builder, Kind, ShouldRun, Step};
6-
use crate::tool::{prepare_tool_cargo, SourceType};
6+
use crate::tool::prepare_tool_cargo;
77
use crate::{Compiler, Mode};
88
use crate::cache::{INTERNER, Interned};
99
use std::path::PathBuf;
@@ -187,11 +187,10 @@ impl Step for Rustdoc {
187187

188188
let mut cargo = prepare_tool_cargo(builder,
189189
compiler,
190-
Mode::ToolRustc,
190+
Mode::ToolRustc { in_tree: true },
191191
target,
192192
cargo_subcommand(builder.kind),
193193
"src/tools/rustdoc",
194-
SourceType::InTree,
195194
&[]);
196195

197196
println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target);
@@ -244,6 +243,7 @@ pub fn rustdoc_stamp(
244243
compiler: Compiler,
245244
target: Interned<String>,
246245
) -> PathBuf {
247-
builder.cargo_out(compiler, Mode::ToolRustc, target)
246+
// doesn't really matter whether we're in-tree or not
247+
builder.cargo_out(compiler, Mode::ToolRustc { in_tree: true }, target)
248248
.join(".rustdoc-check.stamp")
249249
}

src/bootstrap/compile.rs

+1
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ pub fn std_cargo(builder: &Builder<'_>,
212212
emscripten: false,
213213
});
214214
cargo.env("LLVM_CONFIG", llvm_config);
215+
cargo.env("RUSTC_BUILD_SANITIZERS", "1");
215216
}
216217

217218
cargo.arg("--features").arg(features)

src/bootstrap/doc.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use build_helper::{t, up_to_date};
1717

1818
use crate::util::symlink_dir;
1919
use crate::builder::{Builder, Compiler, RunConfig, ShouldRun, Step};
20-
use crate::tool::{self, prepare_tool_cargo, Tool, SourceType};
20+
use crate::tool::{self, prepare_tool_cargo, Tool};
2121
use crate::compile;
2222
use crate::cache::{INTERNER, Interned};
2323
use crate::config::Config;
@@ -633,7 +633,7 @@ impl Step for Rustdoc {
633633
builder.ensure(tool::Rustdoc { compiler: compiler });
634634

635635
// Symlink compiler docs to the output directory of rustdoc documentation.
636-
let out_dir = builder.stage_out(compiler, Mode::ToolRustc)
636+
let out_dir = builder.stage_out(compiler, Mode::ToolRustc { in_tree: true })
637637
.join(target)
638638
.join("doc");
639639
t!(fs::create_dir_all(&out_dir));
@@ -643,11 +643,10 @@ impl Step for Rustdoc {
643643
let mut cargo = prepare_tool_cargo(
644644
builder,
645645
compiler,
646-
Mode::ToolRustc,
646+
Mode::ToolRustc { in_tree: true },
647647
target,
648648
"doc",
649649
"src/tools/rustdoc",
650-
SourceType::InTree,
651650
&[]
652651
);
653652

src/bootstrap/flags.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub struct Flags {
3636
// This overrides the deny-warnings configuation option,
3737
// which passes -Dwarnings to the compiler invocations.
3838
//
39-
// true => deny, false => allow
39+
// true => deny, false => warn
4040
pub deny_warnings: Option<bool>,
4141
}
4242

@@ -556,10 +556,10 @@ fn split(s: &[String]) -> Vec<String> {
556556
fn parse_deny_warnings(matches: &getopts::Matches) -> Option<bool> {
557557
match matches.opt_str("warnings").as_ref().map(|v| v.as_str()) {
558558
Some("deny") => Some(true),
559-
Some("allow") => Some(false),
559+
Some("warn") => Some(false),
560560
Some(value) => {
561561
eprintln!(
562-
r#"invalid value for --warnings: {:?}, expected "allow" or "deny""#,
562+
r#"invalid value for --warnings: {:?}, expected "warn" or "deny""#,
563563
value,
564564
);
565565
process::exit(1);

src/bootstrap/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -304,19 +304,19 @@ pub enum Mode {
304304
/// "other" here is for miscellaneous sets of tools that are built using the
305305
/// bootstrap compiler in its entirety (target libraries and all).
306306
/// Typically these tools compile with stable Rust.
307-
ToolBootstrap,
307+
ToolBootstrap { in_tree: bool },
308308

309309
/// Compile a tool which uses all libraries we compile (up to rustc).
310310
/// Doesn't use the stage0 compiler libraries like "other", and includes
311311
/// tools like rustdoc, cargo, rls, etc.
312-
ToolStd,
313-
ToolRustc,
312+
ToolStd { in_tree: bool },
313+
ToolRustc { in_tree: bool },
314314
}
315315

316316
impl Mode {
317317
pub fn is_tool(&self) -> bool {
318318
match self {
319-
Mode::ToolBootstrap | Mode::ToolRustc | Mode::ToolStd => true,
319+
Mode::ToolBootstrap { .. } | Mode::ToolRustc { .. } | Mode::ToolStd { .. } => true,
320320
_ => false
321321
}
322322
}
@@ -528,8 +528,8 @@ impl Build {
528528
Mode::Std => "-std",
529529
Mode::Rustc => "-rustc",
530530
Mode::Codegen => "-codegen",
531-
Mode::ToolBootstrap => "-bootstrap-tools",
532-
Mode::ToolStd | Mode::ToolRustc => "-tools",
531+
Mode::ToolBootstrap { .. } => "-bootstrap-tools",
532+
Mode::ToolStd { .. } | Mode::ToolRustc { .. } => "-tools",
533533
};
534534
self.out.join(&*compiler.host)
535535
.join(format!("stage{}{}", compiler.stage, suffix))

src/bootstrap/test.rs

+10-18
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::compile;
1919
use crate::dist;
2020
use crate::flags::Subcommand;
2121
use crate::native;
22-
use crate::tool::{self, Tool, SourceType};
22+
use crate::tool::{self, Tool};
2323
use crate::toolstate::ToolState;
2424
use crate::util::{self, dylib_path, dylib_path_var};
2525
use crate::Crate as CargoCrate;
@@ -213,11 +213,10 @@ impl Step for Cargo {
213213
});
214214
let mut cargo = tool::prepare_tool_cargo(builder,
215215
compiler,
216-
Mode::ToolRustc,
216+
Mode::ToolRustc { in_tree: false },
217217
self.host,
218218
"test",
219219
"src/tools/cargo",
220-
SourceType::Submodule,
221220
&[]);
222221

223222
if !builder.fail_fast {
@@ -279,11 +278,10 @@ impl Step for Rls {
279278

280279
let mut cargo = tool::prepare_tool_cargo(builder,
281280
compiler,
282-
Mode::ToolRustc,
281+
Mode::ToolRustc { in_tree: false },
283282
host,
284283
"test",
285284
"src/tools/rls",
286-
SourceType::Submodule,
287285
&[]);
288286

289287
builder.add_rustc_lib_path(compiler, &mut cargo);
@@ -335,11 +333,10 @@ impl Step for Rustfmt {
335333

336334
let mut cargo = tool::prepare_tool_cargo(builder,
337335
compiler,
338-
Mode::ToolRustc,
336+
Mode::ToolRustc { in_tree: false },
339337
host,
340338
"test",
341339
"src/tools/rustfmt",
342-
SourceType::Submodule,
343340
&[]);
344341

345342
let dir = testdir(builder, compiler.host);
@@ -392,11 +389,10 @@ impl Step for Miri {
392389
let mut cargo = tool::prepare_tool_cargo(
393390
builder,
394391
compiler,
395-
Mode::ToolRustc,
392+
Mode::ToolRustc { in_tree: false },
396393
host,
397394
"run",
398395
"src/tools/miri",
399-
SourceType::Submodule,
400396
&[],
401397
);
402398
cargo
@@ -451,11 +447,10 @@ impl Step for Miri {
451447
let mut cargo = tool::prepare_tool_cargo(
452448
builder,
453449
compiler,
454-
Mode::ToolRustc,
450+
Mode::ToolRustc { in_tree: false },
455451
host,
456452
"test",
457453
"src/tools/miri",
458-
SourceType::Submodule,
459454
&[],
460455
);
461456

@@ -504,11 +499,10 @@ impl Step for CompiletestTest {
504499

505500
let mut cargo = tool::prepare_tool_cargo(builder,
506501
compiler,
507-
Mode::ToolBootstrap,
502+
Mode::ToolBootstrap { in_tree: true },
508503
host,
509504
"test",
510505
"src/tools/compiletest",
511-
SourceType::InTree,
512506
&[]);
513507

514508
try_run(builder, &mut cargo);
@@ -551,19 +545,18 @@ impl Step for Clippy {
551545
if let Some(clippy) = clippy {
552546
let mut cargo = tool::prepare_tool_cargo(builder,
553547
compiler,
554-
Mode::ToolRustc,
548+
Mode::ToolRustc { in_tree: false },
555549
host,
556550
"test",
557551
"src/tools/clippy",
558-
SourceType::Submodule,
559552
&[]);
560553

561554
// clippy tests need to know about the stage sysroot
562555
cargo.env("SYSROOT", builder.sysroot(compiler));
563556
cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
564557
cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
565558
let host_libs = builder
566-
.stage_out(compiler, Mode::ToolRustc)
559+
.stage_out(compiler, Mode::ToolRustc { in_tree: false })
567560
.join(builder.cargo_dir());
568561
cargo.env("HOST_LIBS", host_libs);
569562
// clippy tests need to find the driver
@@ -1877,11 +1870,10 @@ impl Step for CrateRustdoc {
18771870

18781871
let mut cargo = tool::prepare_tool_cargo(builder,
18791872
compiler,
1880-
Mode::ToolRustc,
1873+
Mode::ToolRustc { in_tree: true },
18811874
target,
18821875
test_kind.subcommand(),
18831876
"src/tools/rustdoc",
1884-
SourceType::InTree,
18851877
&[]);
18861878
if test_kind.subcommand() == "test" && !builder.fail_fast {
18871879
cargo.arg("--no-fail-fast");

0 commit comments

Comments
 (0)