Skip to content

Commit d4db892

Browse files
committed
fix(toml): Force script edition warnings on quiet
With closing of #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 #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.
1 parent 3eb35a3 commit d4db892

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/cargo/util/toml/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ fn normalize_package_toml<'a>(
636636
let report = [Group::with_title(Level::WARNING.secondary_title(format!(
637637
"`package.edition` is unspecified, defaulting to the latest edition (currently `{DEFAULT_EDITION}`)"
638638
)))];
639-
let _ = gctx.shell().print_report(&report, false);
639+
let _ = gctx.shell().print_report(&report, true);
640640
Some(manifest::InheritableField::Value(
641641
DEFAULT_EDITION.to_string(),
642642
))

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)