]> git.lizzy.rs Git - rust.git/blob - tests/ui/impl-trait/nested_impl_trait.rs
Auto merge of #106171 - compiler-errors:consolidate-extract_callable_info, r=estebank...
[rust.git] / tests / ui / impl-trait / nested_impl_trait.rs
1 #![feature(impl_trait_in_fn_trait_return)]
2 use std::fmt::Debug;
3
4 fn fine(x: impl Into<u32>) -> impl Into<u32> { x }
5
6 fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x }
7 //~^ ERROR nested `impl Trait` is not allowed
8 //~| ERROR the trait bound `impl Debug: From<impl Into<u32>>` is not satisfied
9
10 fn bad_in_fn_syntax(x: fn() -> impl Into<impl Debug>) {}
11 //~^ ERROR nested `impl Trait` is not allowed
12 //~| `impl Trait` only allowed in function and inherent method return types
13
14 fn bad_in_arg_position(_: impl Into<impl Debug>) { }
15 //~^ ERROR nested `impl Trait` is not allowed
16
17 struct X;
18 impl X {
19     fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x }
20     //~^ ERROR nested `impl Trait` is not allowed
21     //~| ERROR the trait bound `impl Debug: From<impl Into<u32>>` is not satisfied
22 }
23
24 fn allowed_in_assoc_type() -> impl Iterator<Item=impl Fn()> {
25     vec![|| println!("woot")].into_iter()
26 }
27
28 fn allowed_in_ret_type() -> impl Fn() -> impl Into<u32> {
29     || 5u8
30 }
31
32 fn main() {}