]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/kindck-impl-type-params.rs
Imported Upstream version 1.2.0+dfsg1
[rustc.git] / src / test / compile-fail / kindck-impl-type-params.rs
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
11 // Issue #14061: tests the interaction between generic implementation
12 // parameter bounds and trait objects.
13
14 #![feature(box_syntax)]
15
16 use std::marker;
17
18 struct S<T>(marker::PhantomData<T>);
19
20 trait Gettable<T> {
21 fn get(&self) -> T { panic!() }
22 }
23
24 impl<T: Send + Copy + 'static> Gettable<T> for S<T> {}
25
26 fn f<T>(val: T) {
27 let t: S<T> = S(marker::PhantomData);
28 let a = &t as &Gettable<T>;
29 //~^ ERROR the trait `core::marker::Send` is not implemented
30 //~^^ ERROR the trait `core::marker::Copy` is not implemented
31 }
32
33 fn g<T>(val: T) {
34 let t: S<T> = S(marker::PhantomData);
35 let a: &Gettable<T> = &t;
36 //~^ ERROR the trait `core::marker::Send` is not implemented
37 //~^^ ERROR the trait `core::marker::Copy` is not implemented
38 }
39
40 fn foo<'a>() {
41 let t: S<&'a isize> = S(marker::PhantomData);
42 let a = &t as &Gettable<&'a isize>;
43 //~^ ERROR does not fulfill
44 }
45
46 fn foo2<'a>() {
47 let t: Box<S<String>> = box S(marker::PhantomData);
48 let a = t as Box<Gettable<String>>;
49 //~^ ERROR the trait `core::marker::Copy` is not implemented
50 }
51
52 fn foo3<'a>() {
53 struct Foo; // does not impl Copy
54
55 let t: Box<S<Foo>> = box S(marker::PhantomData);
56 let a: Box<Gettable<Foo>> = t;
57 //~^ ERROR the trait `core::marker::Copy` is not implemented
58 }
59
60 fn main() { }