| Age | Commit message (Collapse) | Author | Lines |
|
|
|
This commit removes many cases of MIR opt tests emitting `.diff`s for more than one pass. These
tests cannot be `unit-test`s, and so they are easy to break, and they also provide little value due
to having excessively strong opinions over *how* a piece of code should be optimized.
Where reasonable, we instead add separate test files that only emit the `PreCodegen.after` MIR for
code where we want to track what the result of the net result of the optimization pipeline's output
is.
|
|
|
|
Thanks for the suggestions, lcnr!
Co-authored-by: lcnr <rust@lcnr.de>
|
|
|
|
`SimplifyArm` and such are currently in `-Zunsound-mir-opts` and thus weren't running by default, so having something like them for the new desugar shouldn't be necessary for switching.
|
|
|
|
The optimization still has some bugs that need to be worked out
such as #77359.
We can try re-enabling this again after the known issues are resolved.
|
|
and `discriminant(_0) = discriminant(0)` are considered equal if 0 is a fieldless variant of an enum
|
|
|
|
I also added test cases to make sure the optimization can fire on all of
these cases:
```rust
fn case_1(o: Option<u8>) -> Option<u8> {
match o {
Some(u) => Some(u),
None => None,
}
}
fn case2(r: Result<u8, i32>) -> Result<u8, i32> {
match r {
Ok(u) => Ok(u),
Err(i) => Err(i),
}
}
fn case3(r: Result<u8, i32>) -> Result<u8, i32> {
let u = r?;
Ok(u)
}
```
Without MIR inlining, this still does not completely optimize away the
`?` operator because the `Try::into_result()`, `From::from()` and
`Try::from_error()` calls still exist. This does move us a bit closer to
that goal though because:
- We can now run the pass on mir-opt-level=1
- We no longer depend on the copy propagation pass running which is
unlikely to stabilize anytime soon.
|