<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/compiler/rustc_mir_transform/src/match_branches.rs, branch beta</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=beta</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=beta'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2025-05-26T10:15:54+00:00</updated>
<entry>
<title>mir-opt: Do not transform non-int type in match_branches</title>
<updated>2025-05-26T10:15:54+00:00</updated>
<author>
<name>dianqk</name>
<email>dianqk@dianqk.net</email>
</author>
<published>2025-05-24T11:43:26+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=457f8ba447a2f2d3fc20ad2b0d779d49c9883485'/>
<id>urn:sha1:457f8ba447a2f2d3fc20ad2b0d779d49c9883485</id>
<content type='text'>
</content>
</entry>
<entry>
<title>mir-opt: Use one MirPatch in MatchBranchSimplification</title>
<updated>2025-04-20T12:56:41+00:00</updated>
<author>
<name>dianqk</name>
<email>dianqk@dianqk.net</email>
</author>
<published>2025-04-20T12:56:41+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=11cfc16a60dcca27a1872fa3e83df35d797e8521'/>
<id>urn:sha1:11cfc16a60dcca27a1872fa3e83df35d797e8521</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Rollup merge of #139042 - compiler-errors:do-not-optimize-switchint, r=saethlin</title>
<updated>2025-04-19T19:30:46+00:00</updated>
<author>
<name>Chris Denton</name>
<email>chris@chrisdenton.dev</email>
</author>
<published>2025-04-19T19:30:46+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=5d2375f789e88d0ac6dbbd828082559a5d2fa8c6'/>
<id>urn:sha1:5d2375f789e88d0ac6dbbd828082559a5d2fa8c6</id>
<content type='text'>
Do not remove trivial `SwitchInt` in analysis MIR

This PR ensures that we don't prematurely remove trivial `SwitchInt` terminators which affects both the borrow-checking and runtime semantics (i.e. UB) of the code. Previously the `SimplifyCfg` optimization was removing `SwitchInt` terminators when they was "trivial", i.e. when all arms branched to the same basic block, even if that `SwitchInt` terminator had the side-effect of reading an operand which (for example) may not be initialized or may point to an invalid place in memory.

This behavior is unlike all other optimizations, which are only applied after "analysis" (i.e. borrow-checking) is finished, and which Miri disables to make sure the compiler doesn't silently remove UB.

Fixing this code "breaks" (i.e. unmasks) code that used to borrow-check but no longer does, like:

```rust
fn foo() {
    let x;
    let (0 | _) = x;
}
```

This match expression should perform a read because `_` does not shadow the `0` literal pattern, and the compiler should have to read the match scrutinee to compare it to 0. I've checked that this behavior does not actually manifest in practice via a crater run which came back clean: https://github.com/rust-lang/rust/pull/139042#issuecomment-2767436367

As a side-note, it may be tempting to suggest that this is actually a good thing or that we should preserve this behavior. If we wanted to make this work (i.e. trivially optimize out reads from matches that are redundant like `0 | _`), then we should be enabling this behavior *after* fixing this. However, I think it's kinda unprincipled, and for example other variations of the code don't even work today, e.g.:

```rust
fn foo() {
    let x;
    let (0.. | _) = x;
}
```
</content>
</entry>
<entry>
<title>In `rustc_mir_tranform`, iterate over index newtypes instead of ints</title>
<updated>2025-04-12T11:53:07+00:00</updated>
<author>
<name>Yotam Ofek</name>
<email>yotam.ofek@gmail.com</email>
</author>
<published>2025-04-11T14:26:26+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=c36e8fcc3c128e31eaa643904c9b8b33d9a5c1a6'/>
<id>urn:sha1:c36e8fcc3c128e31eaa643904c9b8b33d9a5c1a6</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Do not optimize out SwitchInt before borrowck, or if Zmir-preserve-ub</title>
<updated>2025-04-08T21:05:20+00:00</updated>
<author>
<name>Michael Goulet</name>
<email>michael@errs.io</email>
</author>
<published>2025-03-30T18:52:25+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=3ee62a906e8a025834d11c46b8c2f133d3a12448'/>
<id>urn:sha1:3ee62a906e8a025834d11c46b8c2f133d3a12448</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Stop relying on rustc_type_ir in non-type-system crates</title>
<updated>2025-03-15T06:42:48+00:00</updated>
<author>
<name>Michael Goulet</name>
<email>michael@errs.io</email>
</author>
<published>2025-03-13T18:05:00+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=b88f85a4106ca0a53a1dab6d605cf56a0cc945ac'/>
<id>urn:sha1:b88f85a4106ca0a53a1dab6d605cf56a0cc945ac</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Move `MirPatch` from `rustc_middle` to `rustc_mir_transform`.</title>
<updated>2025-02-14T05:15:57+00:00</updated>
<author>
<name>Nicholas Nethercote</name>
<email>n.nethercote@gmail.com</email>
</author>
<published>2025-02-14T04:56:06+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=28b75a384e483d654dbe95bb376dc39af8b117c1'/>
<id>urn:sha1:28b75a384e483d654dbe95bb376dc39af8b117c1</id>
<content type='text'>
Because it's only used in `rustc_mir_transform`. (Presumably it is
currently in `rustc_middle` because lots of other MIR-related stuff is,
but that's not a hard requirement.) And because `rustc_middle` is huge
and it's always good to make it smaller.
</content>
</entry>
<entry>
<title>Disable non-required MIR opts with `optimize(none)`</title>
<updated>2025-01-23T17:40:41+00:00</updated>
<author>
<name>clubby789</name>
<email>jamie@hill-daniel.co.uk</email>
</author>
<published>2024-12-09T19:34:51+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=7a9661d768f52d4bde71b6f2ed605f33c7053d78'/>
<id>urn:sha1:7a9661d768f52d4bde71b6f2ed605f33c7053d78</id>
<content type='text'>
Co-authored-by: Waffle Lapkin &lt;waffle.lapkin@gmail.com&gt;
</content>
</entry>
<entry>
<title>MatchBranchSimplification: Consider empty-unreachable otherwise branch</title>
<updated>2024-12-27T10:57:46+00:00</updated>
<author>
<name>clubby789</name>
<email>jamie@hill-daniel.co.uk</email>
</author>
<published>2024-10-04T20:26:41+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=e32ec45c02d890e46e55af86163a6d1ba10a4b41'/>
<id>urn:sha1:e32ec45c02d890e46e55af86163a6d1ba10a4b41</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Remove -Zfuel.</title>
<updated>2024-11-26T10:45:21+00:00</updated>
<author>
<name>Camille GILLOT</name>
<email>gillot.camille@gmail.com</email>
</author>
<published>2023-05-01T09:56:39+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=7fa021ad86fb62753576332a1a52b78acac492f9'/>
<id>urn:sha1:7fa021ad86fb62753576332a1a52b78acac492f9</id>
<content type='text'>
</content>
</entry>
</feed>
