blob: 72a6599c326966018eaf58a2d931774f413d3298 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// Issue #14061: tests the interaction between generic implementation
// parameter bounds and trait objects.
use std::marker;
struct S<T>(marker::PhantomData<T>);
trait Gettable<T> {
fn get(&self) -> T { panic!() }
}
impl<T: Send + Copy + 'static> Gettable<T> for S<T> {}
fn f<T>(val: T) {
let t: S<T> = S(marker::PhantomData);
let a = &t as &dyn Gettable<T>;
//~^ ERROR `T` cannot be sent between threads safely
//~| ERROR : Copy` is not satisfied
}
fn g<T>(val: T) {
let t: S<T> = S(marker::PhantomData);
let a: &dyn Gettable<T> = &t;
//~^ ERROR `T` cannot be sent between threads safely
//~| ERROR : Copy` is not satisfied
}
fn foo<'a>() {
let t: S<&'a isize> = S(marker::PhantomData);
let a = &t as &dyn Gettable<&'a isize>;
}
fn foo2<'a>() {
let t: Box<S<String>> = Box::new(S(marker::PhantomData));
let a = t as Box<dyn Gettable<String>>;
//~^ ERROR : Copy` is not satisfied
}
fn foo3<'a>() {
struct Foo; // does not impl Copy
let t: Box<S<Foo>> = Box::new(S(marker::PhantomData));
let a: Box<dyn Gettable<Foo>> = t;
//~^ ERROR : Copy` is not satisfied
}
fn main() { }
|