irauta/bitreader

Rust analyzer text completion fails when unwrapping u8 bit

Closed this issue · 2 comments

    result.rq = reader.read_u8(1)
        .unwrap()
        . // here is where the completion fails

This is the error Rust analyzer is throwing:

[Error - 12:22:37 PM] Request textDocument/completion failed.
  Message: request handler panicked: index out of bounds: the len is 1 but the index is 73
  Code: -32603 

My first intuition is to say that this is a problem with rust-analyzer and not this crate, but even then it would be nice to know what specifically triggers the panic. I'll try to reproduce this once I get to a dev machine.

I tried the same code during the week (sorry for the delay in response!) and it worked for me, VS Code showed completions for a u8, as was expected. I don't know what the rest of your source looks like, so I had to improvise, but it seems to me the problem doesn't arise from those specific lines alone, and I can't currently see a way this is related to bitreader specifically.

That said, I'll close this issue for now. You might want to try to find a simply reproducible case where the error happens consistently and file an issue to the rust-analyzer project. Reopening this issue is obviously on the table, if it looks like it really is caused by something in bitreader itself.