-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
New compiler error in beta: this constant cannot be used, attempted to read undefined bytes #54387
Comments
the testcase compiles with |
Minimized: pub struct GstRc {
_obj: *const (),
_borrowed: bool,
}
const FOO: Option<GstRc> = None;
fn main() {
let _meh = FOO;
} |
Visited during T-compiler meeting. Tentatively assigning to @eddyb for investigation. |
I've been looking into this. It seems that the issue stems from here. Specifically, because the niche-filling enum representation is used for |
Ahh, you're right! I don't know why only the second component was special-cased. |
Seems like @oli-obk's quest to keep However, in this case nothing should even be trying to convert to a |
Actually it looks like this is not a EDIT: It is definitely a |
I am working on a fix. EDIT: Submitted as #54693 |
do not normalize all non-scalar constants to a ConstValue::ScalarPair We still need `ConstValue::ScalarPair` for match handling (matching slices and strings), but that will never see anything `Undef`. For non-fat-ptr `ScalarPair`, just point to the allocation like larger data structures do. Fixes #54387 r? @eddyb
Should this be closed before we get a beta backport? |
Backported to beta. Closing this. |
Since latest beta (and nightly), some of my crates have errors like the following
A standalone testcase replicating all the involved types can be found below (depends only on the
libc
crate).I don't know if the error is valid, but in any case I don't understand what it means so at least the error message could be improved a bit :)
The text was updated successfully, but these errors were encountered: