Closed
Description
I accidentally used let statements when I was trying to assign to elements of a bytearray instead of just the equals sign. An ICE resulted.
I tried this code:
fn to_size(tag_size: u32) -> [u8; 4] {
let mut bytes: [u8; 4] = [0; 4];
assert!(tag_size < 2.pow(28), "to_size: Number too big to convert!");
let bytes[0] = (tag_size & 0x0FE00000 >> 21) as u8;
let bytes[1] = (tag_size & 0x001FC000 >> 14) as u8;
let bytes[2] = (tag_size & 0x00003F80 >> 7) as u8;
let bytes[3] = (tag_size & 0x0000007F >> 0) as u8;
bytes
}
fn main() {
println!("{:?}", to_size(257));
}
I expected the compiler to recognize those lets as errors, but instead it panicked with:
src/main.rs:12:9: 12:14 error: internal compiler error: ident only path should have been covered already
src/main.rs:12 let bytes[0] = (tag_size & 0x0FE00000 >> 21) as u8;
^~~~~
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: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/beta-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:130
Meta
rustc --version --verbose
:
rustc 1.0.0-beta (9854143 2015-04-02) (built 2015-04-02)
binary: rustc
commit-hash: 9854143
commit-date: 2015-04-02
build-date: 2015-04-02
host: x86_64-unknown-linux-gnu
release: 1.0.0-beta
Backtrace:
stack backtrace:
1: 0x7fea622273c8 - sys::backtrace::write::h179e141147f9ee14IJC
2: 0x7fea62252770 - panicking::on_panic::h6aa569d33389f0cfsXI
3: 0x7fea6218a4a3 - rt::unwind::begin_unwind_inner::h082f07869f4b9731ACI
4: 0x7fea5f55004d - rt::unwind::begin_unwind::h13428428822164950735
5: 0x7fea5f54fff3 - diagnostic::SpanHandler::span_bug::he82cb6427e6a50a8jnB
6: 0x7fea5f57779a - parse::parser::Parser<'a>::parse_pat::ha10816fc85a711f2ADH
7: 0x7fea5f58c08a - parse::parser::Parser<'a>::parse_local::h7a4b73a54cfe440eUUH
8: 0x7fea5f58c8af - parse::parser::Parser<'a>::parse_stmt_::hc177f9743625a47b1XH
9: 0x7fea5f585a5a - parse::parser::Parser<'a>::parse_block_tail::h39c4a68e017bc6c6l8H
10: 0x7fea5f570e6d - parse::parser::Parser<'a>::parse_inner_attrs_and_block::h11a14d825d017327e7H
11: 0x7fea5f5996da - parse::parser::Parser<'a>::parse_item_fn::h5e181fed3ab83833pII
12: 0x7fea5f5902a6 - parse::parser::Parser<'a>::parse_item_::h400393f2ccce4b57jyJ
13: 0x7fea5f59f3ea - parse::parser::Parser<'a>::parse_mod_items::h9961b2bcefd3983fo4I
14: 0x7fea5f5a5a75 - parse::parser::Parser<'a>::parse_crate_mod::hb6ea15a6eba26ddd7WJ
15: 0x7fea5f5ba8f5 - parse::parse_crate_from_file::h4c866de8bdd6168diMQ
16: 0x7fea628b5a48 - driver::phase_1_parse_input::closure.15614
17: 0x7fea6288cc63 - driver::phase_1_parse_input::hddfc72484068c586Nqa
18: 0x7fea62888fa7 - driver::compile_input::h7c62c2870ff901f6Qba
19: 0x7fea62941a25 - run_compiler::hc815b49ce638c28eV4b
20: 0x7fea6293f33d - boxed::F.FnBox<A>::call_box::h4290333406520961126
21: 0x7fea6293e879 - rt::unwind::try::try_fn::h13999576404798567721
22: 0x7fea622cec68 - rust_try_inner
23: 0x7fea622cec55 - rust_try
24: 0x7fea6293eb4b - boxed::F.FnBox<A>::call_box::h14489442628055152240
25: 0x7fea6223d781 - sys::thread::create::thread_start::h02b7da32b4d7a4aaExH
26: 0x7fea5c02e373 - start_thread
27: 0x7fea61dfd27c - __clone
28: 0x0 - <unknown>