]> git.lizzy.rs Git - rust.git/blob - tests/ui/trivial-bounds/issue-73021-impossible-inline.rs
Rollup merge of #106618 - jmillikin:os-net-rustdoc-wasm32, r=JohnTitor
[rust.git] / tests / ui / trivial-bounds / issue-73021-impossible-inline.rs
1 // build-pass
2 // revisions: no-opt inline
3 // [inline]compile-flags: -Zmir-opt-level=3 --emit=mir
4 #![feature(trivial_bounds)]
5 #![allow(unused)]
6
7 trait Foo {
8     fn test(&self);
9 }
10
11 fn foo<'a>(s: &'a mut ())
12 where
13     &'a mut (): Foo,
14 {
15     s.test();
16 }
17
18 fn clone(it: &mut ()) -> &mut ()
19 where
20     for<'any> &'any mut (): Clone,
21     //~^ WARN trait bound for<'any> &'any mut (): Clone does not depend on any type or lifetime parameters
22 {
23     it.clone()
24 }
25
26 fn generic_function<X: Foo>(x: X) {}
27
28 struct S where i32: Foo;
29 //~^ WARN trait bound i32: Foo does not depend on any type or lifetime parameters
30
31 impl Foo for () where i32: Foo {
32 //~^ WARN trait bound i32: Foo does not depend on any type or lifetime parameters
33     fn test(&self) {
34         3i32.test();
35         Foo::test(&4i32);
36         generic_function(5i32);
37     }
38 }
39
40 fn f() where i32: Foo {
41 //~^ WARN trait bound i32: Foo does not depend on any type or lifetime parameters
42     let s = S;
43     3i32.test();
44     Foo::test(&4i32);
45     generic_function(5i32);
46 }
47
48 fn g() where &'static str: Foo {
49 //~^ WARN trait bound &'static str: Foo does not depend on any type or lifetime parameters
50     "Foo".test();
51     Foo::test(&"Foo");
52     generic_function("Foo");
53 }
54
55 fn use_op(s: String) -> String
56 where
57     String: ::std::ops::Neg<Output = String>,
58 //~^ WARN trait bound String: Neg does not depend on any type or lifetime parameters
59 {
60     -s
61 }
62
63 fn use_for()
64 where
65     i32: Iterator,
66 //~^ WARN trait bound i32: Iterator does not depend on any type or lifetime parameters
67 {
68     for _ in 2i32 {}
69 }
70
71 fn main() {}