-
Notifications
You must be signed in to change notification settings - Fork 13k
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
checked arithmetic not treated as constant in debug builds #38074
Comments
cc @eddyb |
This has to do with how the result of a checked op is a tuple and the 2's complement wrapping value is accessed through I believe that the promoter will work as-is, it's just the constant qualifier that needs to understand this. |
Looking at it again, the const qualifier works fine with fields, but the promoter's initial set of potentially promotable temporaries doesn't include the tuple because one of the uses is by-field. |
Allow projections to be promoted to constants in MIR. This employs the `LvalueContext` additions by @pcwalton to properly extend the MIR promotion of temporaries to allow projections (field accesses, indexing and dereferences) on said temporaries. It's needed both parity with the old constant qualification logic (for current borrowck) and it fixes #38074. The former is *required for soundness* if we accept the RFC for promoting rvalues to `'static` constants. That is, until we get MIR borrowck and the same source of truth will be used for both checks and codegen.
This code produces a compiler error with
rustc foo.rs
but compiles successfully withrustc -O foo.rs
:The error is:
The text was updated successfully, but these errors were encountered: