]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/kindck-impl-type-params.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / kindck-impl-type-params.rs
CommitLineData
1a4d82fc
JJ
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
85aaf69f 16use std::marker;
1a4d82fc 17
85aaf69f 18struct S<T>(marker::PhantomData<T>);
1a4d82fc 19
85aaf69f
SL
20trait Gettable<T> {
21 fn get(&self) -> T { panic!() }
22}
23
24impl<T: Send + Copy + 'static> Gettable<T> for S<T> {}
1a4d82fc
JJ
25
26fn f<T>(val: T) {
85aaf69f 27 let t: S<T> = S(marker::PhantomData);
1a4d82fc 28 let a = &t as &Gettable<T>;
54a0048b 29 //~^ ERROR : std::marker::Send` is not satisfied
1a4d82fc
JJ
30}
31
32fn g<T>(val: T) {
85aaf69f 33 let t: S<T> = S(marker::PhantomData);
1a4d82fc 34 let a: &Gettable<T> = &t;
54a0048b 35 //~^ ERROR : std::marker::Send` is not satisfied
1a4d82fc
JJ
36}
37
38fn foo<'a>() {
85aaf69f 39 let t: S<&'a isize> = S(marker::PhantomData);
1a4d82fc 40 let a = &t as &Gettable<&'a isize>;
9346a6ac 41 //~^ ERROR does not fulfill
1a4d82fc
JJ
42}
43
44fn foo2<'a>() {
85aaf69f 45 let t: Box<S<String>> = box S(marker::PhantomData);
1a4d82fc 46 let a = t as Box<Gettable<String>>;
54a0048b 47 //~^ ERROR : std::marker::Copy` is not satisfied
1a4d82fc
JJ
48}
49
50fn foo3<'a>() {
62682a34
SL
51 struct Foo; // does not impl Copy
52
53 let t: Box<S<Foo>> = box S(marker::PhantomData);
54 let a: Box<Gettable<Foo>> = t;
54a0048b 55 //~^ ERROR : std::marker::Copy` is not satisfied
1a4d82fc
JJ
56}
57
58fn main() { }