]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/kindck-impl-type-params.rs
rollup merge of #17355 : gamazeps/issue17210
[rust.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 struct S<T>;
15
16 trait Gettable<T> {}
17
18 impl<T: Send + Copy> Gettable<T> for S<T> {}
19
20 fn f<T>(val: T) {
21     let t: S<T> = S;
22     let a = &t as &Gettable<T>;
23     //~^ ERROR the trait `core::kinds::Send` is not implemented
24     //~^^ ERROR the trait `core::kinds::Copy` is not implemented
25     let a: &Gettable<T> = &t;
26     //~^ ERROR the trait `core::kinds::Send` is not implemented
27     //~^^ ERROR the trait `core::kinds::Copy` is not implemented
28 }
29
30 fn foo<'a>() {
31     let t: S<&'a int> = S;
32     let a = &t as &Gettable<&'a int>;
33     let t: Box<S<String>> = box S;
34     let a = t as Box<Gettable<String>>;
35     //~^ ERROR the trait `core::kinds::Copy` is not implemented
36     let t: Box<S<String>> = box S;
37     let a: Box<Gettable<String>> = t;
38     //~^ ERROR the trait `core::kinds::Copy` is not implemented
39 }
40
41 fn main() { }