-
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
Migrate from the failure
crate to anyhow
#7776
Conversation
The `anyhow` crate interoperates with the `std::error::Error` trait rather than a custom `Fail` trait, and this is the general trend of error handling in Rust as well. Note that this is mostly mechanical (sed) and intended to get the test suite passing. As usual there's still more idiomatic cleanup that can happen, but that's left to later commits.
r? @Eh2406 (rust_highfive has picked a reviewer for you, use r? to override) |
r? @ehuss |
Nice! I think the only concern I had was the weird numeric error in @bors r+ |
📌 Commit d0430dd has been approved by |
Migrate from the `failure` crate to `anyhow` The `anyhow` crate interoperates with the `std::error::Error` trait rather than a custom `Fail` trait, and this is the general trend of error handling in Rust as well. Note that this is mostly mechanical (sed) and intended to get the test suite passing. As usual there's still more idiomatic cleanup that can happen, but that's left to later commits.
Ah yeah so to clarify that's due to the changes here where I wanted to remove |
☀️ Test successful - checks-azure |
Update cargo rls ## cargo 12 commits in 6e1ca924a67dd1ac89c33f294ef26b5c43b89168..ad3dbe10e1e654fb1f032a5dd9481d7cbaa00d65 2020-01-06 19:11:37 +0000 to 2020-01-13 21:37:15 +0000 - Add named config profiles. (rust-lang/cargo#7750) - Make cargo-rustc crate-type-aware (rust-lang/cargo#7755) - Rename `Kind` (rust-lang/cargo#7791) - Update bash completion (rust-lang/cargo#7789) - Add another curl spurious network error (rust-lang/cargo#7788) - Some small tweaks around error in configuration (rust-lang/cargo#7783) - Fix tests with `url` crate update (rust-lang/cargo#7787) - Fix .gitignore of Cargo.lock in a subdirectory. (rust-lang/cargo#7779) - Bump crates-io (rust-lang/cargo#7778) - Migrate from the `failure` crate to `anyhow` (rust-lang/cargo#7776) - Fix several needless_borrow clippy lints. (rust-lang/cargo#7771) - Fix some links (rust-lang/cargo#7770) ## rls 2 commits in 7c0489c5ff4f5c594e65a3b22efd9ce373deab9b..b27e1173969639448cd2e486b1c5f0fcb1b3b17c 2020-01-04 20:15:37 +0100 to 2020-01-13 11:40:20 +0100 - Update Cargo (rust-lang/rls#1613) - Rustup to #68024 (rust-lang/rls#1612)
Update cargo rls ## cargo 12 commits in 6e1ca924a67dd1ac89c33f294ef26b5c43b89168..ad3dbe10e1e654fb1f032a5dd9481d7cbaa00d65 2020-01-06 19:11:37 +0000 to 2020-01-13 21:37:15 +0000 - Add named config profiles. (rust-lang/cargo#7750) - Make cargo-rustc crate-type-aware (rust-lang/cargo#7755) - Rename `Kind` (rust-lang/cargo#7791) - Update bash completion (rust-lang/cargo#7789) - Add another curl spurious network error (rust-lang/cargo#7788) - Some small tweaks around error in configuration (rust-lang/cargo#7783) - Fix tests with `url` crate update (rust-lang/cargo#7787) - Fix .gitignore of Cargo.lock in a subdirectory. (rust-lang/cargo#7779) - Bump crates-io (rust-lang/cargo#7778) - Migrate from the `failure` crate to `anyhow` (rust-lang/cargo#7776) - Fix several needless_borrow clippy lints. (rust-lang/cargo#7771) - Fix some links (rust-lang/cargo#7770) ## rls 2 commits in 7c0489c5ff4f5c594e65a3b22efd9ce373deab9b..b27e1173969639448cd2e486b1c5f0fcb1b3b17c 2020-01-04 20:15:37 +0100 to 2020-01-13 11:40:20 +0100 - Update Cargo (rust-lang/rls#1613) - Rustup to #68024 (rust-lang/rls#1612)
This matches the upstream convention used by Cargo with its `CargoResult` type aliasing `failure::Error`. In later versions of Cargo, `failure` has been replaced by `anyhow` (rust-lang/cargo#7776), but this should suffice for the time being while we still depend on this Cargo version. The pattern of `try_main()` seen here is a common pattern seen in other CLI tools such as `ripgrep`. Having `main()` return a `Result` isn't useful here because it only shows the `Debug` output and not `Display`, which typically results in a very poor experince for the end-user.
The
anyhow
crate interoperates with thestd::error::Error
traitrather than a custom
Fail
trait, and this is the general trend oferror handling in Rust as well.
Note that this is mostly mechanical (sed) and intended to get the test
suite passing. As usual there's still more idiomatic cleanup that can
happen, but that's left to later commits.