]> git.lizzy.rs Git - rust.git/blob - tests/ui/impl-trait/cross-return-site-inference.rs
Rollup merge of #106427 - mejrs:translation_errors, r=davidtwco
[rust.git] / tests / 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(())
34     //~^ ERROR type annotations needed
35 }
36
37 fn muh2() -> Result<(), impl std::fmt::Debug> {
38     return Err(From::from("foo"));
39     //~^ ERROR type annotations needed
40     Ok(())
41 }
42
43 fn muh3() -> Result<(), impl std::fmt::Debug> {
44     Err(From::from("foo"))
45     //~^ ERROR type annotations needed
46 }
47
48 fn main() {}