diff --git a/src/cargo/core/shell.rs b/src/cargo/core/shell.rs index 6a5077dd1b5..b23bc337e17 100644 --- a/src/cargo/core/shell.rs +++ b/src/cargo/core/shell.rs @@ -222,7 +222,10 @@ impl Shell { /// Prints an amber 'warning' message. pub fn warn(&mut self, message: T) -> CargoResult<()> { - self.print(&"warning", Some(&message), &WARN, false) + let report = &[annotate_snippets::Group::with_title( + annotate_snippets::Level::WARNING.secondary_title(message.to_string()), + )]; + self.print_report(report, false) } /// Prints a cyan 'note' message. diff --git a/tests/testsuite/alt_registry.rs b/tests/testsuite/alt_registry.rs index dd8f0d03f05..dd2e19d3e18 100644 --- a/tests/testsuite/alt_registry.rs +++ b/tests/testsuite/alt_registry.rs @@ -351,7 +351,7 @@ fn publish_with_registry_dependency() { .with_stderr_data(str![[r#" [UPDATING] `alternative` index [WARNING] manifest has no description, license, license-file, documentation, homepage or repository. -See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. + See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. [PACKAGING] foo v0.0.1 ([ROOT]/foo) [UPDATING] `alternative` index [PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) @@ -518,7 +518,7 @@ fn publish_to_alt_registry() { .with_stderr_data(str![[r#" [UPDATING] `alternative` index [WARNING] manifest has no description, license, license-file, documentation, homepage or repository. -See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. + See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. [PACKAGING] foo v0.0.1 ([ROOT]/foo) [PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) [VERIFYING] foo v0.0.1 ([ROOT]/foo) @@ -596,7 +596,7 @@ fn publish_with_crates_io_dep() { .with_stderr_data(str![[r#" [UPDATING] `alternative` index [WARNING] manifest has no documentation, homepage or repository. -See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. + See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. [PACKAGING] foo v0.0.1 ([ROOT]/foo) [UPDATING] `dummy-registry` index [PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) diff --git a/tests/testsuite/bad_config.rs b/tests/testsuite/bad_config.rs index d8eec977ad0..6d20f12e66f 100644 --- a/tests/testsuite/bad_config.rs +++ b/tests/testsuite/bad_config.rs @@ -839,7 +839,7 @@ fn dev_dependencies2() { .build(); p.cargo("check").with_stderr_data(str![[r#" [WARNING] `dev_dependencies` is deprecated in favor of `dev-dependencies` and will not work in the 2024 edition -(in the `foo` package) + (in the `foo` package) [LOCKING] 1 package to latest compatible version [CHECKING] foo v0.1.0 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s @@ -954,7 +954,7 @@ fn build_dependencies2() { .build(); p.cargo("check").with_stderr_data(str![[r#" [WARNING] `build_dependencies` is deprecated in favor of `build-dependencies` and will not work in the 2024 edition -(in the `foo` package) + (in the `foo` package) [LOCKING] 1 package to latest compatible version [CHECKING] foo v0.1.0 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s @@ -1062,7 +1062,7 @@ fn lib_crate_type2() { p.cargo("check") .with_stderr_data(str![[r#" [WARNING] `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition -(in the `foo` library target) + (in the `foo` library target) [CHECKING] foo v0.5.0 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s @@ -1153,7 +1153,7 @@ fn bin_crate_type2() { p.cargo("check") .with_stderr_data(str![[r#" [WARNING] `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition -(in the `foo` binary target) + (in the `foo` binary target) [CHECKING] foo v0.5.0 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s @@ -1262,9 +1262,9 @@ fn examples_crate_type2() { p.cargo("check") .with_stderr_data(str![[r#" [WARNING] `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition -(in the `ex` example target) + (in the `ex` example target) [WARNING] `crate_type` is deprecated in favor of `crate-type` and will not work in the 2024 edition -(in the `goodbye` example target) + (in the `goodbye` example target) [CHECKING] foo v0.5.0 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s @@ -1401,7 +1401,7 @@ fn cargo_platform_build_dependencies2() { p.cargo("check") .with_stderr_data(str![[r#" [WARNING] `build_dependencies` is deprecated in favor of `build-dependencies` and will not work in the 2024 edition -(in the `[HOST_TARGET]` platform target) + (in the `[HOST_TARGET]` platform target) [LOCKING] 1 package to latest compatible version [COMPILING] build v0.5.0 ([ROOT]/foo/build) [COMPILING] foo v0.5.0 ([ROOT]/foo) @@ -1532,7 +1532,7 @@ fn cargo_platform_dev_dependencies2() { p.cargo("check") .with_stderr_data(str![[r#" [WARNING] `dev_dependencies` is deprecated in favor of `dev-dependencies` and will not work in the 2024 edition -(in the `[HOST_TARGET]` platform target) + (in the `[HOST_TARGET]` platform target) [LOCKING] 1 package to latest compatible version [CHECKING] foo v0.5.0 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s @@ -1661,7 +1661,7 @@ fn default_features2() { p.cargo("check").with_stderr_data(str![[r#" [WARNING] `default_features` is deprecated in favor of `default-features` and will not work in the 2024 edition -(in the `a` dependency) + (in the `a` dependency) [LOCKING] 1 package to latest compatible version [CHECKING] a v0.1.0 ([ROOT]/foo/a) [CHECKING] foo v0.1.0 ([ROOT]/foo) @@ -1836,7 +1836,7 @@ fn workspace_default_features2() { [CHECKING] workspace_only v0.1.0 ([ROOT]/foo/workspace_only) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s [WARNING] [ROOT]/foo/workspace_only/Cargo.toml: `default_features` is deprecated in favor of `default-features` and will not work in the 2024 edition -(in the `dep_workspace_only` dependency) + (in the `dep_workspace_only` dependency) "#]] .unordered(), @@ -1947,7 +1947,7 @@ fn lib_proc_macro2() { foo.cargo("check") .with_stderr_data(str![[r#" [WARNING] `proc_macro` is deprecated in favor of `proc-macro` and will not work in the 2024 edition -(in the `foo` library target) + (in the `foo` library target) [CHECKING] foo v0.1.0 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s @@ -2035,7 +2035,7 @@ fn bin_proc_macro2() { foo.cargo("check") .with_stderr_data(str![[r#" [WARNING] `proc_macro` is deprecated in favor of `proc-macro` and will not work in the 2024 edition -(in the `foo` binary target) + (in the `foo` binary target) [CHECKING] foo v0.5.0 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s @@ -3473,22 +3473,22 @@ fn legacy_binary_paths_warnings() { p.cargo("check -v") .with_stderr_data(str![[r#" [WARNING] An explicit [[bin]] section is specified in Cargo.toml which currently -disables Cargo from automatically inferring other binary targets. -This inference behavior will change in the Rust 2018 edition and the following -files will be included as a binary target: - -* src/main.rs - -This is likely to break cargo build or cargo test as these files may not be -ready to be compiled as a binary target today. You can future-proof yourself -and disable this warning by adding `autobins = false` to your [package] -section. You may also move the files to a location where Cargo would not -automatically infer them to be a target, such as in subfolders. - -For more information on this warning you can consult -https://github.com/rust-lang/cargo/issues/5330 + disables Cargo from automatically inferring other binary targets. + This inference behavior will change in the Rust 2018 edition and the following + files will be included as a binary target: + + * src/main.rs + + This is likely to break cargo build or cargo test as these files may not be + ready to be compiled as a binary target today. You can future-proof yourself + and disable this warning by adding `autobins = false` to your [package] + section. You may also move the files to a location where Cargo would not + automatically infer them to be a target, such as in subfolders. + + For more information on this warning you can consult + https://github.com/rust-lang/cargo/issues/5330 [WARNING] path `src/main.rs` was erroneously implicitly accepted for binary `bar`, -please set bin.path in Cargo.toml + please set bin.path in Cargo.toml [CHECKING] foo v1.0.0 ([ROOT]/foo) [RUNNING] `rustc [..]` [RUNNING] `rustc [..]` @@ -3518,22 +3518,22 @@ please set bin.path in Cargo.toml p.cargo("check -v") .with_stderr_data(str![[r#" [WARNING] An explicit [[bin]] section is specified in Cargo.toml which currently -disables Cargo from automatically inferring other binary targets. -This inference behavior will change in the Rust 2018 edition and the following -files will be included as a binary target: - -* src/bin/main.rs - -This is likely to break cargo build or cargo test as these files may not be -ready to be compiled as a binary target today. You can future-proof yourself -and disable this warning by adding `autobins = false` to your [package] -section. You may also move the files to a location where Cargo would not -automatically infer them to be a target, such as in subfolders. - -For more information on this warning you can consult -https://github.com/rust-lang/cargo/issues/5330 + disables Cargo from automatically inferring other binary targets. + This inference behavior will change in the Rust 2018 edition and the following + files will be included as a binary target: + + * src/bin/main.rs + + This is likely to break cargo build or cargo test as these files may not be + ready to be compiled as a binary target today. You can future-proof yourself + and disable this warning by adding `autobins = false` to your [package] + section. You may also move the files to a location where Cargo would not + automatically infer them to be a target, such as in subfolders. + + For more information on this warning you can consult + https://github.com/rust-lang/cargo/issues/5330 [WARNING] path `src/bin/main.rs` was erroneously implicitly accepted for binary `bar`, -please set bin.path in Cargo.toml + please set bin.path in Cargo.toml [CHECKING] foo v1.0.0 ([ROOT]/foo) [RUNNING] `rustc [..]` [RUNNING] `rustc [..]` @@ -3562,7 +3562,7 @@ please set bin.path in Cargo.toml p.cargo("check -v") .with_stderr_data(str![[r#" [WARNING] path `src/bar.rs` was erroneously implicitly accepted for binary `bar`, -please set bin.path in Cargo.toml + please set bin.path in Cargo.toml [CHECKING] foo v1.0.0 ([ROOT]/foo) [RUNNING] `rustc [..]` [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s diff --git a/tests/testsuite/bench.rs b/tests/testsuite/bench.rs index a11822a5e3c..a0c19f8a5fc 100644 --- a/tests/testsuite/bench.rs +++ b/tests/testsuite/bench.rs @@ -716,20 +716,20 @@ fn bench_autodiscover_2015() { p.cargo("bench bench_basic") .with_stderr_data(str![[r#" [WARNING] An explicit [[bench]] section is specified in Cargo.toml which currently -disables Cargo from automatically inferring other benchmark targets. -This inference behavior will change in the Rust 2018 edition and the following -files will be included as a benchmark target: - -* [..]bench_basic.rs - -This is likely to break cargo build or cargo test as these files may not be -ready to be compiled as a benchmark target today. You can future-proof yourself -and disable this warning by adding `autobenches = false` to your [package] -section. You may also move the files to a location where Cargo would not -automatically infer them to be a target, such as in subfolders. - -For more information on this warning you can consult -https://github.com/rust-lang/cargo/issues/5330 + disables Cargo from automatically inferring other benchmark targets. + This inference behavior will change in the Rust 2018 edition and the following + files will be included as a benchmark target: + + * benches/bench_basic.rs + + This is likely to break cargo build or cargo test as these files may not be + ready to be compiled as a benchmark target today. You can future-proof yourself + and disable this warning by adding `autobenches = false` to your [package] + section. You may also move the files to a location where Cargo would not + automatically infer them to be a target, such as in subfolders. + + For more information on this warning you can consult + https://github.com/rust-lang/cargo/issues/5330 [COMPILING] foo v0.0.1 ([ROOT]/foo) [FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s [RUNNING] [..] (target/release/deps/foo-[HASH][EXE]) @@ -1944,7 +1944,7 @@ fn legacy_bench_name() { p.cargo("bench") .with_stderr_data(str![[r#" [WARNING] path `src/bench.rs` was erroneously implicitly accepted for benchmark `bench`, -please set bench.path in Cargo.toml + please set bench.path in Cargo.toml [COMPILING] foo v0.1.0 ([ROOT]/foo) [FINISHED] `bench` profile [optimized] target(s) in [ELAPSED]s [RUNNING] unittests src/lib.rs (target/release/deps/foo-[HASH][EXE]) diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 68a3a037911..950bc2ff459 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -471,8 +471,8 @@ fn cargo_compile_duplicate_build_targets() { p.cargo("build") .with_stderr_data(str![[r#" [WARNING] file `[ROOT]/foo/src/main.rs` found to be present in multiple build targets: - * `lib` target `main` - * `bin` target `foo` + * `lib` target `main` + * `bin` target `foo` [COMPILING] foo v0.0.1 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s @@ -1992,7 +1992,7 @@ fn many_crate_types_old_style_lib_location() { p.cargo("build") .with_stderr_data(str![[r#" [WARNING] path `src/foo.rs` was erroneously implicitly accepted for library `foo`, -please rename the file to `src/lib.rs` or set lib.path in Cargo.toml + please rename the file to `src/lib.rs` or set lib.path in Cargo.toml [COMPILING] foo v0.5.0 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s diff --git a/tests/testsuite/build_script_env.rs b/tests/testsuite/build_script_env.rs index 15d3a671535..aee2c9d0d54 100644 --- a/tests/testsuite/build_script_env.rs +++ b/tests/testsuite/build_script_env.rs @@ -145,7 +145,7 @@ fn rustc_bootstrap() { .with_stderr_data(str![[r#" [COMPILING] has-dashes v0.0.1 ([ROOT]/foo) [WARNING] has-dashes@0.0.1: Cannot set `RUSTC_BOOTSTRAP=1` from build script of `has-dashes v0.0.1 ([ROOT]/foo)`. -[NOTE] Crates cannot set `RUSTC_BOOTSTRAP` themselves, as doing so would subvert the stability guarantees of Rust for your project. + [NOTE] Crates cannot set `RUSTC_BOOTSTRAP` themselves, as doing so would subvert the stability guarantees of Rust for your project. [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s "#]]) @@ -155,7 +155,7 @@ fn rustc_bootstrap() { .env("RUSTC_BOOTSTRAP", "has_dashes") .with_stderr_data(str![[r#" [WARNING] has-dashes@0.0.1: Cannot set `RUSTC_BOOTSTRAP=1` from build script of `has-dashes v0.0.1 ([ROOT]/foo)`. -[NOTE] Crates cannot set `RUSTC_BOOTSTRAP` themselves, as doing so would subvert the stability guarantees of Rust for your project. + [NOTE] Crates cannot set `RUSTC_BOOTSTRAP` themselves, as doing so would subvert the stability guarantees of Rust for your project. [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s "#]]) @@ -190,7 +190,7 @@ fn rustc_bootstrap() { .with_stderr_data(str![[r#" [COMPILING] foo v0.0.1 ([ROOT]/foo) [WARNING] foo@0.0.1: Cannot set `RUSTC_BOOTSTRAP=1` from build script of `foo v0.0.1 ([ROOT]/foo)`. -[NOTE] Crates cannot set `RUSTC_BOOTSTRAP` themselves, as doing so would subvert the stability guarantees of Rust for your project. + [NOTE] Crates cannot set `RUSTC_BOOTSTRAP` themselves, as doing so would subvert the stability guarantees of Rust for your project. [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s "#]]) diff --git a/tests/testsuite/cargo_alias_config.rs b/tests/testsuite/cargo_alias_config.rs index 044a5a28a9e..06346b17eb6 100644 --- a/tests/testsuite/cargo_alias_config.rs +++ b/tests/testsuite/cargo_alias_config.rs @@ -191,8 +191,8 @@ fn alias_shadowing_external_subcommand() { .env("PATH", &path) .with_stderr_data(str![[r#" [WARNING] user-defined alias `echo` is shadowing an external subcommand found at: `[ROOT]/cargo-echo/target/debug/cargo-echo[EXE]` -This was previously accepted but is being phased out; it will become a hard error in a future release. -For more information, see issue #10049 . + This was previously accepted but is being phased out; it will become a hard error in a future release. + For more information, see issue #10049 . [COMPILING] foo v0.5.0 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s @@ -226,8 +226,8 @@ fn default_args_alias() { .with_status(101) .with_stderr_data(str![[r#" [WARNING] user-defined alias `echo` is shadowing an external subcommand found at: `[ROOT]/cargo-echo/target/debug/cargo-echo[EXE]` -This was previously accepted but is being phased out; it will become a hard error in a future release. -For more information, see issue #10049 . + This was previously accepted but is being phased out; it will become a hard error in a future release. + For more information, see issue #10049 . [ERROR] alias echo has unresolvable recursive definition: echo -> echo "#]]) @@ -238,8 +238,8 @@ For more information, see issue #10049 . + This was previously accepted but is being phased out; it will become a hard error in a future release. + For more information, see issue #10049 . [ERROR] alias test-1 has unresolvable recursive definition: test-1 -> echo -> echo "#]]) diff --git a/tests/testsuite/cargo_features.rs b/tests/testsuite/cargo_features.rs index b5af3381ac7..f7c556b94fc 100644 --- a/tests/testsuite/cargo_features.rs +++ b/tests/testsuite/cargo_features.rs @@ -263,7 +263,7 @@ fn stable_feature_warns() { p.cargo("check") .with_stderr_data(str![[r#" [WARNING] the cargo feature `test-dummy-stable` has been stabilized in the 1.0 release and is no longer necessary to be listed in the manifest - See https://doc.rust-lang.org/cargo/ for more information about using this feature. + See https://doc.rust-lang.org/cargo/ for more information about using this feature. [CHECKING] a v0.0.1 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s @@ -699,7 +699,7 @@ fn publish_allowed() { .with_stderr_data(str![[r#" [UPDATING] crates.io index [WARNING] manifest has no description, license, license-file, documentation, homepage or repository. -See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. + See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. [PACKAGING] a v0.0.1 ([ROOT]/foo) [PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed) [VERIFYING] a v0.0.1 ([ROOT]/foo) @@ -752,8 +752,8 @@ fn z_stabilized() { .masquerade_as_nightly_cargo(&["always_nightly"]) .with_stderr_data(str![[r#" [WARNING] flag `-Z cache-messages` has been stabilized in the 1.40 release, and is no longer necessary - Message caching is now always enabled. - + Message caching is now always enabled. + [CHECKING] foo v0.0.1 ([ROOT]/foo) [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s diff --git a/tests/testsuite/cargo_init/path_contains_separator/stderr.term.svg b/tests/testsuite/cargo_init/path_contains_separator/stderr.term.svg index f197017d591..226b3f3daba 100644 --- a/tests/testsuite/cargo_init/path_contains_separator/stderr.term.svg +++ b/tests/testsuite/cargo_init/path_contains_separator/stderr.term.svg @@ -1,7 +1,7 @@