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