-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Old vtable example fails with: "error: untyped pointers are not allowed in constant" #77995
Comments
Since this requires feature gate which only exists on nightly toolchain @rustbot modify labels: -regression-from-stable-to-stable requires-nightly |
Oops, thanks for fixing that @lzutao :) |
cc @rust-lang/wg-const-eval Could someone confirm if this is an intended change? |
This is an expected regression, but we actually want to unregress it: rust/compiler/rustc_mir/src/interpret/intern.rs Lines 407 to 411 in d245464
|
IIRC the main concern here is that we need to implicitly mark the memory that pointer points to as immutable -- if the programmer did not expect this, they'd cause UB when mutating it. I am surprised by this example though... the memory that needs interning here might be the vtable? That case actually should not be too hard to allow I feel. We might be able to just check |
Or alternatively we could intern vtables already in |
While trying to play around with
raw::TraitObject
I found this thread internals.rust-lang.org/... and in particular this code example play.rust-lang.org/... which does not work anymore.Code
I tried this code:
I expected to see this happen:
I get the vtable as a const.
Instead, this happened:
error: untyped pointers are not allowed in constant
Version it worked on
Probably before c400f75
Edit: added PR number #71665
Version with regression
rustc 1.49.0-nightly (e160e5c 2020-10-14)
Any chance we can get the example code to compile again?
Is there a different way to get the vtable?
The text was updated successfully, but these errors were encountered: