diff options
| author | Michael Howell <michael@notriddle.com> | 2024-01-03 15:30:09 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2024-01-03 15:33:12 -0700 |
| commit | 35830fe218f245ef4a82199b8ee371fa89a52721 (patch) | |
| tree | cf985b3569d5f482788f21e97798c7e076824eb0 /tests/rustdoc/impl-trait-43869.rs | |
| parent | b5c9982c0a0888bfc21e3a2c5c11575ecf2d1fb8 (diff) | |
| download | rust-35830fe218f245ef4a82199b8ee371fa89a52721.tar.gz rust-35830fe218f245ef4a82199b8ee371fa89a52721.zip | |
rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 5)
Diffstat (limited to 'tests/rustdoc/impl-trait-43869.rs')
| -rw-r--r-- | tests/rustdoc/impl-trait-43869.rs | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/tests/rustdoc/impl-trait-43869.rs b/tests/rustdoc/impl-trait-43869.rs new file mode 100644 index 00000000000..9c4ed841f79 --- /dev/null +++ b/tests/rustdoc/impl-trait-43869.rs @@ -0,0 +1,75 @@ +// https://github.com/rust-lang/rust/issues/43869 +#![crate_name="foo"] + +pub fn g() -> impl Iterator<Item=u8> { + Some(1u8).into_iter() +} + +#[allow(unused_parens)] +pub fn h() -> (impl Iterator<Item=u8>) { + Some(1u8).into_iter() +} + +pub fn i() -> impl Iterator<Item=u8> + 'static { + Some(1u8).into_iter() +} + +pub fn j() -> impl Iterator<Item=u8> + Clone { + Some(1u8).into_iter() +} + +pub fn k() -> [impl Clone; 2] { + [123u32, 456u32] +} + +pub fn l() -> (impl Clone, impl Default) { + (789u32, -123i32) +} + +pub fn m() -> &'static impl Clone { + &1u8 +} + +pub fn n() -> *const impl Clone { + &1u8 +} + +pub fn o() -> &'static [impl Clone] { + b":)" +} + +// issue #44731 +pub fn test_44731_0() -> Box<impl Iterator<Item=u8>> { + Box::new(g()) +} + +pub fn test_44731_1() -> Result<Box<impl Clone>, ()> { + Ok(Box::new(j())) +} + +// NOTE these involve Fn sugar, where impl Trait is disallowed for now, see issue #45994 +// +//pub fn test_44731_2() -> Box<Fn(impl Clone)> { +// Box::new(|_: u32| {}) +//} +// +//pub fn test_44731_3() -> Box<Fn() -> impl Clone> { +// Box::new(|| 0u32) +//} + +pub fn test_44731_4() -> Box<Iterator<Item=impl Clone>> { + Box::new(g()) +} + +// @has foo/fn.g.html +// @has foo/fn.h.html +// @has foo/fn.i.html +// @has foo/fn.j.html +// @has foo/fn.k.html +// @has foo/fn.l.html +// @has foo/fn.m.html +// @has foo/fn.n.html +// @has foo/fn.o.html +// @has foo/fn.test_44731_0.html +// @has foo/fn.test_44731_1.html +// @has foo/fn.test_44731_4.html |
