Closed
Description
When I test this program with cargo test
:
struct Bar(Vec<u8>);
impl Bar {
fn new(values: &[u8]) -> Self {
Bar(values.into())
}
fn get(&self, index: usize) -> u8 {
self.0[index]
}
}
#[test]
fn test() {
let foo = Bar::new(&[0u8; 4294967295]);
assert_eq!(foo.get(1), 0);
}
fn main() {
println!("hello world");
}
I got this:
C:\...\test>cargo test
Compiling foo v0.1.0 (file:///C:/.../test)
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.23.0-nightly (d6b06c63a 2017-11-09) running on i686-pc-windows-gnu
thread 'rustc' panicked at 'capacity overflow', src\libcore\option.rs:839:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: Could not compile `foo`.
To learn more, run the command again with --verbose.