Closed
Description
Code
fn main() {
let _x = std::boxed::Box::new(|x|x+1;);
}
Current output
error: closure bodies that contain statements must be surrounded by braces
--> src/main.rs:2:37
|
2 | let _x = std::boxed::Box::new(|x|x+1;);
| ^
3 | }
| ^
|
note: statement found outside of a block
--> src/main.rs:2:41
|
2 | let _x = std::boxed::Box::new(|x|x+1;);
| ---^ this `;` turns the preceding closure into a statement
| |
| this expression is a statement because of the trailing semicolon
note: the closure body may be incorrectly delimited
--> src/main.rs:2:35
|
2 | let _x = std::boxed::Box::new(|x|x+1;);
| ^^^^^^ this is the parsed closure...
3 | }
| - ...but likely you meant the closure to end here
help: try adding braces
|
2 ~ let _x = std::boxed::Box::new(|x| {x+1;);
3 ~ }}
|
error: expected `;`, found `}`
--> src/main.rs:2:44
|
2 | let _x = std::boxed::Box::new(|x|x+1;);
| ^ help: add `;` here
3 | }
| - unexpected token
error: could not compile `playground` due to 3 previous errors
Desired output
error: closure bodies that contain statements must be surrounded by braces
--> src/main.rs:2:37
|
2 | let _x = std::boxed::Box::new(|x|x+1;);
| ^
3 | }
| ^
|
note: statement found outside of a block
--> src/main.rs:2:41
|
2 | let _x = std::boxed::Box::new(|x|x+1;);
| ---^ this `;` turns the preceding closure into a statement
| |
| this expression is a statement because of the trailing semicolon
help: try adding braces
|
2 ~ let _x = std::boxed::Box::new(|x| {x+1;});
|
error: could not compile `playground` due to 3 previous errors