diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
commit | 64d98f8ee037282c35007b64c2649055c56af1db (patch) | |
tree | 5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/rustdoc/inline_cross/auxiliary | |
parent | Adding debian version 1.67.1+dfsg1-1. (diff) | |
download | rustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/rustdoc/inline_cross/auxiliary')
22 files changed, 389 insertions, 0 deletions
diff --git a/tests/rustdoc/inline_cross/auxiliary/add-docs.rs b/tests/rustdoc/inline_cross/auxiliary/add-docs.rs new file mode 100644 index 000000000..85efa508f --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/add-docs.rs @@ -0,0 +1,4 @@ +#![crate_name = "inner"] + +/// Doc comment from definition +pub struct MyStruct; diff --git a/tests/rustdoc/inline_cross/auxiliary/assoc-items.rs b/tests/rustdoc/inline_cross/auxiliary/assoc-items.rs new file mode 100644 index 000000000..5fa299914 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/assoc-items.rs @@ -0,0 +1,38 @@ +#![feature(associated_type_defaults)] + +pub struct MyStruct; + +impl MyStruct { + /// docs for PrivateConst + const PrivateConst: i8 = -123; + /// docs for PublicConst + pub const PublicConst: u8 = 123; + /// docs for private_method + fn private_method() {} + /// docs for public_method + pub fn public_method() {} +} + +pub trait MyTrait { + /// docs for ConstNoDefault + const ConstNoDefault: i16; + /// docs for ConstWithDefault + const ConstWithDefault: u16 = 12345; + /// docs for TypeNoDefault + type TypeNoDefault; + /// docs for TypeWithDefault + type TypeWithDefault = u32; + /// docs for method_no_default + fn method_no_default(); + /// docs for method_with_default + fn method_with_default() {} +} + +impl MyTrait for MyStruct { + /// dox for ConstNoDefault + const ConstNoDefault: i16 = -12345; + /// dox for TypeNoDefault + type TypeNoDefault = i32; + /// dox for method_no_default + fn method_no_default() {} +} diff --git a/tests/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs b/tests/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs new file mode 100644 index 000000000..6644c8e41 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds.rs @@ -0,0 +1,46 @@ +pub trait Main { + type Item; + + type Out0: Support<Item = ()>; + type Out1: Support<Item = Self::Item>; + type Out2<T>: Support<Item = T>; + type Out3: Support<Produce<()> = bool>; + type Out4<T>: Support<Produce<T> = T>; + type Out5: Support<Output<'static> = &'static ()>; + type Out6: for<'a> Support<Output<'a> = &'a ()>; + type Out7: Support<Item = String, Produce<i32> = u32> + Unrelated; + type Out8: Unrelated + Protocol<i16, Q1 = u128, Q0 = ()>; + type Out9: FnMut(i32) -> bool + Clone; + type Out10<'q>: Support<Output<'q> = ()>; + type Out11: for<'r, 's> Helper<A<'s> = &'s (), B<'r> = ()>; + type Out12: for<'w> Helper<B<'w> = std::borrow::Cow<'w, str>, A<'w> = bool>; + type Out13: for<'fst, 'snd> Aid<'snd, Result<'fst> = &'fst mut str>; + type Out14<P: Copy + Eq, Q: ?Sized>; + + fn make<F>(_: F, _: impl FnMut(&str) -> bool) + where + F: FnOnce(u32) -> String, + Self::Out2<()>: Protocol<u8, Q0 = Self::Item, Q1 = ()>; +} + +pub trait Support { + type Item; + type Output<'a>; + type Produce<T>; +} + +pub trait Protocol<K> { + type Q0; + type Q1; +} + +pub trait Unrelated {} + +pub trait Helper { + type A<'q>; + type B<'q>; +} + +pub trait Aid<'src> { + type Result<'inter: 'src>; +} diff --git a/tests/rustdoc/inline_cross/auxiliary/cross-glob.rs b/tests/rustdoc/inline_cross/auxiliary/cross-glob.rs new file mode 100644 index 000000000..48672590a --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/cross-glob.rs @@ -0,0 +1,7 @@ +#![crate_name = "inner"] + +pub struct SomeStruct; + +pub fn some_fn() {} + +pub enum Shadowed {} diff --git a/tests/rustdoc/inline_cross/auxiliary/default-trait-method.rs b/tests/rustdoc/inline_cross/auxiliary/default-trait-method.rs new file mode 100644 index 000000000..ce60bbfb4 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/default-trait-method.rs @@ -0,0 +1,16 @@ +#![feature(specialization)] + +#![crate_name = "foo"] + +pub trait Item { + fn foo(); + fn bar(); + fn baz() {} +} + +pub struct Foo; + +impl Item for Foo { + default fn foo() {} + fn bar() {} +} diff --git a/tests/rustdoc/inline_cross/auxiliary/dyn_trait.rs b/tests/rustdoc/inline_cross/auxiliary/dyn_trait.rs new file mode 100644 index 000000000..9ac2e3d96 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/dyn_trait.rs @@ -0,0 +1,17 @@ +pub type Ty0 = dyn for<'any> FnOnce(&'any str) -> bool; + +pub type Ty1<'obj> = dyn std::fmt::Display + 'obj; + +pub type Ty2 = dyn for<'a, 'r> Container<'r, Item<'a, 'static> = ()>; + +pub type Ty3<'s> = &'s dyn ToString; + +pub fn func0(_: &(dyn Fn() + '_)) {} + +pub fn func1<'func>(_: &(dyn Fn() + 'func)) {} + +pub trait Container<'r> { + type Item<'a, 'ctx>; +} + +pub trait Shape<'a> {} diff --git a/tests/rustdoc/inline_cross/auxiliary/impl-inline-without-trait.rs b/tests/rustdoc/inline_cross/auxiliary/impl-inline-without-trait.rs new file mode 100644 index 000000000..401a6a44a --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/impl-inline-without-trait.rs @@ -0,0 +1,8 @@ +pub trait MyTrait { + /// docs for my_trait_method + fn my_trait_method() {} +} + +pub struct MyStruct; + +impl MyTrait for MyStruct {} diff --git a/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs b/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs new file mode 100644 index 000000000..19433c968 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs @@ -0,0 +1,41 @@ +// edition:2018 + +use std::ops::Deref; + +pub fn func<'a>(_x: impl Clone + Into<Vec<u8>> + 'a) {} + +pub fn func2<T>( + _x: impl Deref<Target = Option<T>> + Iterator<Item = T>, + _y: impl Iterator<Item = u8>, +) {} + +pub fn func3(_x: impl Iterator<Item = impl Iterator<Item = u8>> + Clone) {} + +pub fn func4<T: Iterator<Item = impl Clone>>(_x: T) {} + +pub fn func5( + _f: impl for<'any> Fn(&'any str, &'any str) -> bool + for<'r> Other<T<'r> = ()>, + _a: impl for<'alpha, 'beta> Auxiliary<'alpha, Item<'beta> = fn(&'beta ())>, +) {} + +pub trait Other { + type T<'dependency>; +} + +pub trait Auxiliary<'arena> { + type Item<'input>; +} + +pub async fn async_fn() {} + +pub struct Foo; + +impl Foo { + pub fn method<'a>(_x: impl Clone + Into<Vec<u8>> + 'a) {} +} + +pub struct Bar; + +impl Bar { + pub async fn async_foo(&self) {} +} diff --git a/tests/rustdoc/inline_cross/auxiliary/implementors_inline.rs b/tests/rustdoc/inline_cross/auxiliary/implementors_inline.rs new file mode 100644 index 000000000..b003fb357 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/implementors_inline.rs @@ -0,0 +1,18 @@ +pub mod my_trait { + pub trait MyTrait { + fn my_fn(&self) -> Self; + } +} + +pub mod prelude { + #[doc(inline)] + pub use crate::my_trait::MyTrait; +} + +pub struct SomeStruct; + +impl my_trait::MyTrait for SomeStruct { + fn my_fn(&self) -> SomeStruct { + SomeStruct + } +} diff --git a/tests/rustdoc/inline_cross/auxiliary/issue-24183.rs b/tests/rustdoc/inline_cross/auxiliary/issue-24183.rs new file mode 100644 index 000000000..e7a13acc6 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/issue-24183.rs @@ -0,0 +1,14 @@ +#![crate_type = "lib"] + +pub trait U/*: ?Sized */ { + fn modified(self) -> Self + where + Self: Sized + { + self + } + + fn touch(&self)/* where Self: ?Sized */{} +} + +pub trait S: Sized {} diff --git a/tests/rustdoc/inline_cross/auxiliary/issue-33113.rs b/tests/rustdoc/inline_cross/auxiliary/issue-33113.rs new file mode 100644 index 000000000..4e1f1918e --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/issue-33113.rs @@ -0,0 +1,7 @@ +#![crate_name="bar"] + +pub trait Bar {} +pub struct Foo; + +impl<'a> Bar for &'a char {} +impl Bar for Foo {} diff --git a/tests/rustdoc/inline_cross/auxiliary/macro-vis.rs b/tests/rustdoc/inline_cross/auxiliary/macro-vis.rs new file mode 100644 index 000000000..5615a4fdd --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/macro-vis.rs @@ -0,0 +1,25 @@ +#![crate_name = "qwop"] + +/// (written on a spider's web) Some Macro +#[macro_export] +macro_rules! some_macro { + () => { + println!("this is some macro, for sure"); + }; +} + +/// Some other macro, to fill space. +#[macro_export] +macro_rules! other_macro { + () => { + println!("this is some other macro, whatev"); + }; +} + +/// This macro is so cool, it's Super. +#[macro_export] +macro_rules! super_macro { + () => { + println!("is it a bird? a plane? no, it's Super Macro!"); + }; +} diff --git a/tests/rustdoc/inline_cross/auxiliary/macros.rs b/tests/rustdoc/inline_cross/auxiliary/macros.rs new file mode 100644 index 000000000..651ae2f1a --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/macros.rs @@ -0,0 +1,10 @@ +#![feature(staged_api)] +#![stable(feature = "rust1", since = "1.0.0")] + +/// docs for my_macro +#[unstable(feature = "macro_test", issue = "none")] +#[deprecated(since = "1.2.3", note = "text")] +#[macro_export] +macro_rules! my_macro { + () => {}; +} diff --git a/tests/rustdoc/inline_cross/auxiliary/proc_macro.rs b/tests/rustdoc/inline_cross/auxiliary/proc_macro.rs new file mode 100644 index 000000000..d8e5746f3 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/proc_macro.rs @@ -0,0 +1,47 @@ +// force-host +// no-prefer-dynamic +// compile-flags: --crate-type proc-macro + +#![crate_type="proc-macro"] +#![crate_name="some_macros"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +macro_rules! make_attr_macro { + ($name:ident) => { + /// Generated doc comment + #[proc_macro_attribute] + pub fn $name(args: TokenStream, input: TokenStream) -> TokenStream { + panic!() + } + } +} + +make_attr_macro!(first_attr); +make_attr_macro!(second_attr); + +/// a proc-macro that swallows its input and does nothing. +#[proc_macro] +pub fn some_proc_macro(_input: TokenStream) -> TokenStream { + TokenStream::new() +} + +/// a proc-macro attribute that passes its item through verbatim. +#[proc_macro_attribute] +pub fn some_proc_attr(_attr: TokenStream, item: TokenStream) -> TokenStream { + item +} + +/// a derive attribute that adds nothing to its input. +#[proc_macro_derive(SomeDerive)] +pub fn some_derive(_item: TokenStream) -> TokenStream { + TokenStream::new() +} + +/// Doc comment from the original crate +#[proc_macro] +pub fn reexported_macro(_input: TokenStream) -> TokenStream { + TokenStream::new() +} diff --git a/tests/rustdoc/inline_cross/auxiliary/renamed-via-module.rs b/tests/rustdoc/inline_cross/auxiliary/renamed-via-module.rs new file mode 100644 index 000000000..2e5290782 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/renamed-via-module.rs @@ -0,0 +1,9 @@ +#![crate_name = "foo"] + +pub mod iter { + mod range { + pub struct StepBy; + } + pub use self::range::StepBy as DeprecatedStepBy; + pub struct StepBy; +} diff --git a/tests/rustdoc/inline_cross/auxiliary/rustdoc-hidden-sig.rs b/tests/rustdoc/inline_cross/auxiliary/rustdoc-hidden-sig.rs new file mode 100644 index 000000000..6357b76df --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/rustdoc-hidden-sig.rs @@ -0,0 +1,12 @@ +pub struct Bar; + +impl Bar { + pub fn bar(_: u8) -> hidden::Hidden { + hidden::Hidden + } +} + +#[doc(hidden)] +pub mod hidden { + pub struct Hidden; +} diff --git a/tests/rustdoc/inline_cross/auxiliary/rustdoc-hidden.rs b/tests/rustdoc/inline_cross/auxiliary/rustdoc-hidden.rs new file mode 100644 index 000000000..0c75b3127 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/rustdoc-hidden.rs @@ -0,0 +1,4 @@ +#[doc(hidden)] +pub struct Foo; + +pub struct Bar; diff --git a/tests/rustdoc/inline_cross/auxiliary/rustdoc-nonreachable-impls.rs b/tests/rustdoc/inline_cross/auxiliary/rustdoc-nonreachable-impls.rs new file mode 100644 index 000000000..4e461d3bc --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/rustdoc-nonreachable-impls.rs @@ -0,0 +1,34 @@ +pub struct Foo; + +pub trait Woof {} +pub trait Bark {} + +mod private { + // should be shown + impl ::Woof for ::Foo {} + + pub trait Bar {} + pub struct Wibble; + + // these should not be shown + impl Bar for ::Foo {} + impl Bar for Wibble {} + impl ::Bark for Wibble {} + impl ::Woof for Wibble {} +} + +#[doc(hidden)] +pub mod hidden { + // should be shown + impl ::Bark for ::Foo {} + + pub trait Qux {} + pub struct Wobble; + + + // these should only be shown if they're re-exported correctly + impl Qux for ::Foo {} + impl Qux for Wobble {} + impl ::Bark for Wobble {} + impl ::Woof for Wobble {} +} diff --git a/tests/rustdoc/inline_cross/auxiliary/rustdoc-trait-object-impl.rs b/tests/rustdoc/inline_cross/auxiliary/rustdoc-trait-object-impl.rs new file mode 100644 index 000000000..11d8733c4 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/rustdoc-trait-object-impl.rs @@ -0,0 +1,13 @@ +use std::fmt; + +pub trait Bar {} + +impl<'a> Bar + 'a { + pub fn bar(&self) -> usize { 42 } +} + +impl<'a> fmt::Debug for Bar + 'a { + fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { + Ok(()) + } +} diff --git a/tests/rustdoc/inline_cross/auxiliary/trait-vis.rs b/tests/rustdoc/inline_cross/auxiliary/trait-vis.rs new file mode 100644 index 000000000..e5bc7969b --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/trait-vis.rs @@ -0,0 +1,13 @@ +#![crate_name = "inner"] + +pub struct SomeStruct; + +fn asdf() { + const _FOO: () = { + impl Clone for SomeStruct { + fn clone(&self) -> Self { + SomeStruct + } + } + }; +} diff --git a/tests/rustdoc/inline_cross/auxiliary/use_crate.rs b/tests/rustdoc/inline_cross/auxiliary/use_crate.rs new file mode 100644 index 000000000..75efbe0db --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/use_crate.rs @@ -0,0 +1,5 @@ +pub mod asdf { + pub struct SomeStruct; +} + +pub trait SomeTrait {} diff --git a/tests/rustdoc/inline_cross/auxiliary/use_crate_2.rs b/tests/rustdoc/inline_cross/auxiliary/use_crate_2.rs new file mode 100644 index 000000000..25b4c202e --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/use_crate_2.rs @@ -0,0 +1 @@ +pub struct SomethingElse; |