]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/associated-type-projection-from-multiple-supertraits.rs
New upstream version 1.12.0+dfsg1
[rustc.git] / src / test / compile-fail / associated-type-projection-from-multiple-supertraits.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 equality constraints in a where clause where the type being
12 // equated appears in a supertrait.
13
14 pub trait Vehicle {
15 type Color;
16
17 fn go(&self) { }
18 }
19
20 pub trait Box {
21 type Color;
22
23 fn mail(&self) { }
24 }
25
26 pub trait BoxCar : Box + Vehicle {
27 }
28
29 fn dent<C:BoxCar>(c: C, color: C::Color) {
30 //~^ ERROR ambiguous associated type `Color` in bounds of `C`
31 //~| NOTE ambiguous associated type `Color`
32 //~| NOTE could derive from `Vehicle`
33 //~| NOTE could derive from `Box`
34 }
35
36 fn dent_object<COLOR>(c: BoxCar<Color=COLOR>) {
37 //~^ ERROR ambiguous associated type
38 //~| ERROR the value of the associated type `Color` (from the trait `Vehicle`) must be specified
39 //~| NOTE ambiguous associated type `Color`
40 //~| NOTE could derive from `Vehicle`
41 //~| NOTE could derive from `Box`
42 //~| NOTE missing associated type `Color` value
43 }
44
45 fn paint<C:BoxCar>(c: C, d: C::Color) {
46 //~^ ERROR ambiguous associated type `Color` in bounds of `C`
47 //~| NOTE ambiguous associated type `Color`
48 //~| NOTE could derive from `Vehicle`
49 //~| NOTE could derive from `Box`
50 }
51
52 pub fn main() { }