]> git.lizzy.rs Git - rust.git/blob - src/test/ui/suggestions/try-operator-dont-suggest-semicolon.rs
Rollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelid
[rust.git] / src / test / ui / suggestions / try-operator-dont-suggest-semicolon.rs
1 // Regression test for #87051, where a double semicolon was erroneously
2 // suggested after a `?` operator.
3
4 fn main() -> Result<(), ()> {
5     a(|| {
6         b()
7         //~^ ERROR: mismatched types [E0308]
8         //~| NOTE: expected `()`, found `i32`
9         //~| HELP: consider using a semicolon here
10     })?;
11
12     // Here, we do want to suggest a semicolon:
13     let x = Ok(42);
14     if true {
15     //~^ NOTE: expected this to be `()`
16         x?
17         //~^ ERROR: mismatched types [E0308]
18         //~| NOTE: expected `()`, found integer
19         //~| HELP: consider using a semicolon here
20     }
21     //~^ HELP: consider using a semicolon here
22
23     Ok(())
24 }
25
26 fn a<F>(f: F) -> Result<(), ()> where F: FnMut() { Ok(()) }
27 fn b() -> i32 { 42 }