immunant / c2rust

Migrate C code to Rust
https://c2rust.com/
Other
3.81k stars 220 forks source link

analyze: account for `Span`s indexing into aggregated sources, not individual files #967

Closed fw-immunant closed 1 year ago

fw-immunant commented 1 year ago

We create the root span as such:

let file_span = Span::new(file.start_pos, file.end_pos, SyntaxContext::root(), None);

So we have to subtract start_pos correspondingly from each bound when using subspans to index into the file contents as their own slice.

I can't easily push a test case for this, but ran into crashes and wrong output locally.