]> git.lizzy.rs Git - rust.git/blob - src/test/ui/traits/reservation-impl/ok.rs
Rollup merge of #82179 - mbartlett21:patch-5, r=joshtriplett
[rust.git] / src / test / ui / traits / reservation-impl / ok.rs
1 // run-pass
2
3 // rpass test for reservation impls. Not 100% required because `From` uses them,
4 // but still.
5
6 #![feature(rustc_attrs)]
7
8 use std::mem;
9
10 trait MyTrait<S> {
11     fn foo(&self, s: S) -> usize;
12 }
13
14 #[rustc_reservation_impl = "foo"]
15 impl<T> MyTrait<u64> for T {
16     fn foo(&self, _x: u64) -> usize { 0 }
17 }
18
19 // reservation impls don't create coherence conflicts, even with
20 // non-chain overlap.
21 impl<S> MyTrait<S> for u32 {
22     fn foo(&self, _x: S) -> usize { mem::size_of::<S>() }
23 }
24
25 fn main() {
26     // ...and the non-reservation impl gets picked.XS
27     assert_eq!(0u32.foo(0u64), mem::size_of::<u64>());
28 }