]> git.lizzy.rs Git - rust.git/blob - src/test/ui/feature-gates/feature-gate-trivial_bounds.rs
parser will not give wrong help message for 'public'
[rust.git] / src / test / ui / feature-gates / feature-gate-trivial_bounds.rs
1 #![allow(unused)]
2 #![allow(type_alias_bounds)]
3
4 pub trait Foo {
5     fn test(&self);
6 }
7
8 fn generic_function<X: Foo>(x: X) {}
9
10 enum E where i32: Foo { V } //~ ERROR
11
12 struct S where i32: Foo; //~ ERROR
13
14 trait T where i32: Foo {} //~ ERROR
15
16 union U where i32: Foo { f: i32 } //~ ERROR
17
18 type Y where i32: Foo = (); // OK - bound is ignored
19
20 impl Foo for () where i32: Foo { //~ ERROR
21     fn test(&self) {
22         3i32.test();
23         Foo::test(&4i32);
24         generic_function(5i32);
25     }
26 }
27
28 fn f() where i32: Foo //~ ERROR
29 {
30     let s = S;
31     3i32.test();
32     Foo::test(&4i32);
33     generic_function(5i32);
34 }
35
36 fn use_op(s: String) -> String where String: ::std::ops::Neg<Output=String> { //~ ERROR
37     -s
38 }
39
40 fn use_for() where i32: Iterator { //~ ERROR
41     for _ in 2i32 {}
42 }
43
44 trait A {}
45
46 impl A for i32 {}
47
48 struct Dst<X: ?Sized> {
49     x: X,
50 }
51
52 struct TwoStrs(str, str) where str: Sized; //~ ERROR
53
54
55 fn unsized_local() where Dst<dyn A>: Sized { //~ ERROR
56     let x: Dst<dyn A> = *(Box::new(Dst { x: 1 }) as Box<Dst<dyn A>>);
57 }
58
59 fn return_str() -> str where str: Sized { //~ ERROR
60     *"Sized".to_string().into_boxed_str()
61 }
62
63 // This is currently accepted because the function pointer isn't
64 // considered global.
65 fn global_hr(x: fn(&())) where fn(&()): Foo { // OK
66     x.test();
67 }
68
69 fn main() {}