]> git.lizzy.rs Git - rust.git/blob - src/test/rustdoc/issue-43869.rs
Rollup merge of #49401 - alercah:format, r=cramertj
[rust.git] / src / test / rustdoc / issue-43869.rs
1 // Copyright 2017 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 pub fn g() -> impl Iterator<Item=u8> {
12     Some(1u8).into_iter()
13 }
14
15 pub fn h() -> (impl Iterator<Item=u8>) {
16     Some(1u8).into_iter()
17 }
18
19 pub fn i() -> impl Iterator<Item=u8> + 'static {
20     Some(1u8).into_iter()
21 }
22
23 pub fn j() -> impl Iterator<Item=u8> + Clone {
24     Some(1u8).into_iter()
25 }
26
27 pub fn k() -> [impl Clone; 2] {
28     [123u32, 456u32]
29 }
30
31 pub fn l() -> (impl Clone, impl Default) {
32     (789u32, -123i32)
33 }
34
35 pub fn m() -> &'static impl Clone {
36     &1u8
37 }
38
39 pub fn n() -> *const impl Clone {
40     &1u8
41 }
42
43 pub fn o() -> &'static [impl Clone] {
44     b":)"
45 }
46
47 // issue #44731
48 pub fn test_44731_0() -> Box<impl Iterator<Item=u8>> {
49     Box::new(g())
50 }
51
52 pub fn test_44731_1() -> Result<Box<impl Clone>, ()> {
53     Ok(Box::new(j()))
54 }
55
56 // NOTE these involve Fn sugar, where impl Trait is disallowed for now, see issue #45994
57 //
58 //pub fn test_44731_2() -> Box<Fn(impl Clone)> {
59 //    Box::new(|_: u32| {})
60 //}
61 //
62 //pub fn test_44731_3() -> Box<Fn() -> impl Clone> {
63 //    Box::new(|| 0u32)
64 //}
65
66 pub fn test_44731_4() -> Box<Iterator<Item=impl Clone>> {
67     Box::new(g())
68 }
69
70 // @has issue_43869/fn.g.html
71 // @has issue_43869/fn.h.html
72 // @has issue_43869/fn.i.html
73 // @has issue_43869/fn.j.html
74 // @has issue_43869/fn.k.html
75 // @has issue_43869/fn.l.html
76 // @has issue_43869/fn.m.html
77 // @has issue_43869/fn.n.html
78 // @has issue_43869/fn.o.html
79 // @has issue_43869/fn.test_44731_0.html
80 // @has issue_43869/fn.test_44731_1.html
81 // @has issue_43869/fn.test_44731_4.html