-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
refactor: use custom error instead of anyhow #13050
Conversation
r? @ehuss (rustbot has picked a reviewer for you, use r? to override) |
Can I ask why do we need to switch to using custom errors? Do we need it for use in other repos to check the error type? |
If we are on the way to make cargo crates more user-friendly, a better error management could be a good route to go. Otherwise people might need downcasting things to get the root error cause. Some more contexts: |
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.
I am not particularly sure about the SemVer compatibility. Some functions' return type has changed from Result<, anyhow::Error> to Result<, rustfix::Error>. People already consume anyhow::Error should be able to use rustfix::Error without updating their code I think.
Only if they are always using ?
/ map_err(Into::into)
which might not always be the case
- Someone making a call to rustfix in a trailing statement of a function
- Someone capturing a function pointer
We should likely go ahead and treat this as a breaking change.
I'm unsure how you might want to proceed, so I'm only approving and not merging, whether
- you want to hold off for other breaking changes
- need to bump the version in the manifest
- something else
c5bbef9
to
21274da
Compare
Just did a bump to
I don't want to hold off the bump, but yes I plan to make some items private as there is no reason for them to be public. BTW, it seems that this kind of breaking change is not covered in Cargo book SemVer chapter, nor does cargo-semver-checks detect it. |
@bors r+ |
☀️ Test successful - checks-actions |
Update cargo 7 commits in 9b13310ca596020a737aaa47daa4ed9ff8898a2f..26333c732095d207aa05932ce863d850fb309386 2023-11-24 16:20:51 +0000 to 2023-11-28 20:07:39 +0000 - docs: link to the packages lint table from the related workspace table (rust-lang/cargo#13057) - Add more doc comments for gc changes. (rust-lang/cargo#13055) - docs: Provide pointers for MSRV (rust-lang/cargo#13056) - Fixed typo in SemVer Compatibility documentation page (rust-lang/cargo#13054) - refactor: use custom error instead of anyhow (rust-lang/cargo#13050) - review and remove ignored tests in rustfix (rust-lang/cargo#13047) - docs: add doc comments for rustfix (rust-lang/cargo#13048) r? ghost
Rollup merge of rust-lang#118425 - weihanglo:update-cargo, r=weihanglo Update cargo 7 commits in 9b13310ca596020a737aaa47daa4ed9ff8898a2f..26333c732095d207aa05932ce863d850fb309386 2023-11-24 16:20:51 +0000 to 2023-11-28 20:07:39 +0000 - docs: link to the packages lint table from the related workspace table (rust-lang/cargo#13057) - Add more doc comments for gc changes. (rust-lang/cargo#13055) - docs: Provide pointers for MSRV (rust-lang/cargo#13056) - Fixed typo in SemVer Compatibility documentation page (rust-lang/cargo#13054) - refactor: use custom error instead of anyhow (rust-lang/cargo#13050) - review and remove ignored tests in rustfix (rust-lang/cargo#13047) - docs: add doc comments for rustfix (rust-lang/cargo#13048) r? ghost
What does this PR try to resolve?
This defines custom error types for
rustfix
crate, instead ofanyhow
.How should we test and review this PR?
Some error messages were slightly tweaked but shouldn't affect the behavior.
I am not particularly sure about the SemVer compatibility. Some functions' return type has changed from
Result<_, anyhow::Error>
toResult<_, rustfix::Error>
. People already consumeanyhow::Error
should be able to userustfix::Error
without updating their code I think.