From e14e19a67dcdd7437b29bd37b4aa1fde3e5fecee Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 May 2025 17:30:40 +0200 Subject: Created `tests/rustdoc/extern` subfolder to limit number of files at the top level --- .../extern-default-method.no_href_on_anchor.html | 1 - tests/rustdoc/auxiliary/extern-links.rs | 1 - tests/rustdoc/auxiliary/external-cross-doc.md | 4 --- tests/rustdoc/auxiliary/external-cross.rs | 3 --- tests/rustdoc/auxiliary/external-doc.md | 3 --- tests/rustdoc/auxiliary/html_root.rs | 2 -- tests/rustdoc/auxiliary/issue-30109-1.rs | 1 - tests/rustdoc/auxiliary/no_html_root.rs | 1 - tests/rustdoc/auxiliary/panic-item.rs | 17 ------------- tests/rustdoc/auxiliary/pub-extern-crate.rs | 2 -- .../auxiliary/rustdoc-extern-default-method.rs | 11 -------- tests/rustdoc/auxiliary/rustdoc-extern-method.rs | 7 ------ tests/rustdoc/extern-default-method.rs | 23 ----------------- tests/rustdoc/extern-fn-22038.rs | 22 ---------------- tests/rustdoc/extern-html-root-url-precedence.rs | 7 ------ tests/rustdoc/extern-html-root-url.rs | 18 -------------- tests/rustdoc/extern-links.rs | 21 ---------------- tests/rustdoc/extern-method.rs | 19 -------------- tests/rustdoc/extern/auxiliary/empty.rs | 1 + tests/rustdoc/extern/auxiliary/extern-links.rs | 1 + .../rustdoc/extern/auxiliary/external-cross-doc.md | 4 +++ tests/rustdoc/extern/auxiliary/external-cross.rs | 3 +++ tests/rustdoc/extern/auxiliary/external-doc.md | 3 +++ tests/rustdoc/extern/auxiliary/html_root.rs | 2 ++ tests/rustdoc/extern/auxiliary/issue-30109-1.rs | 1 + tests/rustdoc/extern/auxiliary/no_html_root.rs | 1 + tests/rustdoc/extern/auxiliary/panic-item.rs | 17 +++++++++++++ tests/rustdoc/extern/auxiliary/pub-extern-crate.rs | 2 ++ .../auxiliary/rustdoc-extern-default-method.rs | 11 ++++++++ .../extern/auxiliary/rustdoc-extern-method.rs | 7 ++++++ tests/rustdoc/extern/auxiliary/variant-struct.rs | 5 ++++ .../extern-default-method.no_href_on_anchor.html | 1 + tests/rustdoc/extern/extern-default-method.rs | 23 +++++++++++++++++ tests/rustdoc/extern/extern-fn-22038.rs | 22 ++++++++++++++++ .../extern/extern-html-root-url-precedence.rs | 7 ++++++ tests/rustdoc/extern/extern-html-root-url.rs | 18 ++++++++++++++ tests/rustdoc/extern/extern-links.rs | 21 ++++++++++++++++ tests/rustdoc/extern/extern-method.rs | 19 ++++++++++++++ tests/rustdoc/extern/external-cross.rs | 10 ++++++++ tests/rustdoc/extern/external-doc.rs | 14 +++++++++++ tests/rustdoc/extern/hidden-extern-34025.rs | 13 ++++++++++ tests/rustdoc/extern/link-extern-crate-33178.rs | 17 +++++++++++++ .../rustdoc/extern/link-extern-crate-item-30109.rs | 17 +++++++++++++ .../extern/link-extern-crate-title-33178.rs | 13 ++++++++++ tests/rustdoc/extern/pub-extern-crate.rs | 9 +++++++ tests/rustdoc/extern/unsafe-extern-blocks.rs | 29 ++++++++++++++++++++++ tests/rustdoc/extern/unused-extern-crate.rs | 2 ++ tests/rustdoc/external-cross.rs | 10 -------- tests/rustdoc/external-doc.rs | 14 ----------- tests/rustdoc/hidden-extern-34025.rs | 13 ---------- tests/rustdoc/link-extern-crate-33178.rs | 17 ------------- tests/rustdoc/link-extern-crate-item-30109.rs | 17 ------------- tests/rustdoc/link-extern-crate-title-33178.rs | 13 ---------- tests/rustdoc/pub-extern-crate.rs | 9 ------- tests/rustdoc/unsafe-extern-blocks.rs | 29 ---------------------- tests/rustdoc/unused-extern-crate.rs | 2 -- 56 files changed, 293 insertions(+), 287 deletions(-) delete mode 100644 tests/rustdoc/anchors/extern-default-method.no_href_on_anchor.html delete mode 100644 tests/rustdoc/auxiliary/extern-links.rs delete mode 100644 tests/rustdoc/auxiliary/external-cross-doc.md delete mode 100644 tests/rustdoc/auxiliary/external-cross.rs delete mode 100644 tests/rustdoc/auxiliary/external-doc.md delete mode 100644 tests/rustdoc/auxiliary/html_root.rs delete mode 100644 tests/rustdoc/auxiliary/issue-30109-1.rs delete mode 100644 tests/rustdoc/auxiliary/no_html_root.rs delete mode 100644 tests/rustdoc/auxiliary/panic-item.rs delete mode 100644 tests/rustdoc/auxiliary/pub-extern-crate.rs delete mode 100644 tests/rustdoc/auxiliary/rustdoc-extern-default-method.rs delete mode 100644 tests/rustdoc/auxiliary/rustdoc-extern-method.rs delete mode 100644 tests/rustdoc/extern-default-method.rs delete mode 100644 tests/rustdoc/extern-fn-22038.rs delete mode 100644 tests/rustdoc/extern-html-root-url-precedence.rs delete mode 100644 tests/rustdoc/extern-html-root-url.rs delete mode 100644 tests/rustdoc/extern-links.rs delete mode 100644 tests/rustdoc/extern-method.rs create mode 100644 tests/rustdoc/extern/auxiliary/empty.rs create mode 100644 tests/rustdoc/extern/auxiliary/extern-links.rs create mode 100644 tests/rustdoc/extern/auxiliary/external-cross-doc.md create mode 100644 tests/rustdoc/extern/auxiliary/external-cross.rs create mode 100644 tests/rustdoc/extern/auxiliary/external-doc.md create mode 100644 tests/rustdoc/extern/auxiliary/html_root.rs create mode 100644 tests/rustdoc/extern/auxiliary/issue-30109-1.rs create mode 100644 tests/rustdoc/extern/auxiliary/no_html_root.rs create mode 100644 tests/rustdoc/extern/auxiliary/panic-item.rs create mode 100644 tests/rustdoc/extern/auxiliary/pub-extern-crate.rs create mode 100644 tests/rustdoc/extern/auxiliary/rustdoc-extern-default-method.rs create mode 100644 tests/rustdoc/extern/auxiliary/rustdoc-extern-method.rs create mode 100644 tests/rustdoc/extern/auxiliary/variant-struct.rs create mode 100644 tests/rustdoc/extern/extern-default-method.no_href_on_anchor.html create mode 100644 tests/rustdoc/extern/extern-default-method.rs create mode 100644 tests/rustdoc/extern/extern-fn-22038.rs create mode 100644 tests/rustdoc/extern/extern-html-root-url-precedence.rs create mode 100644 tests/rustdoc/extern/extern-html-root-url.rs create mode 100644 tests/rustdoc/extern/extern-links.rs create mode 100644 tests/rustdoc/extern/extern-method.rs create mode 100644 tests/rustdoc/extern/external-cross.rs create mode 100644 tests/rustdoc/extern/external-doc.rs create mode 100644 tests/rustdoc/extern/hidden-extern-34025.rs create mode 100644 tests/rustdoc/extern/link-extern-crate-33178.rs create mode 100644 tests/rustdoc/extern/link-extern-crate-item-30109.rs create mode 100644 tests/rustdoc/extern/link-extern-crate-title-33178.rs create mode 100644 tests/rustdoc/extern/pub-extern-crate.rs create mode 100644 tests/rustdoc/extern/unsafe-extern-blocks.rs create mode 100644 tests/rustdoc/extern/unused-extern-crate.rs delete mode 100644 tests/rustdoc/external-cross.rs delete mode 100644 tests/rustdoc/external-doc.rs delete mode 100644 tests/rustdoc/hidden-extern-34025.rs delete mode 100644 tests/rustdoc/link-extern-crate-33178.rs delete mode 100644 tests/rustdoc/link-extern-crate-item-30109.rs delete mode 100644 tests/rustdoc/link-extern-crate-title-33178.rs delete mode 100644 tests/rustdoc/pub-extern-crate.rs delete mode 100644 tests/rustdoc/unsafe-extern-blocks.rs delete mode 100644 tests/rustdoc/unused-extern-crate.rs diff --git a/tests/rustdoc/anchors/extern-default-method.no_href_on_anchor.html b/tests/rustdoc/anchors/extern-default-method.no_href_on_anchor.html deleted file mode 100644 index ef14836ccb8..00000000000 --- a/tests/rustdoc/anchors/extern-default-method.no_href_on_anchor.html +++ /dev/null @@ -1 +0,0 @@ -provided(&self) \ No newline at end of file diff --git a/tests/rustdoc/auxiliary/extern-links.rs b/tests/rustdoc/auxiliary/extern-links.rs deleted file mode 100644 index 4a835673a59..00000000000 --- a/tests/rustdoc/auxiliary/extern-links.rs +++ /dev/null @@ -1 +0,0 @@ -pub struct Foo; diff --git a/tests/rustdoc/auxiliary/external-cross-doc.md b/tests/rustdoc/auxiliary/external-cross-doc.md deleted file mode 100644 index d3c85326559..00000000000 --- a/tests/rustdoc/auxiliary/external-cross-doc.md +++ /dev/null @@ -1,4 +0,0 @@ -# Cross-crate imported docs - -This file is to make sure `#[doc = include_str!("file.md")]` works when you re-export an item with included -docs. diff --git a/tests/rustdoc/auxiliary/external-cross.rs b/tests/rustdoc/auxiliary/external-cross.rs deleted file mode 100644 index 5de63cdabc6..00000000000 --- a/tests/rustdoc/auxiliary/external-cross.rs +++ /dev/null @@ -1,3 +0,0 @@ -#[deny(missing_docs)] -#[doc = include_str!("external-cross-doc.md")] -pub struct NeedMoreDocs; diff --git a/tests/rustdoc/auxiliary/external-doc.md b/tests/rustdoc/auxiliary/external-doc.md deleted file mode 100644 index babde0a05ad..00000000000 --- a/tests/rustdoc/auxiliary/external-doc.md +++ /dev/null @@ -1,3 +0,0 @@ -# External Docs - -This file is here to test the `#[doc = include_str!("file")]` attribute. diff --git a/tests/rustdoc/auxiliary/html_root.rs b/tests/rustdoc/auxiliary/html_root.rs deleted file mode 100644 index 4eb0b700f8f..00000000000 --- a/tests/rustdoc/auxiliary/html_root.rs +++ /dev/null @@ -1,2 +0,0 @@ -#![doc(html_root_url="https://example.com/html_root")] -pub fn foo() {} diff --git a/tests/rustdoc/auxiliary/issue-30109-1.rs b/tests/rustdoc/auxiliary/issue-30109-1.rs deleted file mode 100644 index ca05a6a9076..00000000000 --- a/tests/rustdoc/auxiliary/issue-30109-1.rs +++ /dev/null @@ -1 +0,0 @@ -pub struct Bar; diff --git a/tests/rustdoc/auxiliary/no_html_root.rs b/tests/rustdoc/auxiliary/no_html_root.rs deleted file mode 100644 index c5c0bc606cd..00000000000 --- a/tests/rustdoc/auxiliary/no_html_root.rs +++ /dev/null @@ -1 +0,0 @@ -pub fn bar() {} diff --git a/tests/rustdoc/auxiliary/panic-item.rs b/tests/rustdoc/auxiliary/panic-item.rs deleted file mode 100644 index ccf784f7284..00000000000 --- a/tests/rustdoc/auxiliary/panic-item.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ no-prefer-dynamic -#![crate_type = "lib"] -#![no_std] -#![feature(lang_items)] - -use core::panic::PanicInfo; -use core::sync::atomic::{self, Ordering}; - -#[panic_handler] -fn panic(_info: &PanicInfo) -> ! { - loop { - atomic::compiler_fence(Ordering::SeqCst); - } -} - -#[lang = "eh_personality"] -fn foo() {} diff --git a/tests/rustdoc/auxiliary/pub-extern-crate.rs b/tests/rustdoc/auxiliary/pub-extern-crate.rs deleted file mode 100644 index 8c89c8d6c76..00000000000 --- a/tests/rustdoc/auxiliary/pub-extern-crate.rs +++ /dev/null @@ -1,2 +0,0 @@ -#![crate_name = "inner"] -pub struct SomeStruct; diff --git a/tests/rustdoc/auxiliary/rustdoc-extern-default-method.rs b/tests/rustdoc/auxiliary/rustdoc-extern-default-method.rs deleted file mode 100644 index 12934238a8e..00000000000 --- a/tests/rustdoc/auxiliary/rustdoc-extern-default-method.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![crate_type="lib"] - -pub trait Trait { - fn provided(&self) {} -} - -pub struct Struct; - -impl Trait for Struct { - fn provided(&self) {} -} diff --git a/tests/rustdoc/auxiliary/rustdoc-extern-method.rs b/tests/rustdoc/auxiliary/rustdoc-extern-method.rs deleted file mode 100644 index e493048d9da..00000000000 --- a/tests/rustdoc/auxiliary/rustdoc-extern-method.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![crate_type="lib"] -#![feature(unboxed_closures)] - -pub trait Foo { - extern "rust-call" fn foo(&self, _: ()) -> i32; - extern "rust-call" fn foo_(&self, _: ()) -> i32 { 0 } -} diff --git a/tests/rustdoc/extern-default-method.rs b/tests/rustdoc/extern-default-method.rs deleted file mode 100644 index 1af9fab152e..00000000000 --- a/tests/rustdoc/extern-default-method.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ aux-build:rustdoc-extern-default-method.rs -//@ ignore-cross-compile -// ignore-tidy-linelength - -extern crate rustdoc_extern_default_method as ext; - -// For this test, the dependency is compiled but not documented. -// -// Still, the struct from the external crate and its impl should be documented since -// the struct is re-exported from this crate. -// However, the method in the trait impl should *not* have a link (an `href` attribute) to -// its corresponding item in the trait declaration since it would otherwise be broken. -// -// In older versions of rustdoc, the impl item (`a[@class="fn"]`) used to link to -// `#method.provided` – i.e. "to itself". Put in quotes since that was actually incorrect in -// general: If the type `Struct` also had an inherent method called `provided`, the impl item -// would link to that one even though those two methods are distinct items! - -//@ count extern_default_method/struct.Struct.html '//*[@id="method.provided"]' 1 -//@ count extern_default_method/struct.Struct.html '//*[@id="method.provided"]//a[@class="fn"]' 1 -//@ snapshot no_href_on_anchor - '//*[@id="method.provided"]//a[@class="fn"]' -//@ has extern_default_method/struct.Struct.html '//*[@id="method.provided"]//a[@class="anchor"]/@href' #method.provided -pub use ext::Struct; diff --git a/tests/rustdoc/extern-fn-22038.rs b/tests/rustdoc/extern-fn-22038.rs deleted file mode 100644 index 206c6e181d1..00000000000 --- a/tests/rustdoc/extern-fn-22038.rs +++ /dev/null @@ -1,22 +0,0 @@ -// https://github.com/rust-lang/rust/issues/22038 -#![crate_name="issue_22038"] - -extern "C" { - //@ has issue_22038/fn.foo1.html \ - // '//pre[@class="rust item-decl"]' 'pub unsafe extern "C" fn foo1()' - pub fn foo1(); -} - -extern "system" { - //@ has issue_22038/fn.foo2.html \ - // '//pre[@class="rust item-decl"]' 'pub unsafe extern "system" fn foo2()' - pub fn foo2(); -} - -//@ has issue_22038/fn.bar.html \ -// '//pre[@class="rust item-decl"]' 'pub extern "C" fn bar()' -pub extern "C" fn bar() {} - -//@ has issue_22038/fn.baz.html \ -// '//pre[@class="rust item-decl"]' 'pub extern "system" fn baz()' -pub extern "system" fn baz() {} diff --git a/tests/rustdoc/extern-html-root-url-precedence.rs b/tests/rustdoc/extern-html-root-url-precedence.rs deleted file mode 100644 index 93775087997..00000000000 --- a/tests/rustdoc/extern-html-root-url-precedence.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ compile-flags:-Z unstable-options --extern-html-root-url core=https://example.com/core/0.1.0 --extern-html-root-takes-precedence - -//@ has extern_html_root_url_precedence/index.html -// --extern-html-root should take precedence if `--takes-precedence` is passed -//@ has - '//a/@href' 'https://example.com/core/0.1.0/core/iter/index.html' -#[doc(no_inline)] -pub use std::iter; diff --git a/tests/rustdoc/extern-html-root-url.rs b/tests/rustdoc/extern-html-root-url.rs deleted file mode 100644 index a503e829de4..00000000000 --- a/tests/rustdoc/extern-html-root-url.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ compile-flags:-Z unstable-options --extern-html-root-url html_root=https://example.com/override --extern-html-root-url no_html_root=https://example.com/override -//@ aux-build:html_root.rs -//@ aux-build:no_html_root.rs -// NOTE: intentionally does not build any auxiliary docs - -extern crate html_root; -extern crate no_html_root; - -//@ has extern_html_root_url/index.html -// `html_root_url` should override `--extern-html-root-url` -//@ has - '//a/@href' 'https://example.com/html_root/html_root/fn.foo.html' -#[doc(no_inline)] -pub use html_root::foo; - -#[doc(no_inline)] -// `--extern-html-root-url` should apply if no `html_root_url` is given -//@ has - '//a/@href' 'https://example.com/override/no_html_root/fn.bar.html' -pub use no_html_root::bar; diff --git a/tests/rustdoc/extern-links.rs b/tests/rustdoc/extern-links.rs deleted file mode 100644 index d1fee224755..00000000000 --- a/tests/rustdoc/extern-links.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ aux-build:extern-links.rs -//@ ignore-cross-compile - -#![crate_name = "foo"] - -pub extern crate extern_links; - -//@ !has foo/index.html '//a' 'extern_links' -#[doc(no_inline)] -pub use extern_links as extern_links2; - -//@ !has foo/index.html '//a' 'Foo' -#[doc(no_inline)] -pub use extern_links::Foo; - -#[doc(hidden)] -pub mod hidden { - //@ !has foo/hidden/extern_links/index.html - //@ !has foo/hidden/extern_links/struct.Foo.html - pub use extern_links; -} diff --git a/tests/rustdoc/extern-method.rs b/tests/rustdoc/extern-method.rs deleted file mode 100644 index c3e042f2da8..00000000000 --- a/tests/rustdoc/extern-method.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ aux-build:rustdoc-extern-method.rs -//@ ignore-cross-compile - -#![feature(unboxed_closures)] - -extern crate rustdoc_extern_method as foo; - -//@ has extern_method/trait.Foo.html //pre "pub trait Foo" -//@ has - '//*[@id="tymethod.foo"]//h4[@class="code-header"]' 'extern "rust-call" fn foo' -//@ has - '//*[@id="method.foo_"]//h4[@class="code-header"]' 'extern "rust-call" fn foo_' -pub use foo::Foo; - -//@ has extern_method/trait.Bar.html //pre "pub trait Bar" -pub trait Bar { - //@ has - '//*[@id="tymethod.bar"]//h4[@class="code-header"]' 'extern "rust-call" fn bar' - extern "rust-call" fn bar(&self, _: ()); - //@ has - '//*[@id="method.bar_"]//h4[@class="code-header"]' 'extern "rust-call" fn bar_' - extern "rust-call" fn bar_(&self, _: ()) { } -} diff --git a/tests/rustdoc/extern/auxiliary/empty.rs b/tests/rustdoc/extern/auxiliary/empty.rs new file mode 100644 index 00000000000..d11c69f812a --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/empty.rs @@ -0,0 +1 @@ +// intentionally empty diff --git a/tests/rustdoc/extern/auxiliary/extern-links.rs b/tests/rustdoc/extern/auxiliary/extern-links.rs new file mode 100644 index 00000000000..4a835673a59 --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/extern-links.rs @@ -0,0 +1 @@ +pub struct Foo; diff --git a/tests/rustdoc/extern/auxiliary/external-cross-doc.md b/tests/rustdoc/extern/auxiliary/external-cross-doc.md new file mode 100644 index 00000000000..d3c85326559 --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/external-cross-doc.md @@ -0,0 +1,4 @@ +# Cross-crate imported docs + +This file is to make sure `#[doc = include_str!("file.md")]` works when you re-export an item with included +docs. diff --git a/tests/rustdoc/extern/auxiliary/external-cross.rs b/tests/rustdoc/extern/auxiliary/external-cross.rs new file mode 100644 index 00000000000..5de63cdabc6 --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/external-cross.rs @@ -0,0 +1,3 @@ +#[deny(missing_docs)] +#[doc = include_str!("external-cross-doc.md")] +pub struct NeedMoreDocs; diff --git a/tests/rustdoc/extern/auxiliary/external-doc.md b/tests/rustdoc/extern/auxiliary/external-doc.md new file mode 100644 index 00000000000..babde0a05ad --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/external-doc.md @@ -0,0 +1,3 @@ +# External Docs + +This file is here to test the `#[doc = include_str!("file")]` attribute. diff --git a/tests/rustdoc/extern/auxiliary/html_root.rs b/tests/rustdoc/extern/auxiliary/html_root.rs new file mode 100644 index 00000000000..4eb0b700f8f --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/html_root.rs @@ -0,0 +1,2 @@ +#![doc(html_root_url="https://example.com/html_root")] +pub fn foo() {} diff --git a/tests/rustdoc/extern/auxiliary/issue-30109-1.rs b/tests/rustdoc/extern/auxiliary/issue-30109-1.rs new file mode 100644 index 00000000000..ca05a6a9076 --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/issue-30109-1.rs @@ -0,0 +1 @@ +pub struct Bar; diff --git a/tests/rustdoc/extern/auxiliary/no_html_root.rs b/tests/rustdoc/extern/auxiliary/no_html_root.rs new file mode 100644 index 00000000000..c5c0bc606cd --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/no_html_root.rs @@ -0,0 +1 @@ +pub fn bar() {} diff --git a/tests/rustdoc/extern/auxiliary/panic-item.rs b/tests/rustdoc/extern/auxiliary/panic-item.rs new file mode 100644 index 00000000000..ccf784f7284 --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/panic-item.rs @@ -0,0 +1,17 @@ +//@ no-prefer-dynamic +#![crate_type = "lib"] +#![no_std] +#![feature(lang_items)] + +use core::panic::PanicInfo; +use core::sync::atomic::{self, Ordering}; + +#[panic_handler] +fn panic(_info: &PanicInfo) -> ! { + loop { + atomic::compiler_fence(Ordering::SeqCst); + } +} + +#[lang = "eh_personality"] +fn foo() {} diff --git a/tests/rustdoc/extern/auxiliary/pub-extern-crate.rs b/tests/rustdoc/extern/auxiliary/pub-extern-crate.rs new file mode 100644 index 00000000000..8c89c8d6c76 --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/pub-extern-crate.rs @@ -0,0 +1,2 @@ +#![crate_name = "inner"] +pub struct SomeStruct; diff --git a/tests/rustdoc/extern/auxiliary/rustdoc-extern-default-method.rs b/tests/rustdoc/extern/auxiliary/rustdoc-extern-default-method.rs new file mode 100644 index 00000000000..12934238a8e --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/rustdoc-extern-default-method.rs @@ -0,0 +1,11 @@ +#![crate_type="lib"] + +pub trait Trait { + fn provided(&self) {} +} + +pub struct Struct; + +impl Trait for Struct { + fn provided(&self) {} +} diff --git a/tests/rustdoc/extern/auxiliary/rustdoc-extern-method.rs b/tests/rustdoc/extern/auxiliary/rustdoc-extern-method.rs new file mode 100644 index 00000000000..e493048d9da --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/rustdoc-extern-method.rs @@ -0,0 +1,7 @@ +#![crate_type="lib"] +#![feature(unboxed_closures)] + +pub trait Foo { + extern "rust-call" fn foo(&self, _: ()) -> i32; + extern "rust-call" fn foo_(&self, _: ()) -> i32 { 0 } +} diff --git a/tests/rustdoc/extern/auxiliary/variant-struct.rs b/tests/rustdoc/extern/auxiliary/variant-struct.rs new file mode 100644 index 00000000000..0f3d2e5f1b7 --- /dev/null +++ b/tests/rustdoc/extern/auxiliary/variant-struct.rs @@ -0,0 +1,5 @@ +pub enum Foo { + Bar { + qux: (), + } +} diff --git a/tests/rustdoc/extern/extern-default-method.no_href_on_anchor.html b/tests/rustdoc/extern/extern-default-method.no_href_on_anchor.html new file mode 100644 index 00000000000..ef14836ccb8 --- /dev/null +++ b/tests/rustdoc/extern/extern-default-method.no_href_on_anchor.html @@ -0,0 +1 @@ +provided(&self) \ No newline at end of file diff --git a/tests/rustdoc/extern/extern-default-method.rs b/tests/rustdoc/extern/extern-default-method.rs new file mode 100644 index 00000000000..1af9fab152e --- /dev/null +++ b/tests/rustdoc/extern/extern-default-method.rs @@ -0,0 +1,23 @@ +//@ aux-build:rustdoc-extern-default-method.rs +//@ ignore-cross-compile +// ignore-tidy-linelength + +extern crate rustdoc_extern_default_method as ext; + +// For this test, the dependency is compiled but not documented. +// +// Still, the struct from the external crate and its impl should be documented since +// the struct is re-exported from this crate. +// However, the method in the trait impl should *not* have a link (an `href` attribute) to +// its corresponding item in the trait declaration since it would otherwise be broken. +// +// In older versions of rustdoc, the impl item (`a[@class="fn"]`) used to link to +// `#method.provided` – i.e. "to itself". Put in quotes since that was actually incorrect in +// general: If the type `Struct` also had an inherent method called `provided`, the impl item +// would link to that one even though those two methods are distinct items! + +//@ count extern_default_method/struct.Struct.html '//*[@id="method.provided"]' 1 +//@ count extern_default_method/struct.Struct.html '//*[@id="method.provided"]//a[@class="fn"]' 1 +//@ snapshot no_href_on_anchor - '//*[@id="method.provided"]//a[@class="fn"]' +//@ has extern_default_method/struct.Struct.html '//*[@id="method.provided"]//a[@class="anchor"]/@href' #method.provided +pub use ext::Struct; diff --git a/tests/rustdoc/extern/extern-fn-22038.rs b/tests/rustdoc/extern/extern-fn-22038.rs new file mode 100644 index 00000000000..206c6e181d1 --- /dev/null +++ b/tests/rustdoc/extern/extern-fn-22038.rs @@ -0,0 +1,22 @@ +// https://github.com/rust-lang/rust/issues/22038 +#![crate_name="issue_22038"] + +extern "C" { + //@ has issue_22038/fn.foo1.html \ + // '//pre[@class="rust item-decl"]' 'pub unsafe extern "C" fn foo1()' + pub fn foo1(); +} + +extern "system" { + //@ has issue_22038/fn.foo2.html \ + // '//pre[@class="rust item-decl"]' 'pub unsafe extern "system" fn foo2()' + pub fn foo2(); +} + +//@ has issue_22038/fn.bar.html \ +// '//pre[@class="rust item-decl"]' 'pub extern "C" fn bar()' +pub extern "C" fn bar() {} + +//@ has issue_22038/fn.baz.html \ +// '//pre[@class="rust item-decl"]' 'pub extern "system" fn baz()' +pub extern "system" fn baz() {} diff --git a/tests/rustdoc/extern/extern-html-root-url-precedence.rs b/tests/rustdoc/extern/extern-html-root-url-precedence.rs new file mode 100644 index 00000000000..93775087997 --- /dev/null +++ b/tests/rustdoc/extern/extern-html-root-url-precedence.rs @@ -0,0 +1,7 @@ +//@ compile-flags:-Z unstable-options --extern-html-root-url core=https://example.com/core/0.1.0 --extern-html-root-takes-precedence + +//@ has extern_html_root_url_precedence/index.html +// --extern-html-root should take precedence if `--takes-precedence` is passed +//@ has - '//a/@href' 'https://example.com/core/0.1.0/core/iter/index.html' +#[doc(no_inline)] +pub use std::iter; diff --git a/tests/rustdoc/extern/extern-html-root-url.rs b/tests/rustdoc/extern/extern-html-root-url.rs new file mode 100644 index 00000000000..a503e829de4 --- /dev/null +++ b/tests/rustdoc/extern/extern-html-root-url.rs @@ -0,0 +1,18 @@ +//@ compile-flags:-Z unstable-options --extern-html-root-url html_root=https://example.com/override --extern-html-root-url no_html_root=https://example.com/override +//@ aux-build:html_root.rs +//@ aux-build:no_html_root.rs +// NOTE: intentionally does not build any auxiliary docs + +extern crate html_root; +extern crate no_html_root; + +//@ has extern_html_root_url/index.html +// `html_root_url` should override `--extern-html-root-url` +//@ has - '//a/@href' 'https://example.com/html_root/html_root/fn.foo.html' +#[doc(no_inline)] +pub use html_root::foo; + +#[doc(no_inline)] +// `--extern-html-root-url` should apply if no `html_root_url` is given +//@ has - '//a/@href' 'https://example.com/override/no_html_root/fn.bar.html' +pub use no_html_root::bar; diff --git a/tests/rustdoc/extern/extern-links.rs b/tests/rustdoc/extern/extern-links.rs new file mode 100644 index 00000000000..d1fee224755 --- /dev/null +++ b/tests/rustdoc/extern/extern-links.rs @@ -0,0 +1,21 @@ +//@ aux-build:extern-links.rs +//@ ignore-cross-compile + +#![crate_name = "foo"] + +pub extern crate extern_links; + +//@ !has foo/index.html '//a' 'extern_links' +#[doc(no_inline)] +pub use extern_links as extern_links2; + +//@ !has foo/index.html '//a' 'Foo' +#[doc(no_inline)] +pub use extern_links::Foo; + +#[doc(hidden)] +pub mod hidden { + //@ !has foo/hidden/extern_links/index.html + //@ !has foo/hidden/extern_links/struct.Foo.html + pub use extern_links; +} diff --git a/tests/rustdoc/extern/extern-method.rs b/tests/rustdoc/extern/extern-method.rs new file mode 100644 index 00000000000..c3e042f2da8 --- /dev/null +++ b/tests/rustdoc/extern/extern-method.rs @@ -0,0 +1,19 @@ +//@ aux-build:rustdoc-extern-method.rs +//@ ignore-cross-compile + +#![feature(unboxed_closures)] + +extern crate rustdoc_extern_method as foo; + +//@ has extern_method/trait.Foo.html //pre "pub trait Foo" +//@ has - '//*[@id="tymethod.foo"]//h4[@class="code-header"]' 'extern "rust-call" fn foo' +//@ has - '//*[@id="method.foo_"]//h4[@class="code-header"]' 'extern "rust-call" fn foo_' +pub use foo::Foo; + +//@ has extern_method/trait.Bar.html //pre "pub trait Bar" +pub trait Bar { + //@ has - '//*[@id="tymethod.bar"]//h4[@class="code-header"]' 'extern "rust-call" fn bar' + extern "rust-call" fn bar(&self, _: ()); + //@ has - '//*[@id="method.bar_"]//h4[@class="code-header"]' 'extern "rust-call" fn bar_' + extern "rust-call" fn bar_(&self, _: ()) { } +} diff --git a/tests/rustdoc/extern/external-cross.rs b/tests/rustdoc/extern/external-cross.rs new file mode 100644 index 00000000000..13646ec38cf --- /dev/null +++ b/tests/rustdoc/extern/external-cross.rs @@ -0,0 +1,10 @@ +//@ aux-build:external-cross.rs +//@ ignore-cross-compile + +#![crate_name="host"] + +extern crate external_cross; + +//@ has host/struct.NeedMoreDocs.html +//@ has - '//h2' 'Cross-crate imported docs' +pub use external_cross::NeedMoreDocs; diff --git a/tests/rustdoc/extern/external-doc.rs b/tests/rustdoc/extern/external-doc.rs new file mode 100644 index 00000000000..c81aa17ed5a --- /dev/null +++ b/tests/rustdoc/extern/external-doc.rs @@ -0,0 +1,14 @@ +//@ has external_doc/struct.IncludeStrDocs.html +//@ has - '//h2' 'External Docs' +//@ has - '//h3' 'Inline Docs' +#[doc = include_str!("auxiliary/external-doc.md")] +/// ## Inline Docs +pub struct IncludeStrDocs; + +macro_rules! dir { () => { "auxiliary" } } + +//@ has external_doc/struct.EagerExpansion.html +//@ has - '//h2' 'External Docs' +#[doc = include_str!(concat!(dir!(), "/external-doc.md"))] +/// ## Inline Docs +pub struct EagerExpansion; diff --git a/tests/rustdoc/extern/hidden-extern-34025.rs b/tests/rustdoc/extern/hidden-extern-34025.rs new file mode 100644 index 00000000000..2a7b21a874d --- /dev/null +++ b/tests/rustdoc/extern/hidden-extern-34025.rs @@ -0,0 +1,13 @@ +// https://github.com/rust-lang/rust/issues/34025 +#![crate_name = "foo"] + +//@ !has 'foo/sys/index.html' +//@ !has 'foo/sys/sidebar-items.js' +#[doc(hidden)] +pub mod sys { + extern "C" { + //@ !has 'foo/sys/fn.foo.html' + #[doc(hidden)] + pub fn foo(); + } +} diff --git a/tests/rustdoc/extern/link-extern-crate-33178.rs b/tests/rustdoc/extern/link-extern-crate-33178.rs new file mode 100644 index 00000000000..94822798af3 --- /dev/null +++ b/tests/rustdoc/extern/link-extern-crate-33178.rs @@ -0,0 +1,17 @@ +//@ aux-build:empty.rs +//@ aux-build:variant-struct.rs +//@ build-aux-docs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/33178 +#![crate_name="issue_33178"] + +//@ has issue_33178/index.html +//@ has - '//a[@title="mod empty"][@href="../empty/index.html"]' empty +pub extern crate empty; + +//@ has - '//a[@title="mod variant_struct"][@href="../variant_struct/index.html"]' variant_struct +pub extern crate variant_struct as foo; + +//@ has - '//a[@title="mod issue_33178"][@href="index.html"]' self +pub extern crate self as bar; diff --git a/tests/rustdoc/extern/link-extern-crate-item-30109.rs b/tests/rustdoc/extern/link-extern-crate-item-30109.rs new file mode 100644 index 00000000000..544cfa14971 --- /dev/null +++ b/tests/rustdoc/extern/link-extern-crate-item-30109.rs @@ -0,0 +1,17 @@ +//@ build-aux-docs +//@ aux-build:issue-30109-1.rs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/30109 +#![crate_name="issue_30109"] + +pub mod quux { + extern crate issue_30109_1 as bar; + use self::bar::Bar; + + pub trait Foo {} + + //@ has issue_30109/quux/trait.Foo.html \ + // '//a/@href' '../issue_30109_1/struct.Bar.html' + impl Foo for Bar {} +} diff --git a/tests/rustdoc/extern/link-extern-crate-title-33178.rs b/tests/rustdoc/extern/link-extern-crate-title-33178.rs new file mode 100644 index 00000000000..39c4fec1cd9 --- /dev/null +++ b/tests/rustdoc/extern/link-extern-crate-title-33178.rs @@ -0,0 +1,13 @@ +//@ aux-build:empty.rs +//@ aux-build:variant-struct.rs +//@ ignore-cross-compile + +// https://github.com/rust-lang/rust/issues/33178 +#![crate_name="issue_33178_1"] + +//@ has issue_33178_1/index.html +//@ !has - //a/@title empty +pub extern crate empty; + +//@ !has - //a/@title variant_struct +pub extern crate variant_struct as foo; diff --git a/tests/rustdoc/extern/pub-extern-crate.rs b/tests/rustdoc/extern/pub-extern-crate.rs new file mode 100644 index 00000000000..05f70301e33 --- /dev/null +++ b/tests/rustdoc/extern/pub-extern-crate.rs @@ -0,0 +1,9 @@ +//@ aux-build:pub-extern-crate.rs + +//@ has pub_extern_crate/index.html +//@ !has - '//code' 'pub extern crate inner' +//@ has - '//a/@href' 'inner/index.html' +//@ has pub_extern_crate/inner/index.html +//@ has pub_extern_crate/inner/struct.SomeStruct.html +#[doc(inline)] +pub extern crate inner; diff --git a/tests/rustdoc/extern/unsafe-extern-blocks.rs b/tests/rustdoc/extern/unsafe-extern-blocks.rs new file mode 100644 index 00000000000..9a4e292dc83 --- /dev/null +++ b/tests/rustdoc/extern/unsafe-extern-blocks.rs @@ -0,0 +1,29 @@ +// Test to ensure the feature is working as expected. + +#![crate_name = "foo"] + +//@ has 'foo/index.html' + +// First we check that both the static and the function have a "sup" element +// to tell they're unsafe. + +//@ count - '//dl[@class="item-table"]//sup[@title="unsafe static"]' 1 +//@ has - '//dl[@class="item-table"]//sup[@title="unsafe static"]' '⚠' +//@ count - '//dl[@class="item-table"]//sup[@title="unsafe function"]' 1 +//@ has - '//dl[@class="item-table"]//sup[@title="unsafe function"]' '⚠' + +unsafe extern "C" { + //@ has 'foo/static.FOO.html' + //@ has - '//pre[@class="rust item-decl"]' 'pub static FOO: i32' + pub safe static FOO: i32; + //@ has 'foo/static.BAR.html' + //@ has - '//pre[@class="rust item-decl"]' 'pub unsafe static BAR: i32' + pub static BAR: i32; + + //@ has 'foo/fn.foo.html' + //@ has - '//pre[@class="rust item-decl"]' 'pub extern "C" fn foo()' + pub safe fn foo(); + //@ has 'foo/fn.bar.html' + //@ has - '//pre[@class="rust item-decl"]' 'pub unsafe extern "C" fn bar()' + pub fn bar(); +} diff --git a/tests/rustdoc/extern/unused-extern-crate.rs b/tests/rustdoc/extern/unused-extern-crate.rs new file mode 100644 index 00000000000..cdc00fd313a --- /dev/null +++ b/tests/rustdoc/extern/unused-extern-crate.rs @@ -0,0 +1,2 @@ +//@ aux-crate:panic_item=panic-item.rs +//@ has unused_extern_crate/index.html diff --git a/tests/rustdoc/external-cross.rs b/tests/rustdoc/external-cross.rs deleted file mode 100644 index 13646ec38cf..00000000000 --- a/tests/rustdoc/external-cross.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ aux-build:external-cross.rs -//@ ignore-cross-compile - -#![crate_name="host"] - -extern crate external_cross; - -//@ has host/struct.NeedMoreDocs.html -//@ has - '//h2' 'Cross-crate imported docs' -pub use external_cross::NeedMoreDocs; diff --git a/tests/rustdoc/external-doc.rs b/tests/rustdoc/external-doc.rs deleted file mode 100644 index c81aa17ed5a..00000000000 --- a/tests/rustdoc/external-doc.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ has external_doc/struct.IncludeStrDocs.html -//@ has - '//h2' 'External Docs' -//@ has - '//h3' 'Inline Docs' -#[doc = include_str!("auxiliary/external-doc.md")] -/// ## Inline Docs -pub struct IncludeStrDocs; - -macro_rules! dir { () => { "auxiliary" } } - -//@ has external_doc/struct.EagerExpansion.html -//@ has - '//h2' 'External Docs' -#[doc = include_str!(concat!(dir!(), "/external-doc.md"))] -/// ## Inline Docs -pub struct EagerExpansion; diff --git a/tests/rustdoc/hidden-extern-34025.rs b/tests/rustdoc/hidden-extern-34025.rs deleted file mode 100644 index 2a7b21a874d..00000000000 --- a/tests/rustdoc/hidden-extern-34025.rs +++ /dev/null @@ -1,13 +0,0 @@ -// https://github.com/rust-lang/rust/issues/34025 -#![crate_name = "foo"] - -//@ !has 'foo/sys/index.html' -//@ !has 'foo/sys/sidebar-items.js' -#[doc(hidden)] -pub mod sys { - extern "C" { - //@ !has 'foo/sys/fn.foo.html' - #[doc(hidden)] - pub fn foo(); - } -} diff --git a/tests/rustdoc/link-extern-crate-33178.rs b/tests/rustdoc/link-extern-crate-33178.rs deleted file mode 100644 index 94822798af3..00000000000 --- a/tests/rustdoc/link-extern-crate-33178.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ aux-build:empty.rs -//@ aux-build:variant-struct.rs -//@ build-aux-docs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/33178 -#![crate_name="issue_33178"] - -//@ has issue_33178/index.html -//@ has - '//a[@title="mod empty"][@href="../empty/index.html"]' empty -pub extern crate empty; - -//@ has - '//a[@title="mod variant_struct"][@href="../variant_struct/index.html"]' variant_struct -pub extern crate variant_struct as foo; - -//@ has - '//a[@title="mod issue_33178"][@href="index.html"]' self -pub extern crate self as bar; diff --git a/tests/rustdoc/link-extern-crate-item-30109.rs b/tests/rustdoc/link-extern-crate-item-30109.rs deleted file mode 100644 index 544cfa14971..00000000000 --- a/tests/rustdoc/link-extern-crate-item-30109.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ build-aux-docs -//@ aux-build:issue-30109-1.rs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/30109 -#![crate_name="issue_30109"] - -pub mod quux { - extern crate issue_30109_1 as bar; - use self::bar::Bar; - - pub trait Foo {} - - //@ has issue_30109/quux/trait.Foo.html \ - // '//a/@href' '../issue_30109_1/struct.Bar.html' - impl Foo for Bar {} -} diff --git a/tests/rustdoc/link-extern-crate-title-33178.rs b/tests/rustdoc/link-extern-crate-title-33178.rs deleted file mode 100644 index 39c4fec1cd9..00000000000 --- a/tests/rustdoc/link-extern-crate-title-33178.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ aux-build:empty.rs -//@ aux-build:variant-struct.rs -//@ ignore-cross-compile - -// https://github.com/rust-lang/rust/issues/33178 -#![crate_name="issue_33178_1"] - -//@ has issue_33178_1/index.html -//@ !has - //a/@title empty -pub extern crate empty; - -//@ !has - //a/@title variant_struct -pub extern crate variant_struct as foo; diff --git a/tests/rustdoc/pub-extern-crate.rs b/tests/rustdoc/pub-extern-crate.rs deleted file mode 100644 index 05f70301e33..00000000000 --- a/tests/rustdoc/pub-extern-crate.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ aux-build:pub-extern-crate.rs - -//@ has pub_extern_crate/index.html -//@ !has - '//code' 'pub extern crate inner' -//@ has - '//a/@href' 'inner/index.html' -//@ has pub_extern_crate/inner/index.html -//@ has pub_extern_crate/inner/struct.SomeStruct.html -#[doc(inline)] -pub extern crate inner; diff --git a/tests/rustdoc/unsafe-extern-blocks.rs b/tests/rustdoc/unsafe-extern-blocks.rs deleted file mode 100644 index 9a4e292dc83..00000000000 --- a/tests/rustdoc/unsafe-extern-blocks.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Test to ensure the feature is working as expected. - -#![crate_name = "foo"] - -//@ has 'foo/index.html' - -// First we check that both the static and the function have a "sup" element -// to tell they're unsafe. - -//@ count - '//dl[@class="item-table"]//sup[@title="unsafe static"]' 1 -//@ has - '//dl[@class="item-table"]//sup[@title="unsafe static"]' '⚠' -//@ count - '//dl[@class="item-table"]//sup[@title="unsafe function"]' 1 -//@ has - '//dl[@class="item-table"]//sup[@title="unsafe function"]' '⚠' - -unsafe extern "C" { - //@ has 'foo/static.FOO.html' - //@ has - '//pre[@class="rust item-decl"]' 'pub static FOO: i32' - pub safe static FOO: i32; - //@ has 'foo/static.BAR.html' - //@ has - '//pre[@class="rust item-decl"]' 'pub unsafe static BAR: i32' - pub static BAR: i32; - - //@ has 'foo/fn.foo.html' - //@ has - '//pre[@class="rust item-decl"]' 'pub extern "C" fn foo()' - pub safe fn foo(); - //@ has 'foo/fn.bar.html' - //@ has - '//pre[@class="rust item-decl"]' 'pub unsafe extern "C" fn bar()' - pub fn bar(); -} diff --git a/tests/rustdoc/unused-extern-crate.rs b/tests/rustdoc/unused-extern-crate.rs deleted file mode 100644 index cdc00fd313a..00000000000 --- a/tests/rustdoc/unused-extern-crate.rs +++ /dev/null @@ -1,2 +0,0 @@ -//@ aux-crate:panic_item=panic-item.rs -//@ has unused_extern_crate/index.html -- cgit 1.4.1-3-g733a5