]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/method-two-traits-distinguished-via-where-clause.rs
d595092119059ebbc428d3c00851b9ced6a32256
[rust.git] / src / test / run-pass / method-two-traits-distinguished-via-where-clause.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // Test that we select between traits A and B. To do that, we must
12 // consider the `Sized` bound.
13
14 #![feature(core)]
15
16 trait A {
17     fn foo(self);
18 }
19
20 trait B {
21     fn foo(self);
22 }
23
24 impl<T: Sized> A for *const T {
25     fn foo(self) {}
26 }
27
28 impl<T> B for *const [T] {
29     fn foo(self) {}
30 }
31
32 fn main() {
33     let x: [int; 4] = [1,2,3,4];
34     let xptr = x.as_slice() as *const _;
35     xptr.foo();
36 }