about summary refs log tree commit diff
path: root/src/test/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-01-03 13:09:15 +0000
committerGitHub <noreply@github.com>2022-01-03 13:09:15 +0000
commit29fc022d851bb7b11e30acc3df6d3d425b104821 (patch)
treec3c879424b7609ad702904d7355376832eb3e417 /src/test/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs
parent8e9ccbf97a70259b6c6576e8fd7d77d28238737e (diff)
parent2e472bb746a73d3440ebbdf11fb9aca4d56dd3cc (diff)
downloadrust-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