Introduce a no-op PlaceMention statement for let _ =.#102256
Introduce a no-op PlaceMention statement for let _ =.#102256bors merged 9 commits intorust-lang:masterfrom
PlaceMention statement for let _ =.#102256Conversation
|
r? @TaKO8Ki (rust-highfive has picked a reviewer for you, use r? to override) |
|
This PR changes MIR cc @oli-obk, @RalfJung, @JakobDegen, @davidtwco, @celinval, @vakaras |
|
Does this also fix #80059? |
|
@lukas-code, yes, I added a test. |
|
This sounds great! For Miri's rust-lang/miri#2360 it'd be awesome if those FakeRead could stick around in MIR a bit longer than they currently do (i.e., the pass that removes them should not be run with |
|
We currently spec |
|
I made this a |
@JakobDegen I don't see the issue. |
Sorry, that was in response to Ralf's comment about rust-lang/miri#2360 . For the purposes in this PR what you have is completely fine (in other words, if we wanted to use this to fix the miri issue it would stop being an analysis helper) |
|
I've tried the example in #80059 for destructuring assignments to |
dcbbb69 to
6fe81fe
Compare
|
@est31 it does. Added to the test. |
There was a problem hiding this comment.
I meant one with _ = only, without a let.
|
We talked about this in the T-lang meeting. The main concern, from the language side, was that we had carefully calibrated a boundary for what kinds of things should be considered "syntactic checks" (checking for missing
So, there's an architectural question for T-compiler: I believe this PR is adding something useful today, and so I suspect we should land it. But: Do we think there's any chance we'll resurrect #99379, or otherwise try to do unsafeck on THIR, in the near term? I would like an answer from T-compiler about that before moving forward on this PR. @rustbot label I-compiler-nominated |
|
When I originally wrote this commit, I did not intend it to be useful for unsafeck. My focus was #101500, which is "flow analysis". While I agree with the syntactic/dataflow separation between THIR and MIR, I still think that this PR is useful:
|
If we do, then this PR just means MIR and THIR unsafety checking are more in line with each other, right? I don't quite understand what the concern is here. |
I think this PR is crucial since it is a first step towards resolving rust-lang/miri#2360. |
|
Btw, this will also fix #79735, won't it? |
This comment has been minimized.
This comment has been minimized.
It should. I'll test it when I get my laptop working again. A bit more problematic: this PR also introduces an error in this snippet, which currently passes borrow checking. fn foo(mut n: Option<usize>) {
let _ = if let Some(ref mut s) = n {
s
} else {
&mut 0
//~^ ERROR temporary value dropped while borrowed
};
}This error already happens for |
|
Updated coverage info. |
|
🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened. |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (d583342): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. |
Fixes #54003
Fixes #80059
Split from #101500
This PR introduces a new
PlaceMentionstatement dedicated to matches that neither introduce bindings nor ascribe types. Without this, all traces of the match would vanish from MIR, making it impossible to diagnose unsafety or use in #101500.This allows to mark
let _ = <unsafe union access or dereference>as requiring an unsafe block.Nominating for lang team, as this introduces an extra error.