Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit f28d452

Browse files
committed
chore: Upgrade cargo
Cargo has switched exclusively to `toml_edit`, so when downcasting errors to get line and column, we need to downcast for those errors as well. This does not attempt to port rls to `toml_edit` and an analysis was not done to verify if the `find_toml_error` code path only needs to check for one toml library. The downside to this solution is its brittle. Any time cargo upgrades through a breaking `toml_edit` version, this test will break again and we'll have to upgrade rls to fix it.
1 parent b3a092d commit f28d452

File tree

3 files changed

+52
-13
lines changed

3 files changed

+52
-13
lines changed

Cargo.lock

Lines changed: 41 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ rls-vfs = "0.8"
3131
rls-ipc = { version = "0.1.0", path = "rls-ipc", optional = true }
3232

3333
anyhow = "1.0.26"
34-
cargo = { git = "https://github.com/rust-lang/cargo", rev = "06b9d31743210b788b130c8a484c2838afa6fc27" }
35-
cargo-util = { git = "https://github.com/rust-lang/cargo", rev = "06b9d31743210b788b130c8a484c2838afa6fc27" }
34+
cargo = { git = "https://github.com/rust-lang/cargo", rev = "1c034752de0df744fcd7788fcbca158830b8bf85" }
35+
cargo-util = { git = "https://github.com/rust-lang/cargo", rev = "1c034752de0df744fcd7788fcbca158830b8bf85" }
3636
cargo_metadata = "0.14"
3737
clippy_lints = { git = "https://github.com/rust-lang/rust-clippy", version = "0.1.60", optional = true }
3838
env_logger = "0.9"
@@ -58,6 +58,7 @@ regex = "1"
5858
ordslice = "0.3"
5959
crossbeam-channel = "0.5"
6060
toml = "0.5"
61+
toml_edit = { version = "0.13.1", features = ["easy"] }
6162
heck = "0.3"
6263

6364
# A noop dependency that changes in the Rust repository, it's a bit of a hack.

rls/src/build/cargo.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -828,9 +828,14 @@ impl ManifestAwareError {
828828
fn find_toml_error(
829829
err: &(dyn std::error::Error + 'static),
830830
) -> Option<(usize, usize)> {
831-
match err.downcast_ref::<toml::de::Error>() {
832-
Some(toml_err) => toml_err.line_col(),
833-
None => find_toml_error(err.source()?),
831+
if let Some(toml_err) = err.downcast_ref::<toml_edit::TomlError>() {
832+
toml_err.line_col()
833+
} else if let Some(toml_err) = err.downcast_ref::<toml_edit::de::Error>() {
834+
toml_err.line_col()
835+
} else if let Some(toml_err) = err.downcast_ref::<toml::de::Error>() {
836+
toml_err.line_col()
837+
} else {
838+
find_toml_error(err.source()?)
834839
}
835840
}
836841
if let Some((line, col)) = find_toml_error(last_cause) {

0 commit comments

Comments
 (0)