Skip to content

Use a slightly more recent rustc toolchain that supports binrw #186

@RyanGlScott

Description

@RyanGlScott

For reasons that I do not fully understand, nightly-2025-02-16 (the Rust toolchain that mir-json currently requires) cannot build many snippets of code that use the binrw crate. Here is one such example. Given the following project structure:

$ tree .
.
├── Cargo.toml
└── src
    └── lib.rs

2 directories, 2 files

With the following files:

# Cargo.toml
[package]
name = "binrw-example"
version = "0.1.0"
edition = "2024"

[dependencies]
binrw = "=0.15.0"
// src/lib.rs
use binrw::BinRead;

#[derive(BinRead)]
pub struct Point {
    x: i16,
}

If you attempt to build this with the nightly-2025-02-16 toolchain, it will panic at compile time:

$ cargo +nightly-2025-02-16 build
<snip>
   Compiling binrw-example v0.1.0 (/Users/rscott/Documents/Hacking/Rust/binrw-example)
error: proc-macro derive panicked
 --> src/lib.rs:4:10
  |
4 | #[derive(BinRead)]
  |          ^^^^^^^
  |
  = help: message: byte index 3 is out of bounds of `x`

error: could not compile `binrw-example` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...

On the other hand, building this with stable Rust toolchains does not panic, nor does it panic if I pick a more recent nightly toolchain (e.g., nightly-2025-09-02). My hunch is that this was caused by a fleeting rustc compiler bug that was fixed at some point after the nightly-2025-02-16 toolchain was released.

Technically, this is not a mir-json bug, but rather a bug in the underlying toolchain. Still, it is quite annoying that one effectively cannot verify binrw-related code of this sort, so it would be nice if we could bump mir-json to a more recent nightly toolchain that does not suffer from this bug. The first step in doing so would be to figure out what the closest nightly toolchain to nightly-2025-02-16 is that does not suffer from this bug.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions