]> git.lizzy.rs Git - rust.git/blob - src/test/ui/trivial-bounds-lint.rs
e37600a653a90a5c8c9ec9c5a4f781ec0fbd1924
[rust.git] / src / test / ui / trivial-bounds-lint.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 // ignore-test FIXME(#50825)
12 #![feature(trivial_bounds)]
13 #![allow(unused)]
14 #![deny(trivial_bounds)]
15
16 struct A where i32: Copy; //~ ERROR
17
18 trait X<T: Copy> {}
19
20 trait Y<T>: Copy {}
21
22 trait Z {
23     type S: Copy;
24 }
25
26 // Check only the bound the user writes trigger the lint
27 fn trivial_elaboration<T>() where T: X<i32> + Z<S = i32>, i32: Y<T> {} // OK
28
29 fn global_param() where i32: X<()> {} //~ ERROR
30
31 // Should only error on the trait bound, not the implicit
32 // projection bound <i32 as Z>::S == i32.
33 fn global_projection() where i32: Z<S = i32> {} //~ ERROR
34
35 impl A {
36     fn new() -> A { A }
37 }
38
39 // Lifetime bounds should be linted as well
40 fn global_lifetimes() where i32: 'static, &'static str: 'static {}
41 //~^ ERROR
42 //~| ERROR
43
44 fn local_lifetimes<'a>() where i32: 'a, &'a str: 'a {} // OK
45
46 fn global_outlives() where 'static: 'static {} //~ ERROR
47
48 // Check that each bound is checked individually
49 fn mixed_bounds<T: Copy>() where i32: X<T> + Copy {} //~ ERROR
50
51 fn main() {}