]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/return-bindings.rs
Rollup merge of #106670 - albertlarsan68:check-docs-in-pr-ci, r=Mark-Simulacrum
[rust.git] / tests / ui / suggestions / return-bindings.rs
1 #![allow(unused)]
2
3 fn a(i: i32) -> i32 {}
4 //~^ ERROR mismatched types
5
6 fn b(opt_str: Option<String>) {
7     let s: String = if let Some(s) = opt_str {
8         //~^ ERROR mismatched types
9     } else {
10         String::new()
11     };
12 }
13
14 fn c() -> Option<i32> {
15     //~^ ERROR mismatched types
16     let x = Some(1);
17 }
18
19 fn d(opt_str: Option<String>) {
20     let s: String = if let Some(s) = opt_str {
21         //~^ ERROR mismatched types
22     } else {
23         String::new()
24     };
25 }
26
27 fn d2(opt_str: Option<String>) {
28     let s = if let Some(s) = opt_str {
29     } else {
30         String::new()
31         //~^ ERROR `if` and `else` have incompatible types
32     };
33 }
34
35 fn e(opt_str: Option<String>) {
36     let s: String = match opt_str {
37         Some(s) => {}
38         //~^ ERROR mismatched types
39         None => String::new(),
40     };
41 }
42
43 fn e2(opt_str: Option<String>) {
44     let s = match opt_str {
45         Some(s) => {}
46         None => String::new(),
47         //~^ ERROR `match` arms have incompatible types
48     };
49 }
50
51 fn main() {}