diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-01-03 13:09:15 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-03 13:09:15 +0000 |
| commit | 29fc022d851bb7b11e30acc3df6d3d425b104821 (patch) | |
| tree | c3c879424b7609ad702904d7355376832eb3e417 /src/test/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs | |
| parent | 8e9ccbf97a70259b6c6576e8fd7d77d28238737e (diff) | |
| parent | 2e472bb746a73d3440ebbdf11fb9aca4d56dd3cc (diff) | |
| download | rust-29fc022d851bb7b11e30acc3df6d3d425b104821.tar.gz rust-29fc022d851bb7b11e30acc3df6d3d425b104821.zip | |
Merge #11178
11178: Fix replace_match_with_if_let removing unsafe blocks r=bugadani a=bugadani
If the assist encounters an unsafe block in one of the match arms, the assist generated intermediate code like the following:
```rust
if let Foo(_) = foo {
<then branch>
} else unsafe { ... }
```
Which was then parsed back and the unsafe branch got completely removed, removing in invalid code output:
```rust
if let Foo(_) = foo {
<then branch>
} else
```
This PR fixes this issue.
However, I'm sure there is a better, more general solution here, but I lack familiarity with rust-analyzer. `make::expr_if` looks like it expects a `BlockExpr` that, when printed, is wrapped in braces correctly, but I'm sure changing the display impl for an `unsafe` `BlockExpr` would have caused problems. I could have changed `make::expr_if` instead to special case unsafe blocks, but that would have meant some expressions getting wrapped by the caller (as previously), and some others by the function.
Co-authored-by: Dániel Buga <bugadani@gmail.com>
Diffstat (limited to 'src/test/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs')
0 files changed, 0 insertions, 0 deletions
