]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nested_impl_trait.rs
Auto merge of #60132 - davidtwco:issue-60075, r=estebank
[rust.git] / src / test / ui / nested_impl_trait.rs
1 use std::fmt::Debug;
2
3 fn fine(x: impl Into<u32>) -> impl Into<u32> { x }
4
5 fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x }
6 //~^ ERROR nested `impl Trait` is not allowed
7
8 fn bad_in_fn_syntax(x: fn() -> impl Into<impl Debug>) {}
9 //~^ ERROR nested `impl Trait` is not allowed
10 //~^^ `impl Trait` not allowed
11
12 fn bad_in_arg_position(_: impl Into<impl Debug>) { }
13 //~^ ERROR nested `impl Trait` is not allowed
14
15 struct X;
16 impl X {
17     fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x }
18     //~^ ERROR nested `impl Trait` is not allowed
19 }
20
21 fn allowed_in_assoc_type() -> impl Iterator<Item=impl Fn()> {
22     vec![|| println!("woot")].into_iter()
23 }
24
25 fn allowed_in_ret_type() -> impl Fn() -> impl Into<u32> {
26 //~^ `impl Trait` not allowed
27     || 5
28 }
29
30 fn main() {}