Closed
Description
My config.toml:
[rust]
codegen-units = 8
debug = true
optimize = true
debug-assertions = true
debuginfo = true
debuginfo-lines = true
And my (odd?) build invocation:
% time python /Users/fklock/Dev/Mozilla/rust-mirborrowck/.git/../x.py test src/tools/tidy && \
time python /Users/fklock/Dev/Mozilla/rust-mirborrowck/.git/../x.py build --stage 1 --incremental --keep-stage 0 src/libstd && \
time python /Users/fklock/Dev/Mozilla/rust-mirborrowck/.git/../x.py test --stage 1 src/test/{mir-opt,compile-fail,run-pass}
Results in stage 1 binary where we get weirdness on this compile-fail test:
% ./objdir-dbgopt/build/x86_64-unknown-linux-gnu/stage1/bin/rustc src/test/compile-fail/enum-discrim-too-small2.rs
error: literal out of range for i8
--> src/test/compile-fail/enum-discrim-too-small2.rs:18:11
|
18 | Ci8 = 223, //~ ERROR literal out of range for i8
| ^^^
|
note: lint level defined here
--> src/test/compile-fail/enum-discrim-too-small2.rs:11:9
|
11 | #![deny(overflowing_literals)]
| ^^^^^^^^^^^^^^^^^^^^
error: literal out of range for i16
--> src/test/compile-fail/enum-discrim-too-small2.rs:25:12
|
25 | Ci16 = 55555, //~ ERROR literal out of range for i16
| ^^^^^
error: literal out of range for i32
--> src/test/compile-fail/enum-discrim-too-small2.rs:32:12
|
32 | Ci32 = 3_000_000_000, //~ ERROR literal out of range for i32
| ^^^^^^^^^^^^^
error: internal compiler error: librustc/ty/layout.rs:553: Integer::repr_discr: `#[repr]` hint too small for discriminant range of enum `Ei64
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.25.0-dev running on x86_64-unknown-linux-gnu
thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:508:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
I am pretty sure this is specific to debug builds. At least, that's my current best guess as to why this hasn't been caught by bors.
The code layout.rs
looks like this:
if let Some(ity) = repr.int {
let discr = Integer::from_attr(tcx, ity);
let fit = if ity.is_signed() { signed_fit } else { unsigned_fit };
if discr < fit {
bug!("Integer::repr_discr: `#[repr]` hint too small for \
discriminant range of enum `{}", ty)
}
return (discr, ity.is_signed());
}
it should probably be signalling a proper error, or trusting that the lint will eventually fire and catch this, rather than just triggering a call to bug!
(since this does not represent a bug in the compiler itself, right?)