]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/cross-return-site-inference.rs
d881af9ed8fe13c655fed5ecff9544c72fbb4bf1
[rust.git] / src / test / ui / impl-trait / cross-return-site-inference.rs
1 // edition:2021
2
3 fn foo(b: bool) -> impl std::fmt::Debug {
4     if b {
5         return vec![42]
6     }
7     [].into_iter().collect()
8 }
9
10 fn bar(b: bool) -> impl std::fmt::Debug {
11     if b {
12         return [].into_iter().collect()
13     }
14     vec![42]
15 }
16
17 fn bak(b: bool) -> impl std::fmt::Debug {
18     if b {
19         return std::iter::empty().collect()
20     }
21     vec![42]
22 }
23
24 fn baa(b: bool) -> impl std::fmt::Debug {
25     if b {
26         return [42].into_iter().collect()
27     }
28     vec![]
29 }
30
31 fn muh() -> Result<(), impl std::fmt::Debug> {
32     Err("whoops")?;
33     Ok(()) //~ ERROR type annotations needed
34 }
35
36 fn muh2() -> Result<(), impl std::fmt::Debug> {
37     return Err(From::from("foo")); //~ ERROR type annotations needed
38     Ok(())
39 }
40
41 fn muh3() -> Result<(), impl std::fmt::Debug> {
42     Err(From::from("foo")) //~ ERROR type annotations needed
43 }
44
45 fn main() {}