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

Commit

Permalink
chore: Upgrade cargo
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
epage committed Jan 26, 2022
1 parent 01c9ce1 commit 506fa43
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 13 deletions.
49 changes: 41 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ rls-vfs = "0.8"
rls-ipc = { version = "0.1.0", path = "rls-ipc", optional = true }

anyhow = "1.0.26"
cargo = { git = "https://github.com/rust-lang/cargo", rev = "06b9d31743210b788b130c8a484c2838afa6fc27" }
cargo-util = { git = "https://github.com/rust-lang/cargo", rev = "06b9d31743210b788b130c8a484c2838afa6fc27" }
cargo = { git = "https://github.com/rust-lang/cargo", rev = "1c034752de0df744fcd7788fcbca158830b8bf85" }
cargo-util = { git = "https://github.com/rust-lang/cargo", rev = "1c034752de0df744fcd7788fcbca158830b8bf85" }
cargo_metadata = "0.14"
clippy_lints = { git = "https://github.com/rust-lang/rust-clippy", version = "0.1.60", optional = true }
env_logger = "0.9"
Expand All @@ -58,6 +58,7 @@ regex = "1"
ordslice = "0.3"
crossbeam-channel = "0.5"
toml = "0.5"
toml_edit = { version = "0.13.1", features = ["easy"] }
heck = "0.3"

# A noop dependency that changes in the Rust repository, it's a bit of a hack.
Expand Down
11 changes: 8 additions & 3 deletions rls/src/build/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,9 +828,14 @@ impl ManifestAwareError {
fn find_toml_error(
err: &(dyn std::error::Error + 'static),
) -> Option<(usize, usize)> {
match err.downcast_ref::<toml::de::Error>() {
Some(toml_err) => toml_err.line_col(),
None => find_toml_error(err.source()?),
if let Some(toml_err) = err.downcast_ref::<toml_edit::TomlError>() {
toml_err.line_col()
} else if let Some(toml_err) = err.downcast_ref::<toml_edit::de::Error>() {
toml_err.line_col()
} else if let Some(toml_err) = err.downcast_ref::<toml::de::Error>() {
toml_err.line_col()
} else {
find_toml_error(err.source()?)
}
}
if let Some((line, col)) = find_toml_error(last_cause) {
Expand Down

0 comments on commit 506fa43

Please sign in to comment.