]> git.proxmox.com Git - rustc.git/blame - src/test/ui/specialization/auxiliary/cross_crates_defaults.rs
New upstream version 1.40.0+dfsg1
[rustc.git] / src / test / ui / specialization / auxiliary / cross_crates_defaults.rs
CommitLineData
54a0048b
SL
1#![feature(specialization)]
2
3// First, test only use of explicit `default` items:
4
5pub trait Foo {
6 fn foo(&self) -> bool;
7}
8
9impl<T> Foo for T {
10 default fn foo(&self) -> bool { false }
11}
12
13impl Foo for i32 {}
14
15impl Foo for i64 {
16 fn foo(&self) -> bool { true }
17}
18
19// Next, test mixture of explicit `default` and provided methods:
20
21pub trait Bar {
22 fn bar(&self) -> i32 { 0 }
23}
24
e74abb32
XL
25impl<T> Bar for T {
26 default fn bar(&self) -> i32 { 0 }
27}
54a0048b
SL
28
29impl Bar for i32 {
30 fn bar(&self) -> i32 { 1 }
31}
32impl<'a> Bar for &'a str {}
33
34impl<T> Bar for Vec<T> {
35 default fn bar(&self) -> i32 { 2 }
36}
37impl Bar for Vec<i32> {}
38impl Bar for Vec<i64> {
39 fn bar(&self) -> i32 { 3 }
40}