Skip to content

"consider using a semicolon" where there already is one, after a ? #87051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ben0x539 opened this issue Jul 11, 2021 · 0 comments · Fixed by #87061
Closed

"consider using a semicolon" where there already is one, after a ? #87051

ben0x539 opened this issue Jul 11, 2021 · 0 comments · Fixed by #87061
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ben0x539
Copy link
Contributor

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 ?.

@ben0x539 ben0x539 added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 11, 2021
@bors bors closed this as completed in 5fcefb1 Jul 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant