Skip to content

fix: Suggest similar looking feature names when feature is missing #15454

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

Merged
merged 6 commits into from
Apr 25, 2025

Conversation

epage
Copy link
Contributor

@epage epage commented Apr 25, 2025

What does this PR try to resolve?

I recently depended on a package with preserve-order rather than preserve_order and the error message didn't help me with the problem so I figure I'd fix that. I also found other improvements along the way

  • Suggest an alternative feature when a feature includes a missing feature
  • Suggest an alternative feature when a dependency includes a missing feature
  • Lower case error messages
  • Re-frame prescriptive information as help
  • Change plural "features" error messages to singular "feature" as they can only ever have one (knowing an the MissingFeature string only has one feature in it was important for doing a closest match on the feature).

How should we test and review this PR?

Additional information

@rustbot
Copy link
Collaborator

rustbot commented Apr 25, 2025

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-dependency-resolution Area: dependency resolution and the resolver S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 25, 2025
@@ -280,6 +280,7 @@ fn dependency_activates_typoed_feature() {
versions that meet the requirements `*` are: 0.0.1

package `foo` depends on `bar` with feature `bar` but `bar` does not have that feature.
package `bar` does have feature `baz`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the leading space intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other clauses have a context line like this with a single leading space.

Its weird. It seems like it should be one of 0, 2, or 4 spaces but I didn't feel like following up what the intent was.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you've tweaked the message already, do you also want to address that in the same PR?

We can also do it in a follow up. I am fine with either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging now to get the incremental improvement rather than blocking on figuring out what the intended indentation is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Eh2406 when back from vacation, if you'd be willing to look at these errors and let us know what you think would work well, I'd appreciate it.

Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My previous comment is just a nit. Feel free to merge this whenever you feel good :)

@@ -280,6 +280,7 @@ fn dependency_activates_typoed_feature() {
versions that meet the requirements `*` are: 0.0.1

package `foo` depends on `bar` with feature `bar` but `bar` does not have that feature.
package `bar` does have feature `baz`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you've tweaked the message already, do you also want to address that in the same PR?

We can also do it in a follow up. I am fine with either.

@epage epage added this pull request to the merge queue Apr 25, 2025
Merged via the queue into rust-lang:master with commit fb3906d Apr 25, 2025
23 checks passed
@epage epage deleted the feature branch April 25, 2025 20:18
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 27, 2025
Update cargo

10 commits in d811228b14ae2707323f37346aee3f4147e247e6..7918c7eb59614c39f1c4e27e99d557720976bdd7
2025-04-15 15:18:42 +0000 to 2025-04-27 09:44:23 +0000
- overriding-dependencies.md: better readability (rust-lang/cargo#15459)
- source-replacement.md: fix typo (rust-lang/cargo#15458)
- Stabilize automatic garbage collection. (rust-lang/cargo#14287)
- Update doctest xcompile flags (rust-lang/cargo#15455)
- fix: Suggest similar looking feature names when feature is missing (rust-lang/cargo#15454)
- fix(unit-graph): switch to Package ID Spec (rust-lang/cargo#15447)
- chore(deps): update cargo-semver-checks to v0.41.0 (rust-lang/cargo#15446)
- Implement RFC3695: Allow boolean literals as cfg predicates (rust-lang/cargo#14649)
- chore: remove duplicate word in comment (rust-lang/cargo#15437)
- Fix formatting of CliUnstable parsing (rust-lang/cargo#15434)

r? ghost
@rustbot rustbot added this to the 1.88.0 milestone Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dependency-resolution Area: dependency resolution and the resolver S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants