]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/kindck-impl-type-params.rs
Auto merge of #22517 - brson:relnotes, r=Gankro
[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 #![feature(box_syntax)]
15
16 struct S<T>;
17
18 trait Gettable<T> {}
19
20 impl<T: Send + Copy + 'static> Gettable<T> for S<T> {}
21
22 fn f<T>(val: T) {
23     let t: S<T> = S;
24     let a = &t as &Gettable<T>;
25     //~^ ERROR the trait `core::marker::Send` is not implemented
26     //~^^ ERROR the trait `core::marker::Copy` is not implemented
27 }
28
29 fn g<T>(val: T) {
30     let t: S<T> = S;
31     let a: &Gettable<T> = &t;
32     //~^ ERROR the trait `core::marker::Send` is not implemented
33     //~^^ ERROR the trait `core::marker::Copy` is not implemented
34 }
35
36 fn foo<'a>() {
37     let t: S<&'a isize> = S;
38     let a = &t as &Gettable<&'a isize>;
39     //~^ ERROR the type `&'a isize` does not fulfill the required lifetime
40 }
41
42 fn foo2<'a>() {
43     let t: Box<S<String>> = box S;
44     let a = t as Box<Gettable<String>>;
45     //~^ ERROR the trait `core::marker::Copy` is not implemented
46 }
47
48 fn foo3<'a>() {
49     let t: Box<S<String>> = box S;
50     let a: Box<Gettable<String>> = t;
51     //~^ ERROR the trait `core::marker::Copy` is not implemented
52 }
53
54 fn main() { }