diff --git a/src/bin/cargo/commands/test.rs b/src/bin/cargo/commands/test.rs index 3c9e83a803b..fb87bf79bc7 100644 --- a/src/bin/cargo/commands/test.rs +++ b/src/bin/cargo/commands/test.rs @@ -89,11 +89,11 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult { if doc { if compile_opts.filter.is_specific() { return Err( - anyhow::format_err!("Can't mix --doc with other target selecting options").into(), + anyhow::format_err!("can't mix --doc with other target selecting options").into(), ); } if no_run { - return Err(anyhow::format_err!("Can't skip running doc tests with --no-run").into()); + return Err(anyhow::format_err!("can't skip running doc tests with --no-run").into()); } compile_opts.build_config.intent = UserIntent::Doctest; compile_opts.filter = ops::CompileFilter::lib_only(); diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs index f30875da2be..fbe1c013c06 100644 --- a/src/cargo/core/compiler/custom_build.rs +++ b/src/cargo/core/compiler/custom_build.rs @@ -1074,16 +1074,16 @@ impl BuildOutput { if nightly_features_allowed || rustc_bootstrap_allows(library_name.as_deref()) { - log_messages.push((Severity::Warning, format!("Cannot set `RUSTC_BOOTSTRAP={}` from {}.\n\ - note: Crates cannot set `RUSTC_BOOTSTRAP` themselves, as doing so would subvert the stability guarantees of Rust for your project.", + log_messages.push((Severity::Warning, format!("cannot set `RUSTC_BOOTSTRAP={}` from {}.\n\ + note: crates cannot set `RUSTC_BOOTSTRAP` themselves, as doing so would subvert the stability guarantees of Rust for your project.", val, whence ))); } else { // Setting RUSTC_BOOTSTRAP would change the behavior of the crate. // Abort with an error. bail!( - "Cannot set `RUSTC_BOOTSTRAP={}` from {}.\n\ - note: Crates cannot set `RUSTC_BOOTSTRAP` themselves, as doing so would subvert the stability guarantees of Rust for your project.\n\ + "cannot set `RUSTC_BOOTSTRAP={}` from {}.\n\ + note: crates cannot set `RUSTC_BOOTSTRAP` themselves, as doing so would subvert the stability guarantees of Rust for your project.\n\ help: If you're sure you want to do this in your project, set the environment variable `RUSTC_BOOTSTRAP={}` before running cargo instead.", val, whence, @@ -1147,7 +1147,7 @@ impl BuildOutput { value = match flags_iter.next() { Some(v) => v, None => bail! { - "Flag in rustc-flags has no value in {}: {}", + "flag in rustc-flags has no value in {}: {}", whence, value }, @@ -1163,7 +1163,7 @@ impl BuildOutput { }; } else { bail!( - "Only `-l` and `-L` flags are allowed in {}: `{}`", + "only `-l` and `-L` flags are allowed in {}: `{}`", whence, value ) diff --git a/src/cargo/core/package_id_spec.rs b/src/cargo/core/package_id_spec.rs index 3403bac8bfe..f730246b15b 100644 --- a/src/cargo/core/package_id_spec.rs +++ b/src/cargo/core/package_id_spec.rs @@ -112,14 +112,8 @@ impl PackageIdSpecQuery for PackageIdSpec { return match ids.next() { Some(other) => { let mut msg = format!( - "There are multiple `{}` packages in \ - your project, and the specification \ - `{}` is ambiguous.\n\ - Please re-run this command \ - with one of the following \ - specifications:", - self.name(), - self + "specificationm `{self}` is ambiguous +help: re-run this command with one of the following specifications", ); let mut vec = vec![ret, other]; vec.extend(ids); diff --git a/src/cargo/core/registry.rs b/src/cargo/core/registry.rs index 030b3e72ca7..99f1d857ac0 100644 --- a/src/cargo/core/registry.rs +++ b/src/cargo/core/registry.rs @@ -542,7 +542,7 @@ impl<'gctx> PackageRegistry<'gctx> { let source = self .source_config .load(source_id, &self.yanked_whitelist) - .with_context(|| format!("Unable to update {}", source_id))?; + .with_context(|| format!("unable to update {}", source_id))?; assert_eq!(source.source_id(), source_id); if kind == Kind::Override { @@ -812,7 +812,7 @@ impl<'gctx> Registry for PackageRegistry<'gctx> { for (source_id, source) in self.sources.sources_mut() { source .block_until_ready() - .with_context(|| format!("Unable to update {}", source_id))?; + .with_context(|| format!("unable to update {}", source_id))?; } Ok(()) } diff --git a/src/cargo/core/source_id.rs b/src/cargo/core/source_id.rs index 3db37d2184d..df958bf133d 100644 --- a/src/cargo/core/source_id.rs +++ b/src/cargo/core/source_id.rs @@ -405,7 +405,7 @@ impl SourceId { .to_file_path() .expect("path sources cannot be remote"); if crate::util::toml::is_embedded(&path) { - anyhow::bail!("Single file packages cannot be used as dependencies") + anyhow::bail!("single file packages cannot be used as dependencies") } Ok(Box::new(PathSource::new(&path, self, gctx))) } diff --git a/src/cargo/ops/cargo_install.rs b/src/cargo/ops/cargo_install.rs index 811f926e8c8..50aa7c8bfe3 100644 --- a/src/cargo/ops/cargo_install.rs +++ b/src/cargo/ops/cargo_install.rs @@ -73,9 +73,9 @@ impl<'gctx> InstallablePackage<'gctx> { if let Some(name) = krate { if name == "." { bail!( - "To install the binaries for the package in current working \ + "to install the binaries for the package in current working \ directory use `cargo install --path .`. \n\ - Use `cargo build` if you want to simply build the package." + use `cargo build` if you want to simply build the package." ) } } @@ -228,17 +228,17 @@ impl<'gctx> InstallablePackage<'gctx> { if from_cwd { if pkg.manifest().edition() == Edition::Edition2015 { gctx.shell().warn( - "Using `cargo install` to install the binaries from the \ + "using `cargo install` to install the binaries from the \ package in current working directory is deprecated, \ use `cargo install --path .` instead. \ - Use `cargo build` if you want to simply build the package.", + note: use `cargo build` if you want to simply build the package.", )? } else { bail!( - "Using `cargo install` to install the binaries from the \ + "using `cargo install` to install the binaries from the \ package in current working directory is no longer supported, \ use `cargo install --path .` instead. \ - Use `cargo build` if you want to simply build the package." + note: use `cargo build` if you want to simply build the package." ) } }; diff --git a/src/cargo/ops/cargo_new.rs b/src/cargo/ops/cargo_new.rs index efe49539224..38f8323bbe6 100644 --- a/src/cargo/ops/cargo_new.rs +++ b/src/cargo/ops/cargo_new.rs @@ -481,7 +481,7 @@ pub fn new(opts: &NewOptions, gctx: &GlobalContext) -> CargoResult<()> { mk(gctx, &mkopts).with_context(|| { format!( - "Failed to create package `{}` at `{}`", + "failed to create package `{}` at `{}`", name, path.display() ) @@ -593,7 +593,7 @@ pub fn init(opts: &NewOptions, gctx: &GlobalContext) -> CargoResult { if find_project_manifest_exact(path, "cargo.toml").is_ok() { Err(anyhow::format_err!( - "Could not find Cargo.toml in `{}`, but found cargo.toml please try to rename it to Cargo.toml", + "could not find `Cargo.toml` in `{}` +help: found `cargo.toml`, consider renaming it to `Cargo.toml`", path.display() )) } else { Err(anyhow::format_err!( - "Could not find Cargo.toml in `{}`", + "could not find `Cargo.toml` in `{}`", path.display() )) } diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 45269b8a9c8..9efa5c73fd4 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -616,7 +616,7 @@ pub trait ArgMatchesExt { Some(arg) => Some(arg.parse::().map_err(|_| { clap::Error::raw( clap::error::ErrorKind::ValueValidation, - format!("Invalid value: could not parse `{}` as a number", arg), + format!("invalid value: could not parse `{}` as a number", arg), ) })?), }; @@ -629,7 +629,7 @@ pub trait ArgMatchesExt { Some(arg) => Some(arg.parse::().map_err(|_| { clap::Error::raw( clap::error::ErrorKind::ValueValidation, - format!("Invalid value: could not parse `{}` as a number", arg), + format!("invalid value: could not parse `{}` as a number", arg), ) })?), }; @@ -917,7 +917,7 @@ Run `{cmd}` to see possible targets." let mut compile_opts = self.compile_options(gctx, intent, workspace, profile_checking)?; let spec = self._values_of("package"); if spec.iter().any(restricted_names::is_glob_pattern) { - anyhow::bail!("Glob patterns on package selection are not supported.") + anyhow::bail!("glob patterns on package selection are not supported.") } compile_opts.spec = Packages::Packages(spec); Ok(compile_opts) diff --git a/tests/testsuite/bad_config.rs b/tests/testsuite/bad_config.rs index 81d7312871c..8f76dad3f4d 100644 --- a/tests/testsuite/bad_config.rs +++ b/tests/testsuite/bad_config.rs @@ -189,7 +189,7 @@ fn bad4() { .with_status(101) .with_stderr_data(str![[r#" [CREATING] binary (application) `foo` package -[ERROR] Failed to create package `foo` at `[ROOT]/foo/foo` +[ERROR] failed to create package `foo` at `[ROOT]/foo/foo` Caused by: error in [ROOT]/foo/.cargo/config.toml: `cargo-new.vcs` expected a string, but found a boolean @@ -455,7 +455,7 @@ Caused by: failed to load source for dependency `foo` Caused by: - Unable to update git://host.xz + unable to update git://host.xz Caused by: failed to clone into: [ROOT]/home/.cargo/git/db/_empty-[HASH] @@ -476,7 +476,7 @@ Caused by: failed to load source for dependency `foo` Caused by: - Unable to update file:/// + unable to update file:/// Caused by: failed to clone into: [ROOT]/home/.cargo/git/db/_empty-[HASH] @@ -2338,7 +2338,7 @@ Caused by: failed to load source for dependency `bar` Caused by: - Unable to update https://github.com/rust-lang/does-not-exist/pull/123 + unable to update https://github.com/rust-lang/does-not-exist/pull/123 ... [NOTE] GitHub url https://github.com/rust-lang/does-not-exist/pull/123 is not a repository. [HELP] Replace the dependency with @@ -2383,7 +2383,7 @@ Caused by: failed to load source for dependency `bar` Caused by: - Unable to update http://127.0.0.1/#foo + unable to update http://127.0.0.1/#foo Caused by: failed to clone into: [ROOT]/home/.cargo/git/db/_empty-[HASH] @@ -2445,7 +2445,7 @@ Caused by: failed to load source for dependency `bar` Caused by: - Unable to update registry `crates-io` + unable to update registry `crates-io` Caused by: could not find a configured source with the name `bar` when attempting to lookup `crates-io` (configuration in `[ROOT]/foo/.cargo/config.toml`) @@ -2490,7 +2490,7 @@ Caused by: failed to load source for dependency `bar` Caused by: - Unable to update registry `crates-io` + unable to update registry `crates-io` Caused by: detected a cycle of `replace-with` sources, the source `crates-io` is eventually replaced with itself (configuration in `[ROOT]/foo/.cargo/config.toml`) @@ -2538,7 +2538,7 @@ Caused by: failed to load source for dependency `bar` Caused by: - Unable to update registry `crates-io` + unable to update registry `crates-io` Caused by: detected a cycle of `replace-with` sources, the source `crates-io` is eventually replaced with itself (configuration in `[ROOT]/foo/.cargo/config.toml`) @@ -3147,10 +3147,10 @@ fn bad_target_links_overrides() { p.cargo("check") .with_status(101) - .with_stderr_data(str![[r" -[ERROR] Only `-l` and `-L` flags are allowed in target config `target.[..].rustc-flags` (in [..]foo/.cargo/config.toml): `foo` + .with_stderr_data(str![[r#" +[ERROR] only `-l` and `-L` flags are allowed in target config `target.[HOST_TARGET].rustc-flags` (in [ROOT]/foo/.cargo/config.toml): `foo` -"]]) +"#]]) .run(); p.change_file( diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs index a30dc57775a..9a519ece6e2 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -989,7 +989,7 @@ fn custom_build_script_wrong_rustc_flags() { .with_status(101) .with_stderr_data(str![[r#" [COMPILING] foo v0.5.0 ([ROOT]/foo) -[ERROR] Only `-l` and `-L` flags are allowed in build script of `foo v0.5.0 ([ROOT]/foo)`: `-aaa -bbb` +[ERROR] only `-l` and `-L` flags are allowed in build script of `foo v0.5.0 ([ROOT]/foo)`: `-aaa -bbb` "#]]) .run(); diff --git a/tests/testsuite/build_script_env.rs b/tests/testsuite/build_script_env.rs index 442d7ad3d3c..6daf9a4dc47 100644 --- a/tests/testsuite/build_script_env.rs +++ b/tests/testsuite/build_script_env.rs @@ -129,8 +129,8 @@ fn rustc_bootstrap() { p.cargo("check") .with_stderr_data(str![[r#" [COMPILING] has-dashes v0.0.1 ([ROOT]/foo) -[ERROR] 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. +[ERROR] 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. [HELP] If you're sure you want to do this in your project, set the environment variable `RUSTC_BOOTSTRAP=has_dashes` before running cargo instead. "#]]) @@ -144,8 +144,8 @@ fn rustc_bootstrap() { .env("RUSTC_BOOTSTRAP", "1") .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. +[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. [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s "#]]) @@ -154,8 +154,8 @@ fn rustc_bootstrap() { p.cargo("check") .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. +[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. [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s "#]]) @@ -164,8 +164,8 @@ fn rustc_bootstrap() { p.cargo("check") .env("RUSTC_BOOTSTRAP", "bar") .with_stderr_data(str![[r#" -[ERROR] 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. +[ERROR] 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. [HELP] If you're sure you want to do this in your project, set the environment variable `RUSTC_BOOTSTRAP=has_dashes` before running cargo instead. "#]]) @@ -189,8 +189,8 @@ fn rustc_bootstrap() { .env("RUSTC_BOOTSTRAP", "1") .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. +[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. [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s "#]]) @@ -199,8 +199,8 @@ fn rustc_bootstrap() { p.cargo("check") .env("RUSTC_BOOTSTRAP", "foo") .with_stderr_data(str![[r#" -[ERROR] 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. +[ERROR] 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. [HELP] If you're sure you want to do this in your project, set the environment variable `RUSTC_BOOTSTRAP=1` before running cargo instead. "#]]) diff --git a/tests/testsuite/cargo_add/invalid_path/stderr.term.svg b/tests/testsuite/cargo_add/invalid_path/stderr.term.svg index 7a97e8811b9..203ba67dc93 100644 --- a/tests/testsuite/cargo_add/invalid_path/stderr.term.svg +++ b/tests/testsuite/cargo_add/invalid_path/stderr.term.svg @@ -1,7 +1,7 @@ - +