]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc/universal-impl-trait.rs
Auto merge of #50364 - LukasKalbertodt:improve-duration-debug-impl, r=KodrAus
[rust.git] / src / test / rustdoc / universal-impl-trait.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 #![crate_name = "foo"]
12
13 use std::io::Read;
14 use std::borrow::Borrow;
15
16 // @has foo/fn.foo.html
17 // @has - //pre 'foo('
18 // @matches - '_x: impl <a class="trait" href="[^"]+/trait\.Clone\.html"'
19 // @matches - '_z: .+impl.+trait\.Copy\.html.+, impl.+trait\.Clone\.html'
20 pub fn foo(_x: impl Clone, _y: i32, _z: (impl Copy, impl Clone)) {
21 }
22
23 pub trait Trait {
24     // @has foo/trait.Trait.html
25     // @has - 'method</a>('
26     // @matches - '_x: impl <a class="trait" href="[^"]+/trait\.Debug\.html"'
27     fn method(&self, _x: impl std::fmt::Debug) {
28     }
29 }
30
31 pub struct S<T>(T);
32
33 impl<T> S<T> {
34     // @has foo/struct.S.html
35     // @has - 'bar</a>('
36     // @matches - '_bar: impl <a class="trait" href="[^"]+/trait\.Copy\.html"'
37     pub fn bar(_bar: impl Copy) {
38     }
39
40     // @has - 'baz</a>('
41     // @matches - '_baz:.+struct\.S\.html.+impl .+trait\.Clone\.html'
42     pub fn baz(_baz: S<impl Clone>) {
43     }
44
45     // @has - 'qux</a>('
46     // @matches - 'trait\.Read\.html'
47     pub fn qux(_qux: impl IntoIterator<Item = S<impl Read>>) {
48     }
49 }
50
51 // @has - 'method</a>('
52 // @matches - '_x: impl <a class="trait" href="[^"]+/trait\.Debug\.html"'
53 impl<T> Trait for S<T> {}
54
55 // @has foo/fn.much_universe.html
56 // @matches - 'T:.+Borrow.+impl .+trait\.Trait\.html'
57 // @matches - 'U:.+IntoIterator.+= impl.+Iterator\.html.+= impl.+Clone\.html'
58 // @matches - '_: impl .+trait\.Read\.html.+ \+ .+trait\.Clone\.html'
59 pub fn much_universe<
60     T: Borrow<impl Trait>,
61     U: IntoIterator<Item = impl Iterator<Item = impl Clone>>,
62 >(
63     _: impl Read + Clone,
64 ) {
65 }