]> git.lizzy.rs Git - rust.git/blob - src/test/ui/trivial-bounds-inconsistent.rs
Reenable trivial bounds
[rust.git] / src / test / ui / trivial-bounds-inconsistent.rs
1 // Copyright 2018 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 // run-pass
12
13 // Check that tautalogically false bounds are accepted, and are used
14 // in type inference.
15 #![feature(trivial_bounds)]
16 #![allow(unused)]
17
18 pub trait Foo {
19     fn test(&self);
20 }
21
22 fn generic_function<X: Foo>(x: X) {}
23
24 enum E where i32: Foo { V }
25
26 struct S where i32: Foo;
27
28 trait T where i32: Foo {}
29
30 union U where i32: Foo { f: i32 }
31
32 type Y where i32: Foo = ();
33
34 impl Foo for () where i32: Foo {
35     fn test(&self) {
36         3i32.test();
37         Foo::test(&4i32);
38         generic_function(5i32);
39     }
40 }
41
42 fn f() where i32: Foo {
43     let s = S;
44     3i32.test();
45     Foo::test(&4i32);
46     generic_function(5i32);
47 }
48
49 fn g() where &'static str: Foo {
50     "Foo".test();
51     Foo::test(&"Foo");
52     generic_function("Foo");
53 }
54
55 trait A {}
56
57 impl A for i32 {}
58
59 struct Dst<X: ?Sized> {
60     x: X,
61 }
62
63 struct TwoStrs(str, str) where str: Sized;
64
65 fn unsized_local() where for<'a> Dst<A + 'a>: Sized {
66     let x: Dst<A> = *(Box::new(Dst { x: 1 }) as Box<Dst<A>>);
67 }
68
69 fn return_str() -> str where str: Sized {
70     *"Sized".to_string().into_boxed_str()
71 }
72
73 fn use_op(s: String) -> String where String: ::std::ops::Neg<Output=String> {
74     -s
75 }
76
77 fn use_for() where i32: Iterator {
78     for _ in 2i32 {}
79 }
80
81 fn main() {}