rust-analyzer: ra_cargo_watch: unsigned integer unferflow panic on empty main.rs file

Reproduction

Tested on the following version (last commit): 12ac379c6c47be389499aa4b37c754cc478945cd Note: the reproduction was built with debug symbols, i.e. with debug = 2: https://github.com/rust-analyzer/rust-analyzer/blob/3f499489f79d05f8cc31b72055155e91bc78fddc/Cargo.toml#L7

Link to youtube

Shallow investigation

Underflow itself happens at this line: https://github.com/rust-analyzer/rust-analyzer/blob/eba599d9863553d0f7d9d93f4c9050943da171cc/crates/ra_cargo_watch/src/conv.rs#L72

It seems that cargo check sends some invalid event data, because cargo_metadata docs claim that span.line_count is 1-based:

    /// 1-based. The line in the file.
    pub line_start: usize,
    /// 1-based. The line in the file.
    pub line_end: usize,

Maybe this is their bug, however, I am not entirely sure, because I didn’t work with ra_cargo_watch crate at all. @kiljacken, can you take a look, please ?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (16 by maintainers)

Most upvoted comments

This is very very weird. I’ve entirely copied the project hello-world that I opened in extension host to minimize it to the new folder hello-world-2, but the problem doesn’t appear in it, it appears only in the original forlder hello-world