Graydon Hoare | d1affff | 2012-12-11 01:32:48 | [diff] [blame] | 1 | // Copyright 2012 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 | |
Brian Anderson | 78ee821 | 2012-11-28 20:34:30 | [diff] [blame] | 11 | // xfail-fast |
| 12 | // aux-build:trait_inheritance_auto_xc_2_aux.rs |
| 13 | |
| 14 | extern mod aux(name = "trait_inheritance_auto_xc_2_aux"); |
| 15 | |
| 16 | // aux defines impls of Foo, Bar and Baz for A |
| 17 | use aux::{Foo, Bar, Baz, A}; |
| 18 | |
| 19 | // We want to extend all Foo, Bar, Bazes to Quuxes |
Patrick Walton | 6d4ed52 | 2013-03-05 00:11:30 | [diff] [blame] | 20 | pub trait Quux: Foo + Bar + Baz { } |
Patrick Walton | bf2a225 | 2013-02-21 01:07:17 | [diff] [blame] | 21 | impl<T:Foo + Bar + Baz> Quux for T { } |
Brian Anderson | 78ee821 | 2012-11-28 20:34:30 | [diff] [blame] | 22 | |
Patrick Walton | bf2a225 | 2013-02-21 01:07:17 | [diff] [blame] | 23 | fn f<T:Quux>(a: &T) { |
Corey Richardson | cc57ca0 | 2013-05-19 02:02:45 | [diff] [blame] | 24 | assert_eq!(a.f(), 10); |
| 25 | assert_eq!(a.g(), 20); |
| 26 | assert_eq!(a.h(), 30); |
Brian Anderson | 78ee821 | 2012-11-28 20:34:30 | [diff] [blame] | 27 | } |
| 28 | |
Graydon Hoare | 89c8ef7 | 2013-02-02 03:43:17 | [diff] [blame] | 29 | pub fn main() { |
Brian Anderson | 78ee821 | 2012-11-28 20:34:30 | [diff] [blame] | 30 | let a = &A { x: 3 }; |
| 31 | f(a); |
| 32 | } |