You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 <[email protected]>
0 commit comments