Skip to content

Commit 35f8202

Browse files
authored
fix(toml): Force script edition warnings on quiet (rust-lang#16848)
### What does this PR try to resolve? With closing of rust-lang#16598, we were stating that "unpinned edition" message should not be silenced. However, by default all warnings are silenced with `--quiet`. This also extends to `cargo foo.rs 2>&1 output.txt` because that implies `--quiet` for now until we are better able to limit the output of Cargo (see rust-lang#8889). This tty-dependent verbosity was not necessarily intended to silence this specific warning. This changes the edition warning so it is "forced" to always be displayed, regardless of verbosity, closing that hole for silencing it. ### How to test and review this PR?
2 parents 7ceced2 + d4db892 commit 35f8202

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/cargo/util/toml/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,9 +633,10 @@ fn normalize_package_toml<'a>(
633633
if is_embedded {
634634
const DEFAULT_EDITION: crate::core::features::Edition =
635635
crate::core::features::Edition::LATEST_STABLE;
636-
let _ = gctx.shell().warn(format_args!(
636+
let report = [Group::with_title(Level::WARNING.secondary_title(format!(
637637
"`package.edition` is unspecified, defaulting to the latest edition (currently `{DEFAULT_EDITION}`)"
638-
));
638+
)))];
639+
let _ = gctx.shell().print_report(&report, true);
639640
Some(manifest::InheritableField::Value(
640641
DEFAULT_EDITION.to_string(),
641642
))

tests/testsuite/script/cargo.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ rustc = "non-existent-rustc"
414414
.masquerade_as_nightly_cargo(&["script"])
415415
.with_status(101)
416416
.with_stderr_data(str![[r#"
417+
[WARNING] `package.edition` is unspecified, defaulting to the latest edition (currently `2024`)
417418
[ERROR] could not execute process `non-existent-rustc -vV` (never executed)
418419
419420
Caused by:
@@ -449,7 +450,10 @@ arg0: [..]
449450
args: ["-NotAnArg"]
450451
451452
"#]])
452-
.with_stderr_data("")
453+
.with_stderr_data(str![[r#"
454+
[WARNING] `package.edition` is unspecified, defaulting to the latest edition (currently `[..]`)
455+
456+
"#]])
453457
.run();
454458
}
455459

@@ -468,7 +472,10 @@ arg0: [..]
468472
args: ["-NotAnArg"]
469473
470474
"#]])
471-
.with_stderr_data("")
475+
.with_stderr_data(str![[r#"
476+
[WARNING] `package.edition` is unspecified, defaulting to the latest edition (currently `[..]`)
477+
478+
"#]])
472479
.run();
473480
}
474481

0 commit comments

Comments
 (0)