Open
Description
I tried this code:
fn main() {
let mut items = vec![1, 2, 3, 4, 5].into_iter();
problem_thingy(&mut items);
}
fn problem_thingy(items: &mut impl Iterator<Item = u8>) {
let mut peeker = items.peekable();
match peeker.peek() {
Some(_) => (),
None => return (),
}
problem_thingy(&mut peeker);
}
I expected to see this happen: either continuously have the first item be "peeked" at, or return ()
on the final iteration after exhausting other peeks.
Instead, this happened: compiler panicked with an unbearably large error message. I believe this has to do with allocation and pointer safety with Peekable
, but I could be way off.
Meta
rustc --version --verbose
:
rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7
Backtrace and compiler output are unbearably large for this issue, so I've attached them below.
thread 'rustc' panicked at /rust/deps/ena-0.14.3/src/snapshot_vec.rs:199:10:
index out of bounds: the len is 0 but the index is 0