2019-07-13 14:52:57 -05:00
|
|
|
// run-pass
|
|
|
|
|
|
|
|
// rpass test for reservation impls. Not 100% required because `From` uses them,
|
|
|
|
// but still.
|
|
|
|
|
2023-03-21 10:26:23 -05:00
|
|
|
// revisions: old next
|
|
|
|
//[next] compile-flags: -Ztrait-solver=next
|
|
|
|
|
2019-07-13 14:52:57 -05:00
|
|
|
#![feature(rustc_attrs)]
|
|
|
|
|
|
|
|
use std::mem;
|
|
|
|
|
|
|
|
trait MyTrait<S> {
|
|
|
|
fn foo(&self, s: S) -> usize;
|
|
|
|
}
|
|
|
|
|
2019-07-27 14:18:34 -05:00
|
|
|
#[rustc_reservation_impl = "foo"]
|
2019-07-13 14:52:57 -05:00
|
|
|
impl<T> MyTrait<u64> for T {
|
|
|
|
fn foo(&self, _x: u64) -> usize { 0 }
|
|
|
|
}
|
|
|
|
|
|
|
|
// reservation impls don't create coherence conflicts, even with
|
|
|
|
// non-chain overlap.
|
|
|
|
impl<S> MyTrait<S> for u32 {
|
|
|
|
fn foo(&self, _x: S) -> usize { mem::size_of::<S>() }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// ...and the non-reservation impl gets picked.XS
|
|
|
|
assert_eq!(0u32.foo(0u64), mem::size_of::<u64>());
|
|
|
|
}
|