]> git.lizzy.rs Git - rust.git/blob - crates/hir_ty/src/tests/diagnostics.rs
Merge #11842
[rust.git] / crates / hir_ty / src / tests / diagnostics.rs
1 use super::check;
2
3 #[test]
4 fn function_return_type_mismatch_1() {
5     check(
6         r#"
7 fn test() -> &'static str {
8     5
9   //^ expected &str, got i32
10 }
11 "#,
12     );
13 }
14
15 #[test]
16 fn function_return_type_mismatch_2() {
17     check(
18         r#"
19 fn test(x: bool) -> &'static str {
20     if x {
21         return 1;
22              //^ expected &str, got i32
23     }
24     "ok"
25 }
26 "#,
27     );
28 }
29
30 #[test]
31 fn function_return_type_mismatch_3() {
32     check(
33         r#"
34 fn test(x: bool) -> &'static str {
35     if x {
36         return "ok";
37     }
38     1
39   //^ expected &str, got i32
40 }
41 "#,
42     );
43 }
44
45 #[test]
46 fn function_return_type_mismatch_4() {
47     check(
48         r#"
49 fn test(x: bool) -> &'static str {
50     if x {
51         "ok"
52     } else {
53         1
54       //^ expected &str, got i32
55     }
56 }
57 "#,
58     );
59 }
60
61 #[test]
62 fn function_return_type_mismatch_5() {
63     check(
64         r#"
65 fn test(x: bool) -> &'static str {
66     if x {
67         1
68       //^ expected &str, got i32
69     } else {
70         "ok"
71     }
72 }
73 "#,
74     );
75 }