]> git.lizzy.rs Git - rust.git/blob - tests/ui/specialization/specialization-projection.rs
Rollup merge of #106701 - ibraheemdev:sync-sender-spin, r=Amanieu
[rust.git] / tests / ui / specialization / specialization-projection.rs
1 // run-pass
2 #![allow(dead_code)]
3
4 #![feature(specialization)] //~ WARN the feature `specialization` is incomplete
5
6 // Make sure we *can* project non-defaulted associated types
7 // cf ui/specialization/specialization-default-projection.rs
8
9 // First, do so without any use of specialization
10
11 trait Foo {
12     type Assoc;
13 }
14
15 impl<T> Foo for T {
16     type Assoc = ();
17 }
18
19 fn generic_foo<T>() -> <T as Foo>::Assoc {
20     ()
21 }
22
23 // Next, allow for one layer of specialization
24
25 trait Bar {
26     type Assoc;
27 }
28
29 impl<T> Bar for T {
30     default type Assoc = ();
31 }
32
33 impl<T: Clone> Bar for T {
34     type Assoc = u8;
35 }
36
37 fn generic_bar_clone<T: Clone>() -> <T as Bar>::Assoc {
38     0u8
39 }
40
41 fn main() {
42 }