From 3eb35a32d8380a84355474352c09ed75676d7837 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 7 Apr 2026 11:59:12 -0500 Subject: [PATCH 1/2] refactor(toml): Switch script edition warning to report --- src/cargo/util/toml/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 57f0ac2e00b..28a8ff38085 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -633,9 +633,10 @@ fn normalize_package_toml<'a>( if is_embedded { const DEFAULT_EDITION: crate::core::features::Edition = crate::core::features::Edition::LATEST_STABLE; - let _ = gctx.shell().warn(format_args!( + let report = [Group::with_title(Level::WARNING.secondary_title(format!( "`package.edition` is unspecified, defaulting to the latest edition (currently `{DEFAULT_EDITION}`)" - )); + )))]; + let _ = gctx.shell().print_report(&report, false); Some(manifest::InheritableField::Value( DEFAULT_EDITION.to_string(), )) From d4db8929f0da1503fc5378721d9266a5d8978393 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 7 Apr 2026 12:26:01 -0500 Subject: [PATCH 2/2] 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. --- src/cargo/util/toml/mod.rs | 2 +- tests/testsuite/script/cargo.rs | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 28a8ff38085..0147890c433 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -636,7 +636,7 @@ fn normalize_package_toml<'a>( let report = [Group::with_title(Level::WARNING.secondary_title(format!( "`package.edition` is unspecified, defaulting to the latest edition (currently `{DEFAULT_EDITION}`)" )))]; - let _ = gctx.shell().print_report(&report, false); + let _ = gctx.shell().print_report(&report, true); Some(manifest::InheritableField::Value( DEFAULT_EDITION.to_string(), )) diff --git a/tests/testsuite/script/cargo.rs b/tests/testsuite/script/cargo.rs index c2868fa9fd1..d06f84c8365 100644 --- a/tests/testsuite/script/cargo.rs +++ b/tests/testsuite/script/cargo.rs @@ -414,6 +414,7 @@ rustc = "non-existent-rustc" .masquerade_as_nightly_cargo(&["script"]) .with_status(101) .with_stderr_data(str![[r#" +[WARNING] `package.edition` is unspecified, defaulting to the latest edition (currently `2024`) [ERROR] could not execute process `non-existent-rustc -vV` (never executed) Caused by: @@ -449,7 +450,10 @@ arg0: [..] args: ["-NotAnArg"] "#]]) - .with_stderr_data("") + .with_stderr_data(str![[r#" +[WARNING] `package.edition` is unspecified, defaulting to the latest edition (currently `[..]`) + +"#]]) .run(); } @@ -468,7 +472,10 @@ arg0: [..] args: ["-NotAnArg"] "#]]) - .with_stderr_data("") + .with_stderr_data(str![[r#" +[WARNING] `package.edition` is unspecified, defaulting to the latest edition (currently `[..]`) + +"#]]) .run(); }