-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Disallow non-monomorphic calls to needs_drop
in interpreter
#85994
Conversation
Some changes occured to the CTFE / Miri engine cc @rust-lang/miri |
r? @varkor (rust-highfive has picked a reviewer for you, use r? to override) |
Thanks, this makes sense. |
Cc @oli-obk |
I could be useful for optimizations to evaluate I do have a test case, but wasn't sure if we want one that depends on #![feature(const_generics)]
struct Value<const B: bool> {}
impl Value<true> { fn is_true() {} }
fn f<T>() {
Value::<{std::mem::needs_drop::<T>()}>::is_true();
}
fn main() {
f::<u32>();
} |
Well, for the latter that won't happen any more with this PR, right? |
For |
Ah, fair. Then maybe add comments to the other branches (the ones that do not call "ensure_monomorphic") explicitly saying "this code will correctly handle non-monomorphic calls" or so. I want to make sure that when/if another intrinsic is added, we don't introduce the same bug again... |
136ae04
to
e3e6cb2
Compare
r? @RalfJung |
Code change looks good to me; is there any way to have a test for this? r=me otherwise. |
otherwise evaluation could change after further substitutions.
e3e6cb2
to
07a03b0
Compare
Added a test case mentioned earlier. |
Awesome, thanks a lot. :) |
📌 Commit 07a03b0 has been approved by |
…alfJung Disallow non-monomorphic calls to `needs_drop` in interpreter otherwise evaluation could change after further substitutions.
@@ -0,0 +1,20 @@ | |||
error[E0599]: no function or associated item named `assert` found for struct `Bool<{ std::mem::needs_drop::<T>() }>` in the current scope |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error is useless - it would be good to suppress it. Is there already an issue for this kind of error?
☀️ Test successful - checks-actions |
otherwise evaluation could change after further substitutions.