]> git.lizzy.rs Git - rust.git/blob - src/test/ui/feature-gates/feature-gate-type_alias_impl_trait.rs
Merge commit 'd556c56f792756dd7cfec742b9f2e07612dc10f4' into sync_cg_clif-2021-02-01
[rust.git] / src / test / ui / feature-gates / feature-gate-type_alias_impl_trait.rs
1 // ignore-compare-mode-chalk
2 use std::fmt::Debug;
3
4 type Foo = impl Debug; //~ ERROR `impl Trait` in type aliases is unstable
5
6 trait Bar {
7     type Baa: Debug;
8     fn define() -> Self::Baa;
9 }
10
11 impl Bar for () {
12     type Baa = impl Debug; //~ ERROR `impl Trait` in type aliases is unstable
13     fn define() -> Self::Baa {
14         0
15     }
16 }
17
18 fn define() -> Foo {
19     0
20 }
21
22 trait TraitWithDefault {
23     type Assoc = impl Debug;
24     //~^ ERROR associated type defaults are unstable
25     //~| ERROR `impl Trait` not allowed outside of function
26     //~| ERROR `impl Trait` in type aliases is unstable
27 }
28
29 type NestedFree = (Vec<impl Debug>, impl Debug, impl Iterator<Item = impl Debug>);
30 //~^ ERROR `impl Trait` in type aliases is unstable
31 //~| ERROR `impl Trait` in type aliases is unstable
32 //~| ERROR `impl Trait` in type aliases is unstable
33 //~| ERROR `impl Trait` in type aliases is unstable
34
35 fn define_multiple() -> NestedFree {
36     (vec![true], 0u8, 0i32..1)
37 }
38
39 impl Bar for u8 {
40     type Baa = (Vec<impl Debug>, impl Debug, impl Iterator<Item = impl Debug> + Debug);
41     //~^ ERROR `impl Trait` in type aliases is unstable
42     //~| ERROR `impl Trait` in type aliases is unstable
43     //~| ERROR `impl Trait` in type aliases is unstable
44     //~| ERROR `impl Trait` in type aliases is unstable
45     fn define() -> Self::Baa {
46         (vec![true], 0u8, 0i32..1)
47     }
48 }
49
50 fn main() {}