Skip to content

ra_cargo_watch: unsigned integer unferflow panic on empty main.rs file #2973

Closed
@Veetaha

Description

@Veetaha

Reproduction

Tested on the following version (last commit): 12ac379
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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions