]> git.lizzy.rs Git - rust.git/blob - tests/ui/trivial-bounds/trivial-bounds-lint.rs
Rollup merge of #107757 - clubby789:setup-settings-json, r=jyn514
[rust.git] / tests / ui / trivial-bounds / trivial-bounds-lint.rs
1 #![feature(trivial_bounds)]
2 #![allow(unused)]
3 #![deny(trivial_bounds)]
4
5 struct A where i32: Copy; //~ ERROR
6
7 trait X<T: Copy> {}
8
9 trait Y<T>: Copy {}
10
11 trait Z {
12     type S: Copy;
13 }
14
15 // Check only the bound the user writes trigger the lint
16 fn trivial_elaboration<T>() where T: X<i32> + Z<S = i32>, i32: Y<T> {} // OK
17
18 fn global_param() where i32: X<()> {} //~ ERROR
19
20 // Should only error on the trait bound, not the implicit
21 // projection bound <i32 as Z>::S == i32.
22 fn global_projection() where i32: Z<S = i32> {} //~ ERROR
23
24 impl A {
25     fn new() -> A { A }
26 }
27
28 // Lifetime bounds should be linted as well
29 fn global_lifetimes() where i32: 'static, &'static str: 'static {}
30 //~^ ERROR
31 //~| ERROR
32
33 fn local_lifetimes<'a>() where i32: 'a, &'a str: 'a {} // OK
34
35 fn global_outlives() where 'static: 'static {} //~ ERROR
36
37 // Check that each bound is checked individually
38 fn mixed_bounds<T: Copy>() where i32: X<T> + Copy {} //~ ERROR
39
40 fn main() {}