]> git.lizzy.rs Git - rust.git/blob - src/test/ui/impl-trait/nested_impl_trait.rs
Rollup merge of #98441 - calebzulawski:simd_as, r=oli-obk
[rust.git] / src / test / ui / impl-trait / 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 //~| ERROR the trait bound `impl Debug: From<impl Into<u32>>` is not satisfied
8
9 fn bad_in_fn_syntax(x: fn() -> impl Into<impl Debug>) {}
10 //~^ ERROR nested `impl Trait` is not allowed
11 //~| `impl Trait` only allowed in function and inherent method return types
12
13 fn bad_in_arg_position(_: impl Into<impl Debug>) { }
14 //~^ ERROR nested `impl Trait` is not allowed
15
16 struct X;
17 impl X {
18     fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x }
19     //~^ ERROR nested `impl Trait` is not allowed
20     //~| ERROR the trait bound `impl Debug: From<impl Into<u32>>` is not satisfied
21 }
22
23 fn allowed_in_assoc_type() -> impl Iterator<Item=impl Fn()> {
24     vec![|| println!("woot")].into_iter()
25 }
26
27 fn allowed_in_ret_type() -> impl Fn() -> impl Into<u32> {
28 //~^ `impl Trait` only allowed in function and inherent method return types
29     || 5
30 }
31
32 fn main() {}