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