Skip to content

WIP: Eliminate the last three "did you mean" warning phrasings #15356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cargo/ops/cargo_compile/mod.rs
Original file line number Diff line number Diff line change
@@ -234,14 +234,14 @@ pub fn create_bcx<'a, 'gctx>(
| CompileMode::RunCustomBuild => {
if ws.gctx().get_env("RUST_FLAGS").is_ok() {
gctx.shell().warn(
"Cargo does not read `RUST_FLAGS` environment variable. Did you mean `RUSTFLAGS`?",
"Ignoring incorrect environment variable `RUST_FLAGS`; Rust flags are passed via `RUSTFLAGS`.",
)?;
}
}
CompileMode::Doc { .. } | CompileMode::Doctest | CompileMode::Docscrape => {
if ws.gctx().get_env("RUSTDOC_FLAGS").is_ok() {
gctx.shell().warn(
"Cargo does not read `RUSTDOC_FLAGS` environment variable. Did you mean `RUSTDOCFLAGS`?"
"Ignoring incorrect environment variable `RUSTDOC_FLAGS`; Rust flags are passed via `RUSTDOCFLAGS`."
)?;
}
}
4 changes: 2 additions & 2 deletions src/cargo/sources/registry/mod.rs
Original file line number Diff line number Diff line change
@@ -863,8 +863,8 @@ impl<'gctx> Source for RegistrySource<'gctx> {
// Attempt to handle misspellings by searching for a chain of related
// names to the original name. The resolver will later
// reject any candidates that have the wrong name, and with this it'll
// along the way produce helpful "did you mean?" suggestions.
// For now we only try the canonical lysing `-` to `_` and vice versa.
// have enough information to offer "a similar crate exists" suggestions.
// For now we only try canonicalizing `-` to `_` and vice versa.
// More advanced fuzzy searching become in the future.
for name_permutation in [
dep.package_name().replace('-', "_"),
4 changes: 2 additions & 2 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
@@ -1701,8 +1701,8 @@ pub fn to_real_manifest(

if summary.features().contains_key("default-features") {
warnings.push(
"`default-features = [\"..\"]` was found in [features]. \
Did you mean to use `default = [\"..\"]`?"
"`[features]` defines a feature named `default-features`. \
Note that only a feature named `default` will be enabled by default."
.to_string(),
)
}
2 changes: 1 addition & 1 deletion tests/testsuite/features.rs
Original file line number Diff line number Diff line change
@@ -1766,7 +1766,7 @@ fn warn_if_default_features() {
.build();

p.cargo("check").with_stderr_data(str![[r#"
[WARNING] `default-features = [".."]` was found in [features]. Did you mean to use `default = [".."]`?
[WARNING] `[features]` defines a feature named `default-features`. Note that only a feature named `default` will be enabled by default.
[LOCKING] 1 package to latest compatible version
[CHECKING] foo v0.0.1 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
2 changes: 1 addition & 1 deletion tests/testsuite/rustdocflags.rs
Original file line number Diff line number Diff line change
@@ -115,7 +115,7 @@ fn rustdocflags_misspelled() {
p.cargo("doc")
.env("RUSTDOC_FLAGS", "foo")
.with_stderr_data(str![[r#"
[WARNING] Cargo does not read `RUSTDOC_FLAGS` environment variable. Did you mean `RUSTDOCFLAGS`?
[WARNING] Ignoring incorrect environment variable `RUSTDOC_FLAGS`; Rust flags are passed via `RUSTDOCFLAGS`.
...
"#]])
.run();
2 changes: 1 addition & 1 deletion tests/testsuite/rustflags.rs
Original file line number Diff line number Diff line change
@@ -1471,7 +1471,7 @@ fn env_rustflags_misspelled_build_script() {
p.cargo("check")
.env("RUST_FLAGS", "foo")
.with_stderr_data(str![[r#"
[WARNING] Cargo does not read `RUST_FLAGS` environment variable. Did you mean `RUSTFLAGS`?
[WARNING] Ignoring incorrect environment variable `RUST_FLAGS`; Rust flags are passed via `RUSTFLAGS`.
[COMPILING] foo v0.0.1 ([ROOT]/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s