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

Commit 3df7438

Browse files
authored
Merge pull request #1764 from epage/cargo
chore: Upgrade cargo
2 parents e9bdaba + f28d452 commit 3df7438

File tree

3 files changed

+63
-19
lines changed

3 files changed

+63
-19
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: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub(super) fn cargo(
8484

8585
let (manifest_path, manifest_error_range) = {
8686
let mae = error.downcast_ref::<ManifestAwareError>();
87-
(mae.map(|e| e.manifest_path().clone()), mae.map(|e| e.manifest_error_range()))
87+
(mae.map(|e| e.manifest_path().clone()), mae.and_then(|e| e.manifest_error_range()))
8888
};
8989
BuildResult::CargoError { error, stdout, manifest_path, manifest_error_range }
9090
}
@@ -805,15 +805,15 @@ pub struct ManifestAwareError {
805805
cause: anyhow::Error,
806806
/// The path to a manifest file within the project that seems the closest to the error's origin.
807807
nearest_project_manifest: PathBuf,
808-
manifest_error_range: Range,
808+
manifest_error_range: Option<Range>,
809809
}
810810

811811
impl ManifestAwareError {
812812
fn new(cause: anyhow::Error, root_manifest: &Path, ws: Option<&Workspace<'_>>) -> Self {
813813
let project_dir = root_manifest.parent().unwrap();
814814
let mut err_path = root_manifest;
815815
// Cover whole manifest if we haven't any better idea.
816-
let mut err_range = Range { start: Position::new(0, 0), end: Position::new(9999, 0) };
816+
let mut err_range = None;
817817

818818
if let Some(manifest_err) = cause.downcast_ref::<ManifestError>() {
819819
// Scan through any manifest errors to pin the error more precisely.
@@ -828,15 +828,25 @@ 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) {
842+
let line = line as _;
843+
let start_col = col as _;
844+
let end_col = start_col + 1;
837845
// Use TOML deserializiation error position.
838-
err_range.start = Position::new(line as _, col as _);
839-
err_range.end = Position::new(line as _, col as u64 + 1);
846+
err_range = Some(Range {
847+
start: Position::new(line, start_col),
848+
end: Position::new(line, end_col),
849+
});
840850
}
841851
} else {
842852
let nearest_cause = manifest_err
@@ -868,7 +878,7 @@ impl ManifestAwareError {
868878
&self.nearest_project_manifest
869879
}
870880

871-
pub fn manifest_error_range(&self) -> Range {
881+
pub fn manifest_error_range(&self) -> Option<Range> {
872882
self.manifest_error_range
873883
}
874884
}

0 commit comments

Comments
 (0)