]> git.proxmox.com Git - rustc.git/blob - tests/rustdoc/universal-impl-trait.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / rustdoc / universal-impl-trait.rs
1 #![crate_name = "foo"]
2
3 use std::io::Read;
4 use std::borrow::Borrow;
5
6 // @has foo/fn.foo.html
7 // @has - //pre 'foo('
8 // @matchesraw - '_x: impl <a class="trait" href="[^"]+/trait\.Clone\.html"'
9 // @matchesraw - '_z: .+impl.+trait\.Copy\.html.+, impl.+trait\.Clone\.html'
10 pub fn foo(_x: impl Clone, _y: i32, _z: (impl Copy, impl Clone)) {
11 }
12
13 pub trait Trait {
14 // @has foo/trait.Trait.html
15 // @hasraw - 'method</a>('
16 // @matchesraw - '_x: impl <a class="trait" href="[^"]+/trait\.Debug\.html"'
17 fn method(&self, _x: impl std::fmt::Debug) {
18 }
19 }
20
21 pub struct S<T>(T);
22
23 impl<T> S<T> {
24 // @has foo/struct.S.html
25 // @hasraw - 'bar</a>('
26 // @matchesraw - '_bar: impl <a class="trait" href="[^"]+/trait\.Copy\.html"'
27 pub fn bar(_bar: impl Copy) {
28 }
29
30 // @hasraw - 'baz</a>('
31 // @matchesraw - '_baz:.+struct\.S\.html.+impl .+trait\.Clone\.html'
32 pub fn baz(_baz: S<impl Clone>) {
33 }
34
35 // @hasraw - 'qux</a>('
36 // @matchesraw - 'trait\.Read\.html'
37 pub fn qux(_qux: impl IntoIterator<Item = S<impl Read>>) {
38 }
39 }
40
41 // @hasraw - 'method</a>('
42 // @matchesraw - '_x: impl <a class="trait" href="[^"]+/trait\.Debug\.html"'
43 impl<T> Trait for S<T> {}
44
45 // @has foo/fn.much_universe.html
46 // @matchesraw - 'T:.+Borrow.+impl .+trait\.Trait\.html'
47 // @matchesraw - 'U:.+IntoIterator.+= impl.+Iterator\.html.+= impl.+Clone\.html'
48 // @matchesraw - '_: impl .+trait\.Read\.html.+ \+ .+trait\.Clone\.html'
49 pub fn much_universe<
50 T: Borrow<impl Trait>,
51 U: IntoIterator<Item = impl Iterator<Item = impl Clone>>,
52 >(
53 _: impl Read + Clone,
54 ) {
55 }