From 4cc9334686c1072c4e4aaa8fb489097ded217680 Mon Sep 17 00:00:00 2001 From: Matheus Z Marchiore Date: Wed, 11 Oct 2023 14:44:34 -0300 Subject: [PATCH] feat: replacing the format of package name and version --- src/cargo/core/compiler/job_queue/mod.rs | 8 +++----- tests/testsuite/build_script.rs | 10 +++++----- tests/testsuite/build_script_env.rs | 6 +++--- tests/testsuite/build_script_extra_link_arg.rs | 2 +- tests/testsuite/features2.rs | 4 ++-- tests/testsuite/warn_on_failure.rs | 4 ++-- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/cargo/core/compiler/job_queue/mod.rs b/src/cargo/core/compiler/job_queue/mod.rs index ccde8e96e0a8..5ec132dd85bb 100644 --- a/src/cargo/core/compiler/job_queue/mod.rs +++ b/src/cargo/core/compiler/job_queue/mod.rs @@ -952,11 +952,9 @@ impl<'cfg> DrainState<'cfg> { } for warning in output.warnings.iter() { - let warning_with_package = format!( - "{} {}", - format!("[{} {}]", unit.pkg.name(), unit.pkg.version()), - warning - ); + let warning_with_package = + format!("{}@{} {}", unit.pkg.name(), unit.pkg.version(), warning); + bcx.config.shell().warn(warning_with_package)?; } diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs index 5edad2add133..b63297c7bb6b 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -3778,8 +3778,8 @@ fn warnings_emitted() { [COMPILING] foo v0.5.0 ([..]) [RUNNING] `rustc [..]` [RUNNING] `[..]` -warning: [foo 0.5.0] foo -warning: [foo 0.5.0] bar +warning: foo@0.5.0 foo +warning: foo@0.5.0 bar [RUNNING] `rustc [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", @@ -3816,7 +3816,7 @@ fn warnings_emitted_when_build_script_panics() { p.cargo("build") .with_status(101) .with_stdout("") - .with_stderr_contains("warning: [foo 0.5.0] foo\nwarning: [foo 0.5.0] bar") + .with_stderr_contains("warning: foo@0.5.0 foo\nwarning: foo@0.5.0 bar") .run(); } @@ -3929,8 +3929,8 @@ fn warnings_printed_on_vv() { [COMPILING] bar v0.1.0 [RUNNING] `[..] rustc [..]` [RUNNING] `[..]` -warning: [bar 0.1.0] foo -warning: [bar 0.1.0] bar +warning: bar@0.1.0 foo +warning: bar@0.1.0 bar [RUNNING] `[..] rustc [..]` [COMPILING] foo v0.5.0 ([..]) [RUNNING] `[..] rustc [..]` diff --git a/tests/testsuite/build_script_env.rs b/tests/testsuite/build_script_env.rs index 3302c0e668c5..09755449059b 100644 --- a/tests/testsuite/build_script_env.rs +++ b/tests/testsuite/build_script_env.rs @@ -137,12 +137,12 @@ fn rustc_bootstrap() { // NOTE: uses RUSTC_BOOTSTRAP so it will be propagated to rustc // (this matters when tests are being run with a beta or stable cargo) .env("RUSTC_BOOTSTRAP", "1") - .with_stderr_contains("warning: [has-dashes 0.0.1] Cannot set `RUSTC_BOOTSTRAP=1` [..]") + .with_stderr_contains("warning: has-dashes@0.0.1 Cannot set `RUSTC_BOOTSTRAP=1` [..]") .run(); // RUSTC_BOOTSTRAP set to the name of the library should warn p.cargo("check") .env("RUSTC_BOOTSTRAP", "has_dashes") - .with_stderr_contains("warning: [has-dashes 0.0.1] Cannot set `RUSTC_BOOTSTRAP=1` [..]") + .with_stderr_contains("warning: has-dashes@0.0.1 Cannot set `RUSTC_BOOTSTRAP=1` [..]") .run(); // RUSTC_BOOTSTRAP set to some random value should error p.cargo("check") @@ -169,7 +169,7 @@ fn rustc_bootstrap() { // NOTE: uses RUSTC_BOOTSTRAP so it will be propagated to rustc // (this matters when tests are being run with a beta or stable cargo) .env("RUSTC_BOOTSTRAP", "1") - .with_stderr_contains("warning: [foo 0.0.1] Cannot set `RUSTC_BOOTSTRAP=1` [..]") + .with_stderr_contains("warning: foo@0.0.1 Cannot set `RUSTC_BOOTSTRAP=1` [..]") .run(); // RUSTC_BOOTSTRAP conditionally set when there's no library should error (regardless of the value) p.cargo("check") diff --git a/tests/testsuite/build_script_extra_link_arg.rs b/tests/testsuite/build_script_extra_link_arg.rs index 363a01c8c536..7754df8f65ab 100644 --- a/tests/testsuite/build_script_extra_link_arg.rs +++ b/tests/testsuite/build_script_extra_link_arg.rs @@ -204,7 +204,7 @@ fn cdylib_link_arg_transitive() { [COMPILING] bar v1.0.0 [..] [RUNNING] `rustc --crate-name build_script_build bar/build.rs [..] [RUNNING] `[..]build-script-build[..] -warning: [bar 1.0.0] cargo:rustc-link-arg-cdylib was specified in the build script of bar v1.0.0 \ +warning: bar@1.0.0 cargo:rustc-link-arg-cdylib was specified in the build script of bar v1.0.0 \ ([ROOT]/foo/bar), but that package does not contain a cdylib target Allowing this was an unintended change in the 1.50 release, and may become an error in \ diff --git a/tests/testsuite/features2.rs b/tests/testsuite/features2.rs index f70fccdd04b1..37ed72ca46ac 100644 --- a/tests/testsuite/features2.rs +++ b/tests/testsuite/features2.rs @@ -1807,7 +1807,7 @@ fn shared_dep_same_but_dependencies() { [COMPILING] dep [..] [COMPILING] bin2 [..] [COMPILING] bin1 [..] -warning: [bin2 0.1.0] feat: enabled +warning: bin2@0.1.0 feat: enabled [FINISHED] [..] ", ) @@ -1823,7 +1823,7 @@ warning: [bin2 0.1.0] feat: enabled [FRESH] subdep [..] [FRESH] dep [..] [FRESH] bin1 [..] -warning: [bin2 0.1.0] feat: enabled +warning: bin2@0.1.0 feat: enabled [FRESH] bin2 [..] [FINISHED] [..] ", diff --git a/tests/testsuite/warn_on_failure.rs b/tests/testsuite/warn_on_failure.rs index 80ef8aa8d575..9899e1f4df65 100644 --- a/tests/testsuite/warn_on_failure.rs +++ b/tests/testsuite/warn_on_failure.rs @@ -105,7 +105,7 @@ fn warning_on_lib_failure() { .with_stderr_contains("[UPDATING] `[..]` index") .with_stderr_contains("[DOWNLOADED] bar v0.0.1 ([..])") .with_stderr_contains("[COMPILING] bar v0.0.1") - .with_stderr_contains(&format!("[WARNING] [bar 0.0.1] {}", WARNING1)) - .with_stderr_contains(&format!("[WARNING] [bar 0.0.1] {}", WARNING2)) + .with_stderr_contains(&format!("[WARNING] bar@0.0.1 {}", WARNING1)) + .with_stderr_contains(&format!("[WARNING] bar@0.0.1 {}", WARNING2)) .run(); }