jam1garner / binrw

A Rust crate for helping parse and rebuild binary data using ✨macro magic✨.
https://binrw.rs
MIT License
627 stars 37 forks source link

proc-macro derive panicked: byte index 4 is out of bounds of `` when blank line present between doc comments #263

Closed apps4uco closed 5 months ago

apps4uco commented 5 months ago

I have encountered a minimal test case that reproduces the issue

use binrw::prelude::*;

#[derive(Debug, Default, PartialEq, BinRead)]
#[brw(little)]
pub struct MyStruct {
    ///Doc Comment + Blank Line

    ///Doc Comment
    version: u32,
}
[dependencies]
binrw = "0.13.3"

The full error message is

error: proc-macro derive panicked
 --> src/lib.rs:3:37
  |
3 | #[derive(Debug, Default, PartialEq, BinRead)]
  |                                     ^^^^^^^
  |
  = help: message: byte index 4 is out of bounds of ``

error: could not compile `binrw_bug` (lib) due to 1 previous error

Removing the blank line allows the code to compile.

apps4uco commented 5 months ago

Thanks, that was quick.....