diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-05-05 16:28:15 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-05-05 17:47:18 +0200 |
| commit | ff971d001d3440fa609f8c5370432c6b77a5ac6e (patch) | |
| tree | cd8e72cfa130743d02e8a44273453f8943c7ed90 /tests/rustdoc/auto | |
| parent | b374996ab8d3d8a10fdf1ffcf2b1c3de3fdbbf64 (diff) | |
| download | rust-ff971d001d3440fa609f8c5370432c6b77a5ac6e.tar.gz rust-ff971d001d3440fa609f8c5370432c6b77a5ac6e.zip | |
Created `tests/rustdoc/auto` subfolder to limit number of files at the top level
Diffstat (limited to 'tests/rustdoc/auto')
| -rw-r--r-- | tests/rustdoc/auto/auto-impl-for-trait.rs | 16 | ||||
| -rw-r--r-- | tests/rustdoc/auto/auto-impl-primitive.rs | 10 | ||||
| -rw-r--r-- | tests/rustdoc/auto/auto-trait-bounds-by-associated-type-50159.rs | 26 | ||||
| -rw-r--r-- | tests/rustdoc/auto/auto-trait-bounds-inference-variables-54705.rs | 30 | ||||
| -rw-r--r-- | tests/rustdoc/auto/auto-trait-bounds-where-51236.rs | 17 | ||||
| -rw-r--r-- | tests/rustdoc/auto/auto-trait-negative-impl-55321.rs | 21 | ||||
| -rw-r--r-- | tests/rustdoc/auto/auto-trait-not-send.rs | 8 | ||||
| -rw-r--r-- | tests/rustdoc/auto/auto-traits.rs | 13 | ||||
| -rw-r--r-- | tests/rustdoc/auto/auto_aliases.rs | 6 | ||||
| -rw-r--r-- | tests/rustdoc/auto/auxiliary/auto-traits.rs | 3 |
10 files changed, 150 insertions, 0 deletions
diff --git a/tests/rustdoc/auto/auto-impl-for-trait.rs b/tests/rustdoc/auto/auto-impl-for-trait.rs new file mode 100644 index 00000000000..bc658fbfc8c --- /dev/null +++ b/tests/rustdoc/auto/auto-impl-for-trait.rs @@ -0,0 +1,16 @@ +// Test for https://github.com/rust-lang/rust/issues/48463 issue. + +use std::any::Any; +use std::ops::Deref; + +pub struct AnyValue { + val: Box<Any>, +} + +impl Deref for AnyValue { + type Target = Any; + + fn deref(&self) -> &Any { + &*self.val + } +} diff --git a/tests/rustdoc/auto/auto-impl-primitive.rs b/tests/rustdoc/auto/auto-impl-primitive.rs new file mode 100644 index 00000000000..3dab02506ca --- /dev/null +++ b/tests/rustdoc/auto/auto-impl-primitive.rs @@ -0,0 +1,10 @@ +#![feature(rustc_attrs)] + +#![crate_name = "foo"] + +pub use std::fs::File; + +//@ has 'foo/primitive.i16.html' '//h2[@id="synthetic-implementations"]' 'Auto Trait Implementation' +#[rustc_doc_primitive = "i16"] +/// I love poneys! +mod prim {} diff --git a/tests/rustdoc/auto/auto-trait-bounds-by-associated-type-50159.rs b/tests/rustdoc/auto/auto-trait-bounds-by-associated-type-50159.rs new file mode 100644 index 00000000000..2803c4da437 --- /dev/null +++ b/tests/rustdoc/auto/auto-trait-bounds-by-associated-type-50159.rs @@ -0,0 +1,26 @@ +// https://github.com/rust-lang/rust/issues/50159 +#![crate_name = "foo"] + +pub trait Signal { + type Item; +} + +pub trait Signal2 { + type Item2; +} + +impl<B, C> Signal2 for B +where + B: Signal<Item = C>, +{ + type Item2 = C; +} + +//@ has foo/struct.Switch.html +//@ has - '//h3[@class="code-header"]' 'impl<B> Send for Switch<B>where <B as Signal>::Item: Send' +//@ has - '//h3[@class="code-header"]' 'impl<B> Sync for Switch<B>where <B as Signal>::Item: Sync' +//@ count - '//*[@id="implementations-list"]//*[@class="impl"]' 0 +//@ count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 6 +pub struct Switch<B: Signal> { + pub inner: <B as Signal2>::Item2, +} diff --git a/tests/rustdoc/auto/auto-trait-bounds-inference-variables-54705.rs b/tests/rustdoc/auto/auto-trait-bounds-inference-variables-54705.rs new file mode 100644 index 00000000000..ef159fca872 --- /dev/null +++ b/tests/rustdoc/auto/auto-trait-bounds-inference-variables-54705.rs @@ -0,0 +1,30 @@ +// https://github.com/rust-lang/rust/issues/54705 +#![crate_name="foo"] + +pub trait ScopeHandle<'scope> {} + +//@ has foo/struct.ScopeFutureContents.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl<'scope, S> Send for ScopeFutureContents<'scope, S>where S: Sync" +// +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl<'scope, S> Sync for ScopeFutureContents<'scope, S>where S: Sync" +pub struct ScopeFutureContents<'scope, S> + where S: ScopeHandle<'scope>, +{ + dummy: &'scope S, + this: Box<ScopeFuture<'scope, S>>, +} + +struct ScopeFuture<'scope, S> + where S: ScopeHandle<'scope>, +{ + contents: ScopeFutureContents<'scope, S>, +} + +unsafe impl<'scope, S> Send for ScopeFuture<'scope, S> + where S: ScopeHandle<'scope>, +{} +unsafe impl<'scope, S> Sync for ScopeFuture<'scope, S> + where S: ScopeHandle<'scope>, +{} diff --git a/tests/rustdoc/auto/auto-trait-bounds-where-51236.rs b/tests/rustdoc/auto/auto-trait-bounds-where-51236.rs new file mode 100644 index 00000000000..c892b6d0abf --- /dev/null +++ b/tests/rustdoc/auto/auto-trait-bounds-where-51236.rs @@ -0,0 +1,17 @@ +// https://github.com/rust-lang/rust/issues/51236 +#![crate_name="foo"] + +use std::marker::PhantomData; + +pub mod traits { + pub trait Owned<'a> { + type Reader; + } +} + +//@ has foo/struct.Owned.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl<T> Send for Owned<T>where <T as Owned<'static>>::Reader: Send" +pub struct Owned<T> where T: for<'a> ::traits::Owned<'a> { + marker: PhantomData<<T as ::traits::Owned<'static>>::Reader>, +} diff --git a/tests/rustdoc/auto/auto-trait-negative-impl-55321.rs b/tests/rustdoc/auto/auto-trait-negative-impl-55321.rs new file mode 100644 index 00000000000..147f44da117 --- /dev/null +++ b/tests/rustdoc/auto/auto-trait-negative-impl-55321.rs @@ -0,0 +1,21 @@ +// https://github.com/rust-lang/rust/issues/55321 +#![crate_name="foo"] + +#![feature(negative_impls)] + +//@ has foo/struct.A.html +//@ has - '//*[@id="trait-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl !Send for A" +//@ has - '//*[@id="trait-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl !Sync for A" +pub struct A(); + +impl !Send for A {} +impl !Sync for A {} + +//@ has foo/struct.B.html +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl<T> !Send for B<T>" +//@ has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ +// "impl<T> !Sync for B<T>" +pub struct B<T: ?Sized>(A, Box<T>); diff --git a/tests/rustdoc/auto/auto-trait-not-send.rs b/tests/rustdoc/auto/auto-trait-not-send.rs new file mode 100644 index 00000000000..0a31952f5e1 --- /dev/null +++ b/tests/rustdoc/auto/auto-trait-not-send.rs @@ -0,0 +1,8 @@ +#![crate_name = "foo"] + +//@ has 'foo/struct.Foo.html' +//@ has - '//*[@id="impl-Send-for-Foo"]' 'impl !Send for Foo' +//@ has - '//*[@id="impl-Sync-for-Foo"]' 'impl !Sync for Foo' +pub struct Foo(*const i8); +pub trait Whatever: Send {} +impl<T: Send + ?Sized> Whatever for T {} diff --git a/tests/rustdoc/auto/auto-traits.rs b/tests/rustdoc/auto/auto-traits.rs new file mode 100644 index 00000000000..dce406ed3e3 --- /dev/null +++ b/tests/rustdoc/auto/auto-traits.rs @@ -0,0 +1,13 @@ +//@ aux-build:auto-traits.rs + +#![feature(auto_traits)] + +#![crate_name = "foo"] + +extern crate auto_traits; + +//@ has 'foo/trait.Foo.html' '//pre' 'pub unsafe auto trait Foo' +pub unsafe auto trait Foo {} + +//@ has 'foo/trait.Bar.html' '//pre' 'pub unsafe auto trait Bar' +pub use auto_traits::Bar; diff --git a/tests/rustdoc/auto/auto_aliases.rs b/tests/rustdoc/auto/auto_aliases.rs new file mode 100644 index 00000000000..920aba805cd --- /dev/null +++ b/tests/rustdoc/auto/auto_aliases.rs @@ -0,0 +1,6 @@ +#![feature(auto_traits)] + +//@ has auto_aliases/trait.Bar.html '//*[@data-aliases="auto_aliases::Foo"]' 'impl Bar for Foo' +pub struct Foo; + +pub auto trait Bar {} diff --git a/tests/rustdoc/auto/auxiliary/auto-traits.rs b/tests/rustdoc/auto/auxiliary/auto-traits.rs new file mode 100644 index 00000000000..84976c73bee --- /dev/null +++ b/tests/rustdoc/auto/auxiliary/auto-traits.rs @@ -0,0 +1,3 @@ +#![feature(auto_traits)] + +pub unsafe auto trait Bar {} |
