-
-
Notifications
You must be signed in to change notification settings - Fork 52
Const _: () is not evaluated #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Using these Rust versions:
The output of Cargo.toml: Ùsed Code in lib.rs: You are overly eager to close issues,didn't even mention my code example compiles for you. |
|
Could you please confirm that the following script does not produce errors when you run it locally? #!/bin/bash
set -xe
rustup update nightly-2019-05-22
git clone https://github.com/dtolnay/case-studies
cd case-studies/bitfield-assertion/demo
git fetch origin refs/pull/6/head
git checkout FETCH_HEAD
cargo +nightly-2019-05-22 check
cargo expand
echo wow |
|
I ran that script,here is the entire output: What's weird is that if I replace main.rs with the output of cargo expand I get this error: Ànd if I add Fixed macro expanded |
|
The problem seems to be that the constants outputed by proc-macros are not evaluated in I got the macro to error with : But I get an unhelpful error: |
|
Right. It looks like what you are showing is basically First attempt but now with two extra unstable features. This is the behavior described in that section and the error message shown in that section. |
|
This entire thing looks like a bug that needs to be reported,I don't understand why expanding a macro would change whether a constant is evaluated,or why it wouldn't report the error that the generated code produces(rather than just saying "referenced constant has errors" without any details). |
|
Possibly! Want to follow up with a compiler bug report? Let me know if it ends up getting fixed in a way that would make it possible to do an error message that is better than the solution in the case study. |
|
Yes,I will start by looking for similar issues,and if I don't find any recent report of this I will create an issue for "macro generated code doesn't evaluate panicking consts when the expanded code does". |
|
Nice, thanks a lot! |
|
Filed an issue for the different behavior in constants:rust-lang/rust#61058 |
|
For the sake of history: this seems to be fixed by rust-lang/rust@643261a |
Ref #1. Try
cargo checkand observe that this code compiles successfully despite the assertions being violated. Both generated consts are visible in the output ofcargo expand.