Closed
Description
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=47f2843373fb4ad713fa520aa446ee5a
fn main() -> Result<(), ()> {
a(|| {
b()
})?;
Ok(())
}
fn a<F>(f: F) -> Result<(), ()> where F: FnMut() { Ok(()) }
fn b() -> i32 { 42 }
The current output is:
error[E0308]: mismatched types
--> src/main.rs:3:9
|
2 | / a(|| {
3 | | b()
| | ^^^ expected `()`, found `i32`
4 | | })?;
| |_______- expected this to be `()`
|
help: consider using a semicolon here
|
3 | b();
| ^
help: consider using a semicolon here
|
4 | })?;;
| ^
Ideally the output should look like:
error[E0308]: mismatched types
--> src/main.rs:3:9
|
3 | b()
| ^^^ expected `()`, found `i32`
|
help: consider using a semicolon here
|
3 | b();
| ^
(I guess, even tho in my un-reduced case I needed to make a
take a closure returning a non-()
thing)
Doesn't happen without the ?
.