]> git.proxmox.com Git - rustc.git/blame - src/test/rustdoc/higher-ranked-trait-bounds.rs
Update upstream source from tag 'upstream/1.60.0+dfsg1'
[rustc.git] / src / test / rustdoc / higher-ranked-trait-bounds.rs
CommitLineData
136023e0
XL
1#![crate_name = "foo"]
2
3// @has foo/trait.Trait.html
4pub trait Trait<'x> {}
5
6// @has foo/fn.test1.html
7// @has - '//pre' "pub fn test1<T>() where for<'a> &'a T: Iterator,"
8pub fn test1<T>()
9where
10 for<'a> &'a T: Iterator,
11{
12}
13
14// @has foo/fn.test2.html
15// @has - '//pre' "pub fn test2<T>() where for<'a, 'b> &'a T: Trait<'b>,"
16pub fn test2<T>()
17where
18 for<'a, 'b> &'a T: Trait<'b>,
19{
20}
21
22// @has foo/fn.test3.html
23// @has - '//pre' "pub fn test3<F>() where F: for<'a, 'b> Fn(&'a u8, &'b u8),"
24pub fn test3<F>()
25where
26 F: for<'a, 'b> Fn(&'a u8, &'b u8),
27{
28}
29
30// @has foo/struct.Foo.html
31pub struct Foo<'a> {
32 _x: &'a u8,
33 pub some_trait: &'a dyn for<'b> Trait<'b>,
34 pub some_func: for<'c> fn(val: &'c i32) -> i32,
35}
36
37// @has - '//span[@id="structfield.some_func"]' "some_func: for<'c> fn(val: &'c i32) -> i32"
38// @has - '//span[@id="structfield.some_trait"]' "some_trait: &'a dyn for<'b> Trait<'b>"
39
40impl<'a> Foo<'a> {
41 // @has - '//h4[@class="code-header"]' "pub fn bar<T>() where T: Trait<'a>,"
42 pub fn bar<T>()
43 where
44 T: Trait<'a>,
45 {
46 }
47}
48
49// @has foo/trait.B.html
50pub trait B<'x> {}
51
52// @has - '//h3[@class="code-header in-band"]' "impl<'a> B<'a> for dyn for<'b> Trait<'b>"
53impl<'a> B<'a> for dyn for<'b> Trait<'b> {}
54
55// @has foo/struct.Bar.html
56// @has - '//span[@id="structfield.bar"]' "bar: &'a (dyn for<'b> Trait<'b> + Unpin)"
57// @has - '//span[@id="structfield.baz"]' "baz: &'a (dyn Unpin + for<'b> Trait<'b>)"
58pub struct Bar<'a> {
59 pub bar: &'a (dyn for<'b> Trait<'b> + Unpin),
60 pub baz: &'a (dyn Unpin + for<'b> Trait<'b>),
61}