blob: ab3b28e84db5a31658aebf2a074f2fa76cd8b924 (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
//@ check-fail
#![feature(sized_hierarchy)]
use std::marker::{MetaSized, PointeeSized};
trait Sized_: Sized { }
trait NegSized: ?Sized { }
//~^ ERROR relaxed bounds are not permitted in supertrait bounds
trait MetaSized_: MetaSized { }
trait NegMetaSized: ?MetaSized { }
//~^ ERROR relaxed bounds are not permitted in supertrait bounds
trait PointeeSized_: PointeeSized { }
trait NegPointeeSized: ?PointeeSized { }
//~^ ERROR relaxed bounds are not permitted in supertrait bounds
trait Bare {}
fn requires_sized<T: Sized>() {}
fn requires_metasized<T: MetaSized>() {}
fn requires_pointeesized<T: PointeeSized>() {}
fn with_sized_supertrait<T: PointeeSized + Sized_>() {
requires_sized::<T>();
requires_metasized::<T>();
requires_pointeesized::<T>();
}
fn with_metasized_supertrait<T: PointeeSized + MetaSized_>() {
requires_sized::<T>();
//~^ ERROR the size for values of type `T` cannot be known at compilation time
requires_metasized::<T>();
requires_pointeesized::<T>();
}
// It isn't really possible to write this one..
fn with_pointeesized_supertrait<T: PointeeSized + PointeeSized_>() {
requires_sized::<T>();
//~^ ERROR the size for values of type `T` cannot be known
requires_metasized::<T>();
//~^ ERROR the size for values of type `T` cannot be known
requires_pointeesized::<T>();
}
// `T` won't inherit the `const MetaSized` implicit supertrait of `Bare`, so there is an error on
// the bound, which is expected.
fn with_bare_trait<T: PointeeSized + Bare>() {
//~^ ERROR the size for values of type `T` cannot be known
requires_sized::<T>();
//~^ ERROR the size for values of type `T` cannot be known
requires_metasized::<T>();
//~^ ERROR the size for values of type `T` cannot be known
requires_pointeesized::<T>();
}
fn main() { }
|