You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#![crate_type="lib"]pubmod variant0 {pubenumA{A(())}pubstaticB:A = A(());pubfnmain(){}}#[cfg(variant1)]pubmod variant1 {pubenumA{A(())}pubstaticB:A = A(());// <-- error here ...// /tmp/s.rs:6:23: 6:28 error: unsupported constant expr// /tmp/s.rs:6 pub static B: A = A(());// ^~~~~pubfnmain(){matchA(()){B => (),// ... introduced by use of `B` here
_ => (),}}}#[cfg(variant2)]pubmod variant2 {pubenumC{D=3,E=4}pubstaticF:C = D;pubfnmain(){matchD{F => (), _ => (),}}}pubmod variant3 {pubenumC{D=3,E=4}pubstaticF:int = 3;pubfnmain(){matchDasint{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. :)
The text was updated successfully, but these errors were encountered:
This is accomplished by rewriting static expressions into equivalent patterns.
This way, patterns referencing static variables can both participate
in exhaustiveness analysis as well as be compiled down into the appropriate
branch of the decision trees that match expressions are codegened to.
Fixes#6533.
Fixes#13626.
Fixes#13731.
Fixes#14576.
Fixes#15393.
Some code:
Some funkiness:
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. :)
The text was updated successfully, but these errors were encountered: