Fix type checking of return expressions outside fn bodies
This commit is contained in:
parent
40c1623b16
commit
bdddaebd76
8 changed files with 206 additions and 32 deletions
|
|
@ -1,13 +1,21 @@
|
|||
fn main() {
|
||||
//~^ NOTE: not the enclosing function body
|
||||
//~| NOTE: not the enclosing function body
|
||||
//~| NOTE: not the enclosing function body
|
||||
//~| NOTE: not the enclosing function body
|
||||
|_: [_; return || {}] | {};
|
||||
//~^ ERROR return statement outside of function body
|
||||
//~^ ERROR: return statement outside of function body [E0572]
|
||||
//~| NOTE: the return is part of this body...
|
||||
|
||||
[(); return || {}];
|
||||
//~^ ERROR return statement outside of function body
|
||||
//~^ ERROR: return statement outside of function body [E0572]
|
||||
//~| NOTE: the return is part of this body...
|
||||
|
||||
[(); return |ice| {}];
|
||||
//~^ ERROR return statement outside of function body
|
||||
//~^ ERROR: return statement outside of function body [E0572]
|
||||
//~| NOTE: the return is part of this body...
|
||||
|
||||
[(); return while let Some(n) = Some(0) {}];
|
||||
//~^ ERROR return statement outside of function body
|
||||
//~^ ERROR: return statement outside of function body [E0572]
|
||||
//~| NOTE: the return is part of this body...
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +1,62 @@
|
|||
error[E0572]: return statement outside of function body
|
||||
--> $DIR/issue-51714.rs:2:14
|
||||
--> $DIR/issue-51714.rs:6:14
|
||||
|
|
||||
LL | |_: [_; return || {}] | {};
|
||||
| ^^^^^^^^^^^^
|
||||
LL | / fn main() {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | |_: [_; return || {}] | {};
|
||||
| | ^^^^^^^^^^^^ the return is part of this body...
|
||||
... |
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_- ...not the enclosing function body
|
||||
|
||||
error[E0572]: return statement outside of function body
|
||||
--> $DIR/issue-51714.rs:5:10
|
||||
--> $DIR/issue-51714.rs:10:10
|
||||
|
|
||||
LL | [(); return || {}];
|
||||
| ^^^^^^^^^^^^
|
||||
LL | / fn main() {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | [(); return || {}];
|
||||
| | ^^^^^^^^^^^^ the return is part of this body...
|
||||
... |
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_- ...not the enclosing function body
|
||||
|
||||
error[E0572]: return statement outside of function body
|
||||
--> $DIR/issue-51714.rs:8:10
|
||||
--> $DIR/issue-51714.rs:14:10
|
||||
|
|
||||
LL | [(); return |ice| {}];
|
||||
| ^^^^^^^^^^^^^^^
|
||||
LL | / fn main() {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | [(); return |ice| {}];
|
||||
| | ^^^^^^^^^^^^^^^ the return is part of this body...
|
||||
... |
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_- ...not the enclosing function body
|
||||
|
||||
error[E0572]: return statement outside of function body
|
||||
--> $DIR/issue-51714.rs:11:10
|
||||
--> $DIR/issue-51714.rs:18:10
|
||||
|
|
||||
LL | [(); return while let Some(n) = Some(0) {}];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | / fn main() {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | [(); return while let Some(n) = Some(0) {}];
|
||||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the return is part of this body...
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_- ...not the enclosing function body
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue