diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-06-29 00:26:54 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-29 00:26:54 +0900 |
| commit | 4afdef07d9edb6fab979b01f510a16ffc27a6ab6 (patch) | |
| tree | acbad63401ccc4f8918fd56380c88db9799416c7 /library/std/src/sys/unix/stack_overflow.rs | |
| parent | 17ea490310ba7c836c93fe1b7002555b3bea5eb1 (diff) | |
| parent | bdddaebd76cba207b67141e2c362a4fe117bbd34 (diff) | |
| download | rust-4afdef07d9edb6fab979b01f510a16ffc27a6ab6.tar.gz rust-4afdef07d9edb6fab979b01f510a16ffc27a6ab6.zip | |
Rollup merge of #86206 - FabianWolff:issue-86188, r=Mark-Simulacrum
Fix type checking of return expressions outside of function bodies
This pull request fixes #86188. The problem is that the current code for type-checking `return` expressions stops if the `return` occurs outside of a function body, while the correct behavior is to continue type-checking the return value expression (otherwise an ICE happens later on because variables declared in the return value expression don't have a type).
Also, I have noticed that it is sometimes not obvious why a `return` is outside of a function body; for instance, in the example from #86188 (which currently causes an ICE):
```rust
fn main() {
[(); return || {
let tx;
}]
}
```
I have changed the error message to also explain why the `return` is considered outside of the function body:
```
error[E0572]: return statement outside of function body
--> ice0.rs:2:10
|
1 | / fn main() {
2 | | [(); return || {
| |__________^
3 | || let tx;
4 | || }]
| ||_____^ the return is part of this body...
5 | | }
| |_- ...not the enclosing function body
```
Diffstat (limited to 'library/std/src/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions
