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
I'm not entirely sure this issue is by design of the language or really a bug, but it feels quite limiting.
When trying to use a enum variant from a external crate on a constant expression rustc fails telling it's not a constant expression although it works fine when it's in the same crate.
Example
Since it involves crates and such it's complicated to post the code only, so here's a project on which the issue can be reproduced easily by just running cargo build: https://dl.dropboxusercontent.com/u/35476123/Releases/tmp/rust-exenum.tar main_nope.rs tries to use a external enum in a constant expression and fails to compile. main_works.rs tries to use a enum from the same crate in a constant expression and works.
You can switch between those two mains in Cargo.toml.
I'm not entirely sure this issue is by design of the language or really a bug, but it feels quite limiting.
When trying to use a enum variant from a external crate on a constant expression rustc fails telling it's not a constant expression although it works fine when it's in the same crate.
Example
Since it involves crates and such it's complicated to post the code only, so here's a project on which the issue can be reproduced easily by just running
cargo build
:https://dl.dropboxusercontent.com/u/35476123/Releases/tmp/rust-exenum.tar
main_nope.rs
tries to use a external enum in a constant expression and fails to compile.main_works.rs
tries to use a enum from the same crate in a constant expression and works.You can switch between those two mains in
Cargo.toml
.excrate/lib.rs
main_nope.rs
main_works.rs
Meta
The text was updated successfully, but these errors were encountered: