-
Notifications
You must be signed in to change notification settings - Fork 8
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
[bug] Cannot use negative integer as default #9
Comments
I appears a workaround of: #[default(_code = "-1")] does work. |
It also appears this syntax is valid: #[default(-1)] Just not the '=' version shown in the documentation |
I checked, and this is not smart-default's doing - it properly parses and emits code for that case, and then something else is failing on this. I'm afraid there is nothing I can do... |
Okay... just to follow up that I'm not crazy... Here is an example crate showing the bug in a repo: https://github.com/Carter12s/smart_default_test Here is a CI run using the default github rust action replicating the failure: https://github.com/Carter12s/smart_default_test/actions/runs/3751186707/jobs/6371862293 |
Also here's a PR adding a test case to the repo that reproduces the compiler failure: |
I've been looking into this and it is (currently) expected behavior of the compiler. What happens is that it parses an arbitrary expression, which is required to macro-expand to a literal. It is documented like this in the Reference:
Source: https://doc.rust-lang.org/reference/attributes.html#meta-item-attribute-syntax I'm not exactly sure why this is required though. |
Minimum reproducible example:
Gives compiler error:
Removing the negative sign lets it compile perfectly.
Same result occurs on both rustc versions 1.60 and 1.66.
Using library version "0.6".
The text was updated successfully, but these errors were encountered: