Jefffrey opened a new issue, #6480:
URL: https://github.com/apache/arrow-rs/issues/6480

   **Describe the bug**
   <!--
   A clear and concise description of what the bug is.
   -->
   
   BitIterator panics when retrieving its length via ExactSizeIterator
   
   **To Reproduce**
   <!--
   Steps to reproduce the behavior:
   -->
   
   ```rust
       #[test]
       fn test123() {
           let b = BitIterator::new(&[0b00000010], 0, 2);
           dbg!(b.len());
       }
   ```
   
   Output:
   
   ```
   arrow-rs$ cargo test -p arrow-buffer --lib 
util::bit_iterator::tests::test123 -- --nocapture
       Blocking waiting for file lock on build directory
      Compiling arrow-buffer v53.0.0 (/home/jeffrey/Code/arrow-rs/arrow-buffer)
       Finished `test` profile [unoptimized + debuginfo] target(s) in 9.48s
        Running unittests src/lib.rs 
(/media/jeffrey/1tb_860evo_ssd/.cargo_target_cache/debug/deps/arrow_buffer-9f4040912c29ccf9)
   
   running 1 test
   thread 'util::bit_iterator::tests::test123' panicked at 
/rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/iter/traits/exact_size.rs:122:9:
   assertion `left == right` failed
     left: None
    right: Some(0)
   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
   test util::bit_iterator::tests::test123 ... FAILED
   
   failures:
   
   failures:
       util::bit_iterator::tests::test123
   
   test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 128 filtered 
out; finished in 0.00s
   
   error: test failed, to rerun pass `-p arrow-buffer --lib`
   ```
   
   **Expected behavior**
   <!--
   A clear and concise description of what you expected to happen.
   -->
   
   Doesn't panic
   
   **Additional context**
   <!--
   Add any other context about the problem here.
   -->
   
   Panic is here: 
https://github.com/rust-lang/rust/blob/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/iter/traits/exact_size.rs#L122
   
   Looks like BitIterator implements ExactSizeIterator:
   
   
https://github.com/apache/arrow-rs/blob/f41c258246cd4bd9d89228cded9ed54dbd00faff/arrow-buffer/src/util/bit_iterator.rs#L71
   
   But it does not override the default size_hint from Iterator:
   
   
https://github.com/apache/arrow-rs/blob/f41c258246cd4bd9d89228cded9ed54dbd00faff/arrow-buffer/src/util/bit_iterator.rs#L56-L69
   
   According to docs: 
https://doc.rust-lang.org/std/iter/trait.ExactSizeIterator.html
   
   > When doing so, the implementation of [`Iterator::size_hint`] *must* return 
the exact size of the iterator.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to