-
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
UB: edition 2015/18 with -Zmir-opt-level=2: destructing tuple inside closure #110781
Comments
Looks to me like the problem is that --- a/mir_dump/scratch.main-{closure#0}.005-015.DeadStoreElimination.before.mir
+++ b/mir_dump/scratch.main-{closure#0}.005-015.DeadStoreElimination.after.mir
@@ -1,4 +1,4 @@
-// MIR for `main::{closure#0}` before DeadStoreElimination
+// MIR for `main::{closure#0}` after DeadStoreElimination
fn main::{closure#0}(_1: &[closure@src/main.rs:4:13: 4:15]) -> () {
debug t => (*((*_1).0: &(std::string::String, std::string::String))); // in scope 0 at src/main.rs:2:9: 2:10
@@ -9,7 +9,6 @@ fn main::{closure#0}(_1: &[closure@src/main.rs:4:13: 4:15]) -> () {
bb0: {
Retag([fn entry] _1); // scope 0 at src/main.rs:4:13: 6:6
- _2 = deref_copy ((*_1).0: &(std::string::String, std::string::String)); // scope 0 at src/main.rs:5:22: 5:23
PlaceMention((*_2)); // scope 0 at src/main.rs:5:22: 5:23
return; // scope 0 at src/main.rs:6:6: 6:6
} |
The bug is here. I feel obligated to mention that I have repeatedly warned that these bugs are going to happen. We should really stop using |
I was wondering why |
Why is this not just a bug in PlaceContext assignment? |
See my comment in the PR - in general, my understanding is that the definition of placecontext is what it is because that's what makes sense in some other part of the compiler. If we start changing placecontext now to have the information that's useful to optimizations, I worry we'll just end up making those parts of the compiler buggy |
I tried this code:
You need edition 2015 or 2018 to reproduce this.
RUSTFLAGS="-Zmir-opt-level=2" ~/.cargo/bin/cargo miri run
The text was updated successfully, but these errors were encountered: