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/intra-doc/cross-crate | |
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/intra-doc/cross-crate')
19 files changed, 207 insertions, 0 deletions
diff --git a/tests/rustdoc/intra-doc/cross-crate/additional_doc.rs b/tests/rustdoc/intra-doc/cross-crate/additional_doc.rs new file mode 100644 index 000000000..e52fb9b1c --- /dev/null +++ b/tests/rustdoc/intra-doc/cross-crate/additional_doc.rs @@ -0,0 +1,10 @@ +// aux-build:additional_doc.rs +// build-aux-docs +#![deny(rustdoc::broken_intra_doc_links)] + +extern crate my_rand; + +// @has 'additional_doc/trait.Rng.html' '//a[@href="trait.Rng.html"]' 'Rng' +// @has 'additional_doc/trait.Rng.html' '//a[@href="../my_rand/trait.RngCore.html"]' 'RngCore' +/// This is an [`Rng`]. +pub use my_rand::Rng; diff --git a/tests/rustdoc/intra-doc/cross-crate/auxiliary/additional_doc.rs b/tests/rustdoc/intra-doc/cross-crate/auxiliary/additional_doc.rs new file mode 100644 index 000000000..684fdd449 --- /dev/null +++ b/tests/rustdoc/intra-doc/cross-crate/auxiliary/additional_doc.rs @@ -0,0 +1,6 @@ +#![crate_name = "my_rand"] +#![deny(rustdoc::broken_intra_doc_links)] + +pub trait RngCore {} +/// Rng extends [`RngCore`]. +pub trait Rng: RngCore {} diff --git a/tests/rustdoc/intra-doc/cross-crate/auxiliary/hidden.rs b/tests/rustdoc/intra-doc/cross-crate/auxiliary/hidden.rs new file mode 100644 index 000000000..34f4e9f63 --- /dev/null +++ b/tests/rustdoc/intra-doc/cross-crate/auxiliary/hidden.rs @@ -0,0 +1,19 @@ +#![crate_name = "hidden_dep"] +#![deny(rustdoc::broken_intra_doc_links)] + +#[doc(hidden)] +pub mod __reexport { + pub use crate::*; +} + +pub mod future { + mod ready { + + /// Link to [`ready`](function@ready) + pub struct Ready; + pub fn ready() {} + + } + pub use self::ready::{ready, Ready}; + +} diff --git a/tests/rustdoc/intra-doc/cross-crate/auxiliary/intra-doc-basic.rs b/tests/rustdoc/intra-doc/cross-crate/auxiliary/intra-doc-basic.rs new file mode 100644 index 000000000..d6a829966 --- /dev/null +++ b/tests/rustdoc/intra-doc/cross-crate/auxiliary/intra-doc-basic.rs @@ -0,0 +1,7 @@ +#![crate_name = "a"] +#![deny(rustdoc::broken_intra_doc_links)] + +pub struct Foo; + +/// Link to [Foo] +pub struct Bar; diff --git a/tests/rustdoc/intra-doc/cross-crate/auxiliary/intra-link-cross-crate-crate.rs b/tests/rustdoc/intra-doc/cross-crate/auxiliary/intra-link-cross-crate-crate.rs new file mode 100644 index 000000000..a37848e23 --- /dev/null +++ b/tests/rustdoc/intra-doc/cross-crate/auxiliary/intra-link-cross-crate-crate.rs @@ -0,0 +1,5 @@ +#![crate_name = "inner"] + +/// Links to [crate::g] +pub fn f() {} +pub fn g() {} diff --git a/tests/rustdoc/intra-doc/cross-crate/auxiliary/macro_inner.rs b/tests/rustdoc/intra-doc/cross-crate/auxiliary/macro_inner.rs new file mode 100644 index 000000000..cb7a8afb6 --- /dev/null +++ b/tests/rustdoc/intra-doc/cross-crate/auxiliary/macro_inner.rs @@ -0,0 +1,10 @@ +#![crate_name = "macro_inner"] +#![deny(rustdoc::broken_intra_doc_links)] + +pub struct Foo; + +/// See also [`Foo`] +#[macro_export] +macro_rules! my_macro { + () => {} +} diff --git a/tests/rustdoc/intra-doc/cross-crate/auxiliary/module.rs b/tests/rustdoc/intra-doc/cross-crate/auxiliary/module.rs new file mode 100644 index 000000000..018fdedd9 --- /dev/null +++ b/tests/rustdoc/intra-doc/cross-crate/auxiliary/module.rs @@ -0,0 +1,7 @@ +#![crate_name = "module_inner"] +#![deny(rustdoc::broken_intra_doc_links)] +/// [SomeType] links to [bar] +pub struct SomeType; +pub trait SomeTrait {} +/// [bar] links to [SomeTrait] and also [SomeType] +pub mod bar {} diff --git a/tests/rustdoc/intra-doc/cross-crate/auxiliary/proc_macro.rs b/tests/rustdoc/intra-doc/cross-crate/auxiliary/proc_macro.rs new file mode 100644 index 000000000..0d5a95407 --- /dev/null +++ b/tests/rustdoc/intra-doc/cross-crate/auxiliary/proc_macro.rs @@ -0,0 +1,20 @@ +// force-host +// no-prefer-dynamic +// compile-flags: --crate-type proc-macro +#![crate_type="proc-macro"] +#![crate_name="proc_macro_inner"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +/// Links to [`OtherDerive`] +#[proc_macro_derive(DeriveA)] +pub fn a_derive(input: TokenStream) -> TokenStream { + input +} + +#[proc_macro_derive(OtherDerive)] +pub fn other_derive(input: TokenStream) -> TokenStream { + input +} diff --git a/tests/rustdoc/intra-doc/cross-crate/auxiliary/submodule-inner.rs b/tests/rustdoc/intra-doc/cross-crate/auxiliary/submodule-inner.rs new file mode 100644 index 000000000..0612f53d6 --- /dev/null +++ b/tests/rustdoc/intra-doc/cross-crate/auxiliary/submodule-inner.rs @@ -0,0 +1,12 @@ +#![crate_name = "a"] +#![deny(rustdoc::broken_intra_doc_links)] + +pub mod bar { + pub struct Bar; +} + +pub mod foo { + use crate::bar; + /// link to [bar::Bar] + pub struct Foo; +} diff --git a/tests/rustdoc/intra-doc/cross-crate/auxiliary/submodule-outer.rs b/tests/rustdoc/intra-doc/cross-crate/auxiliary/submodule-outer.rs new file mode 100644 index 000000000..105eb8e11 --- /dev/null +++ b/tests/rustdoc/intra-doc/cross-crate/auxiliary/submodule-outer.rs @@ -0,0 +1,13 @@ +#![crate_name = "bar"] +#![deny(rustdoc::broken_intra_doc_links)] + +pub trait Foo { + /// [`Bar`] [`Baz`] + fn foo(); +} + +pub trait Bar { +} + +pub trait Baz { +} diff --git a/tests/rustdoc/intra-doc/cross-crate/auxiliary/traits.rs b/tests/rustdoc/intra-doc/cross-crate/auxiliary/traits.rs new file mode 100644 index 000000000..c16e39d56 --- /dev/null +++ b/tests/rustdoc/intra-doc/cross-crate/auxiliary/traits.rs @@ -0,0 +1,16 @@ +#![crate_name = "inner"] +/// this is a trait +pub trait SomeTrait { + /// this is a method for [a trait][SomeTrait] + fn foo(); +} + +pub mod bar { + use super::SomeTrait; + + pub struct BarStruct; + + impl SomeTrait for BarStruct { + fn foo() {} + } +} diff --git a/tests/rustdoc/intra-doc/cross-crate/basic.rs b/tests/rustdoc/intra-doc/cross-crate/basic.rs new file mode 100644 index 000000000..ad7454918 --- /dev/null +++ b/tests/rustdoc/intra-doc/cross-crate/basic.rs @@ -0,0 +1,9 @@ +// aux-build:intra-doc-basic.rs +// build-aux-docs +#![deny(rustdoc::broken_intra_doc_links)] + +// from https://github.com/rust-lang/rust/issues/65983 +extern crate a; + +// @has 'basic/struct.Bar.html' '//a[@href="../a/struct.Foo.html"]' 'Foo' +pub use a::Bar; diff --git a/tests/rustdoc/intra-doc/cross-crate/crate.rs b/tests/rustdoc/intra-doc/cross-crate/crate.rs new file mode 100644 index 000000000..edf544708 --- /dev/null +++ b/tests/rustdoc/intra-doc/cross-crate/crate.rs @@ -0,0 +1,6 @@ +// aux-build:intra-link-cross-crate-crate.rs +// build-aux-docs +#![crate_name = "outer"] +extern crate inner; +// @has outer/fn.f.html '//a[@href="../inner/fn.g.html"]' "crate::g" +pub use inner::f; diff --git a/tests/rustdoc/intra-doc/cross-crate/hidden.rs b/tests/rustdoc/intra-doc/cross-crate/hidden.rs new file mode 100644 index 000000000..4f7d075ba --- /dev/null +++ b/tests/rustdoc/intra-doc/cross-crate/hidden.rs @@ -0,0 +1,10 @@ +// aux-build:hidden.rs +// build-aux-docs +#![deny(rustdoc::broken_intra_doc_links)] + +// tests https://github.com/rust-lang/rust/issues/73363 + +extern crate hidden_dep; + +// @has 'hidden/struct.Ready.html' '//a/@href' 'fn.ready.html' +pub use hidden_dep::future::{ready, Ready}; diff --git a/tests/rustdoc/intra-doc/cross-crate/macro.rs b/tests/rustdoc/intra-doc/cross-crate/macro.rs new file mode 100644 index 000000000..32f0a55d3 --- /dev/null +++ b/tests/rustdoc/intra-doc/cross-crate/macro.rs @@ -0,0 +1,11 @@ +// aux-build:macro_inner.rs +// aux-build:proc_macro.rs +// build-aux-docs +#![deny(rustdoc::broken_intra_doc_links)] +extern crate macro_inner; +extern crate proc_macro_inner; + +// @has 'macro/macro.my_macro.html' '//a[@href="../macro_inner/struct.Foo.html"]' 'Foo' +pub use macro_inner::my_macro; +// @has 'macro/derive.DeriveA.html' '//a[@href="../proc_macro_inner/derive.OtherDerive.html"]' 'OtherDerive' +pub use proc_macro_inner::DeriveA; diff --git a/tests/rustdoc/intra-doc/cross-crate/module.rs b/tests/rustdoc/intra-doc/cross-crate/module.rs new file mode 100644 index 000000000..fde932265 --- /dev/null +++ b/tests/rustdoc/intra-doc/cross-crate/module.rs @@ -0,0 +1,8 @@ +// outer.rs +// aux-build: module.rs +// build-aux-docs +#![deny(rustdoc::broken_intra_doc_links)] +extern crate module_inner; +// @has 'module/bar/index.html' '//a[@href="../../module_inner/trait.SomeTrait.html"]' 'SomeTrait' +// @has 'module/bar/index.html' '//a[@href="../../module_inner/struct.SomeType.html"]' 'SomeType' +pub use module_inner::bar; diff --git a/tests/rustdoc/intra-doc/cross-crate/submodule-inner.rs b/tests/rustdoc/intra-doc/cross-crate/submodule-inner.rs new file mode 100644 index 000000000..577fe78a5 --- /dev/null +++ b/tests/rustdoc/intra-doc/cross-crate/submodule-inner.rs @@ -0,0 +1,8 @@ +// aux-build:submodule-inner.rs +// build-aux-docs +#![deny(rustdoc::broken_intra_doc_links)] + +extern crate a; + +// @has 'submodule_inner/struct.Foo.html' '//a[@href="../a/bar/struct.Bar.html"]' 'Bar' +pub use a::foo::Foo; diff --git a/tests/rustdoc/intra-doc/cross-crate/submodule-outer.rs b/tests/rustdoc/intra-doc/cross-crate/submodule-outer.rs new file mode 100644 index 000000000..d0c0b7e85 --- /dev/null +++ b/tests/rustdoc/intra-doc/cross-crate/submodule-outer.rs @@ -0,0 +1,16 @@ +// aux-build:submodule-outer.rs +// edition:2018 +#![deny(rustdoc::broken_intra_doc_links)] + +extern crate bar as bar_; + +// from https://github.com/rust-lang/rust/issues/60883 +pub mod bar { + pub use ::bar_::Bar; +} + +// NOTE: we re-exported both `Foo` and `Bar` here, +// NOTE: so they are inlined and therefore we link to the current module. +// @has 'submodule_outer/trait.Foo.html' '//a[@href="bar/trait.Bar.html"]' 'Bar' +// @has 'submodule_outer/trait.Foo.html' '//a[@href="trait.Baz.html"]' 'Baz' +pub use ::bar_::{Foo, Baz}; diff --git a/tests/rustdoc/intra-doc/cross-crate/traits.rs b/tests/rustdoc/intra-doc/cross-crate/traits.rs new file mode 100644 index 000000000..7b9554bfd --- /dev/null +++ b/tests/rustdoc/intra-doc/cross-crate/traits.rs @@ -0,0 +1,14 @@ +// aux-build:traits.rs +// build-aux-docs +#![deny(rustdoc::broken_intra_doc_links)] + +extern crate inner; +use inner::SomeTrait; + +pub struct SomeStruct; + + // @has 'traits/struct.SomeStruct.html' '//a[@href="../inner/trait.SomeTrait.html"]' 'SomeTrait' +impl SomeTrait for SomeStruct { + // @has 'traits/struct.SomeStruct.html' '//a[@href="../inner/trait.SomeTrait.html"]' 'a trait' + fn foo() {} +} |