Closed
Description
Some code:
#![crate_type="lib"]
pub mod variant0 {
pub enum A { A(()) }
pub static B: A = A(());
pub fn main() {
}
}
#[cfg(variant1)]
pub mod variant1 {
pub enum A { A(()) }
pub static B: A = A(()); // <-- error here ...
// /tmp/s.rs:6:23: 6:28 error: unsupported constant expr
// /tmp/s.rs:6 pub static B: A = A(());
// ^~~~~
pub fn main() {
match A(()) {
B => (), // ... introduced by use of `B` here
_ => (), }
}
}
#[cfg(variant2)]
pub mod variant2 {
pub enum C { D=3, E=4 }
pub static F : C = D;
pub fn main() {
match D { F => (), _ => (), }
}
}
pub mod variant3 {
pub enum C { D=3, E=4 }
pub static F : int = 3;
pub fn main() {
match D as int { F => (), _ => (), }
}
}
Some funkiness:
% rustc /tmp/s.rs
% rustc --cfg variant1 /tmp/s.rs
/tmp/s.rs:14:23: 14:28 error: unsupported constant expr
/tmp/s.rs:14 pub static B: A = A(()); // <-- error here ...
^~~~~
% rustc --cfg variant2 /tmp/s.rs
error: internal compiler error: only scalars and strings supported in compare_values
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://static.rust-lang.org/doc/master/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at '~Any', /Users/fklock/Dev/Mozilla/rust.git/src/libsyntax/diagnostic.rs:155
%
The oddity in variant1, as noted in the comments, is that the use of B
in a match pattern is causing the compiler to complain about its definition as a static item.
The oddity in variant2 is that we hit an ICE. :)