]>
Commit | Line | Data |
---|---|---|
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 | 16 | use std::marker; |
1a4d82fc | 17 | |
85aaf69f | 18 | struct S<T>(marker::PhantomData<T>); |
1a4d82fc | 19 | |
85aaf69f SL |
20 | trait Gettable<T> { |
21 | fn get(&self) -> T { panic!() } | |
22 | } | |
23 | ||
24 | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} | |
1a4d82fc JJ |
25 | |
26 | fn 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 | ||
32 | fn 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 | ||
38 | fn 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 | ||
44 | fn 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 | ||
50 | fn 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 | ||
58 | fn main() { } |