-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(patch): clean up patch-related error messages #16498
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
base: master
Are you sure you want to change the base?
fix(patch): clean up patch-related error messages #16498
Conversation
…le resolved candidates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pull request. Looks really nice!
I was thinking about (and tried) moving this portion of error messages directly to the annotate snippets #15944, but with several functions returning Result it was not straightforward. Probably needs well-thought refactoring, which is out of scope of this PR.
Yeah that one definitely need more legwork :)
| Caused by: | ||
| The patch location `[ROOT]/foo/bar` contains a `bar` package with version `0.1.0`, but the patch definition in `[ROOT]/foo/Cargo.toml` requires `^0.1.1`. | ||
| Check that the version in the patch location is what you expect, and update the patch definition to match. | ||
| [ERROR] patch `bar` version mismatch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clean-up!
Some minor nits:
- First letter should be lowercase.
- We could have
noteandhelplevels here maybe, such as
error: patch `bar` version mismatch
note: patch location contains version `0.1.0`, but patch definition requires `^0.1.1`
help: check patch location `[ROOT]/foo/bar`
help: check `bar` patch definition for `https://github.com/rust-lang/crates.io-index`
| vers.sort(); | ||
| let versions: Vec<_> = vers.into_iter().map(|v| v.to_string()).collect(); | ||
| return Poll::Ready(Err(anyhow::anyhow!( | ||
| "patch for `{}` in `{}` resolved to more than one candidate\n\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to quite the second one (source)
| [ERROR] patch for `bar` in `registry `alternative`` resolved to more than one candidate | ||
| Found versions: 0.1.0, 0.1.1 | ||
| Check `bar` patch definition for `https://github.com/rust-lang/crates.io-index` in `[ROOT]/foo/Cargo.toml` | ||
| For example, select only one package using `version = "=0.1.1"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- we don't need to quote "registry
alternative" maybe?
What about this?
error: patch for `bar` in registry `alternative` resolved to more than one candidate
note: found versions: 0.1.0, 0.1.1
help: check `bar` patch definition for `https://github.com/rust-lang/crates.io-index` in `[ROOT]/foo/Cargo.toml`
help: select only one package, for example with `version = "=0.1.1"`
What does this PR try to resolve?
This is a follow-up for #16407.
This PR is supposed to make patch-related error messages closer to the desired style, remove unnecessary(?) context wrappings, and fix a few minor issues in code.
I tried to restructure some of the error messages to include the values from
.context()where I thought it would make sense. Obvious duplications (e.g. repository url of the patch) were removed.I tried to rephrase some of the error messages to sound closer to the desired style and to ease future migration to rustc's error reporter.
How to test and review this PR?
Test changes should demonstrate the intended behavior change.
Suggestions on how to make messages even better are obviously welcome.
Note
I was thinking about (and tried) moving this portion of error messages directly to the annotate snippets #15944, but with several functions returning
Resultit was not straightforward. Probably needs well-thought refactoring, which is out of scope of this PR.r? @weihanglo