]> git.lizzy.rs Git - rust.git/blob - src/test/ui/specialization/specialization-assoc-fns.rs
warn against 'specialization' feature
[rust.git] / src / test / ui / specialization / specialization-assoc-fns.rs
1 // run-pass
2
3 // Test that non-method associated functions can be specialized
4
5 #![feature(specialization)] //~ WARN the feature `specialization` is incomplete
6
7 trait Foo {
8     fn mk() -> Self;
9 }
10
11 impl<T: Default> Foo for T {
12     default fn mk() -> T {
13         T::default()
14     }
15 }
16
17 impl Foo for Vec<u8> {
18     fn mk() -> Vec<u8> {
19         vec![0]
20     }
21 }
22
23 fn main() {
24     let v1: Vec<i32> = Foo::mk();
25     let v2: Vec<u8> = Foo::mk();
26
27     assert!(v1.len() == 0);
28     assert!(v2.len() == 1);
29 }