]>
Commit | Line | Data |
---|---|---|
416331ca XL |
1 | // run-pass |
2 | ||
0bf4aa26 XL |
3 | #![allow(dead_code)] |
4 | #![allow(unused_assignments)] | |
5 | #![allow(unused_variables)] | |
6a06907d XL |
6 | // revisions: min_tait full_tait |
7 | #![feature(min_type_alias_impl_trait)] | |
8 | #![cfg_attr(full_tait, feature(type_alias_impl_trait))] | |
9 | //[full_tait]~^ WARN incomplete | |
8faf50e0 XL |
10 | |
11 | fn main() { | |
12 | assert_eq!(foo().to_string(), "foo"); | |
13 | assert_eq!(bar1().to_string(), "bar1"); | |
14 | assert_eq!(bar2().to_string(), "bar2"); | |
15 | let mut x = bar1(); | |
16 | x = bar2(); | |
17 | assert_eq!(boo::boo().to_string(), "boo"); | |
18 | assert_eq!(my_iter(42u8).collect::<Vec<u8>>(), vec![42u8]); | |
19 | } | |
20 | ||
21 | // single definition | |
416331ca | 22 | type Foo = impl std::fmt::Display; |
8faf50e0 XL |
23 | |
24 | fn foo() -> Foo { | |
25 | "foo" | |
26 | } | |
27 | ||
28 | // two definitions | |
416331ca | 29 | type Bar = impl std::fmt::Display; |
8faf50e0 XL |
30 | |
31 | fn bar1() -> Bar { | |
32 | "bar1" | |
33 | } | |
34 | ||
35 | fn bar2() -> Bar { | |
36 | "bar2" | |
37 | } | |
38 | ||
39 | // definition in submodule | |
416331ca | 40 | type Boo = impl std::fmt::Display; |
8faf50e0 XL |
41 | |
42 | mod boo { | |
43 | pub fn boo() -> super::Boo { | |
44 | "boo" | |
45 | } | |
46 | } | |
47 | ||
416331ca | 48 | type MyIter<T> = impl Iterator<Item = T>; |
8faf50e0 XL |
49 | |
50 | fn my_iter<T>(t: T) -> MyIter<T> { | |
51 | std::iter::once(t) | |
52 | } | |
53 | ||
54 | fn my_iter2<T>(t: T) -> MyIter<T> { | |
55 | std::iter::once(t) | |
56 | } | |
57 | ||
58 | // param names should not have an effect! | |
59 | fn my_iter3<U>(u: U) -> MyIter<U> { | |
60 | std::iter::once(u) | |
61 | } | |
62 | ||
63 | // param position should not have an effect! | |
64 | fn my_iter4<U, V>(_: U, v: V) -> MyIter<V> { | |
65 | std::iter::once(v) | |
66 | } | |
67 | ||
68 | // param names should not have an effect! | |
416331ca | 69 | type MyOtherIter<T> = impl Iterator<Item = T>; |
8faf50e0 XL |
70 | |
71 | fn my_other_iter<U>(u: U) -> MyOtherIter<U> { | |
72 | std::iter::once(u) | |
73 | } | |
74 | ||
75 | trait Trait {} | |
29967ef6 | 76 | type GenericBound<'a, T: Trait + 'a> = impl Sized + 'a; |
8faf50e0 XL |
77 | |
78 | fn generic_bound<'a, T: Trait + 'a>(t: T) -> GenericBound<'a, T> { | |
79 | t | |
80 | } | |
81 | ||
82 | mod pass_through { | |
29967ef6 | 83 | pub type Passthrough<T: 'static> = impl Sized + 'static; |
8faf50e0 XL |
84 | |
85 | fn define_passthrough<T: 'static>(t: T) -> Passthrough<T> { | |
86 | t | |
87 | } | |
88 | } | |
89 | ||
90 | fn use_passthrough(x: pass_through::Passthrough<u32>) -> pass_through::Passthrough<u32> { | |
91 | x | |
92 | } |