4 #![allow(unused_assignments)]
5 #![allow(unused_variables)]
6 #![feature(type_alias_impl_trait)]
9 assert_eq!(foo().to_string(), "foo");
10 assert_eq!(bar1().to_string(), "bar1");
11 assert_eq!(bar2().to_string(), "bar2");
14 assert_eq!(my_iter(42u8).collect::<Vec<u8>>(), vec![42u8]);
17 use defining_use_scope::*;
19 mod defining_use_scope {
21 pub type Foo = impl std::fmt::Display;
28 pub type Bar = impl std::fmt::Display;
30 pub fn bar1() -> Bar {
34 pub fn bar2() -> Bar {
38 pub type MyIter<T> = impl Iterator<Item = T>;
40 pub fn my_iter<T>(t: T) -> MyIter<T> {
44 fn my_iter2<T>(t: T) -> MyIter<T> {
48 // param names should not have an effect!
49 fn my_iter3<U>(u: U) -> MyIter<U> {
53 // param position should not have an effect!
54 fn my_iter4<U, V>(_: U, v: V) -> MyIter<V> {
58 // param names should not have an effect!
59 type MyOtherIter<T> = impl Iterator<Item = T>;
61 fn my_other_iter<U>(u: U) -> MyOtherIter<U> {
66 type GenericBound<'a, T: Trait + 'a> = impl Sized + 'a;
68 fn generic_bound<'a, T: Trait + 'a>(t: T) -> GenericBound<'a, T> {
73 pub type Passthrough<T: 'static> = impl Sized + 'static;
75 fn define_passthrough<T: 'static>(t: T) -> Passthrough<T> {
80 fn use_passthrough(x: pass_through::Passthrough<u32>) -> pass_through::Passthrough<u32> {