From ddfb581fb9e04595bc7cdb9d66792fdfdbec67ed Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 28 Nov 2020 20:25:41 -0500 Subject: Move `src/test/rustdoc` intra-doc link tests into a subdirectory They were starting to get unwieldy. --- .../auxiliary/intra-link-cross-crate-crate.rs | 5 - .../rustdoc/auxiliary/intra-link-extern-crate.rs | 3 - .../auxiliary/intra-link-proc-macro-macro.rs | 35 ------ src/test/rustdoc/auxiliary/intra-link-pub-use.rs | 4 - .../intra-link-reexport-additional-docs.rs | 6 -- .../auxiliary/intra-links-external-traits.rs | 6 -- src/test/rustdoc/auxiliary/my-core.rs | 19 ---- .../rustdoc/auxiliary/through-proc-macro-aux.rs | 20 ---- src/test/rustdoc/intra-doc-crate/additional_doc.rs | 10 -- .../intra-doc-crate/auxiliary/additional_doc.rs | 6 -- .../rustdoc/intra-doc-crate/auxiliary/hidden.rs | 19 ---- .../intra-doc-crate/auxiliary/intra-doc-basic.rs | 7 -- .../intra-doc-crate/auxiliary/macro_inner.rs | 10 -- .../rustdoc/intra-doc-crate/auxiliary/module.rs | 7 -- .../intra-doc-crate/auxiliary/proc_macro.rs | 20 ---- .../intra-doc-crate/auxiliary/submodule-inner.rs | 12 --- .../intra-doc-crate/auxiliary/submodule-outer.rs | 13 --- .../rustdoc/intra-doc-crate/auxiliary/traits.rs | 16 --- src/test/rustdoc/intra-doc-crate/basic.rs | 9 -- src/test/rustdoc/intra-doc-crate/hidden.rs | 10 -- src/test/rustdoc/intra-doc-crate/macro.rs | 12 --- src/test/rustdoc/intra-doc-crate/module.rs | 8 -- .../rustdoc/intra-doc-crate/submodule-inner.rs | 8 -- .../rustdoc/intra-doc-crate/submodule-outer.rs | 16 --- src/test/rustdoc/intra-doc-crate/traits.rs | 15 --- .../rustdoc/intra-doc-link-enum-struct-field.rs | 14 --- src/test/rustdoc/intra-doc-link-generic-params.rs | 62 ----------- src/test/rustdoc/intra-doc-link-mod-ambiguity.rs | 18 ---- src/test/rustdoc/intra-doc-link-private.rs | 6 -- src/test/rustdoc/intra-doc-link-true-false.rs | 10 -- src/test/rustdoc/intra-doc/anchors.rs | 12 +++ src/test/rustdoc/intra-doc/associated-defaults.rs | 27 +++++ src/test/rustdoc/intra-doc/associated-items.rs | 61 +++++++++++ .../intra-doc/auxiliary/intra-link-extern-crate.rs | 3 + .../intra-doc/auxiliary/intra-link-pub-use.rs | 4 + .../intra-link-reexport-additional-docs.rs | 6 ++ .../auxiliary/intra-links-external-traits.rs | 6 ++ src/test/rustdoc/intra-doc/auxiliary/my-core.rs | 19 ++++ .../intra-doc/auxiliary/proc-macro-macro.rs | 34 ++++++ .../intra-doc/auxiliary/through-proc-macro-aux.rs | 20 ++++ src/test/rustdoc/intra-doc/basic.rs | 84 +++++++++++++++ src/test/rustdoc/intra-doc/builtin-macros.rs | 3 + .../intra-doc/cross-crate/additional_doc.rs | 10 ++ .../cross-crate/auxiliary/additional_doc.rs | 6 ++ .../intra-doc/cross-crate/auxiliary/hidden.rs | 19 ++++ .../cross-crate/auxiliary/intra-doc-basic.rs | 7 ++ .../auxiliary/intra-link-cross-crate-crate.rs | 5 + .../intra-doc/cross-crate/auxiliary/macro_inner.rs | 10 ++ .../intra-doc/cross-crate/auxiliary/module.rs | 7 ++ .../intra-doc/cross-crate/auxiliary/proc_macro.rs | 20 ++++ .../cross-crate/auxiliary/submodule-inner.rs | 12 +++ .../cross-crate/auxiliary/submodule-outer.rs | 13 +++ .../intra-doc/cross-crate/auxiliary/traits.rs | 16 +++ src/test/rustdoc/intra-doc/cross-crate/basic.rs | 9 ++ src/test/rustdoc/intra-doc/cross-crate/crate.rs | 6 ++ src/test/rustdoc/intra-doc/cross-crate/hidden.rs | 10 ++ src/test/rustdoc/intra-doc/cross-crate/macro.rs | 12 +++ src/test/rustdoc/intra-doc/cross-crate/module.rs | 8 ++ .../intra-doc/cross-crate/submodule-inner.rs | 8 ++ .../intra-doc/cross-crate/submodule-outer.rs | 16 +++ src/test/rustdoc/intra-doc/cross-crate/traits.rs | 15 +++ .../rustdoc/intra-doc/disambiguators-removed.rs | 51 +++++++++ src/test/rustdoc/intra-doc/enum-struct-field.rs | 14 +++ src/test/rustdoc/intra-doc/extern-crate.rs | 9 ++ src/test/rustdoc/intra-doc/extern-type.rs | 17 +++ src/test/rustdoc/intra-doc/external-traits.rs | 12 +++ src/test/rustdoc/intra-doc/generic-params.rs | 62 +++++++++++ src/test/rustdoc/intra-doc/in-bodies.rs | 30 ++++++ src/test/rustdoc/intra-doc/libstd-re-export.rs | 3 + src/test/rustdoc/intra-doc/mod-ambiguity.rs | 16 +++ src/test/rustdoc/intra-doc/prim-assoc.rs | 5 + .../intra-doc/prim-methods-external-core.rs | 18 ++++ src/test/rustdoc/intra-doc/prim-methods-local.rs | 28 +++++ src/test/rustdoc/intra-doc/prim-methods.rs | 9 ++ src/test/rustdoc/intra-doc/prim-precedence.rs | 17 +++ .../intra-doc/primitive-non-default-impl.rs | 32 ++++++ .../rustdoc/intra-doc/private-failures-ignored.rs | 8 ++ src/test/rustdoc/intra-doc/private.rs | 6 ++ src/test/rustdoc/intra-doc/proc-macro.rs | 27 +++++ src/test/rustdoc/intra-doc/pub-use.rs | 27 +++++ .../rustdoc/intra-doc/reexport-additional-docs.rs | 23 ++++ src/test/rustdoc/intra-doc/self.rs | 117 +++++++++++++++++++++ src/test/rustdoc/intra-doc/through-proc-macro.rs | 12 +++ src/test/rustdoc/intra-doc/trait-impl.rs | 35 ++++++ src/test/rustdoc/intra-doc/trait-item.rs | 12 +++ src/test/rustdoc/intra-doc/true-false.rs | 10 ++ src/test/rustdoc/intra-link-associated-defaults.rs | 27 ----- src/test/rustdoc/intra-link-associated-items.rs | 61 ----------- src/test/rustdoc/intra-link-builtin-macros.rs | 3 - src/test/rustdoc/intra-link-cross-crate-crate.rs | 6 -- .../rustdoc/intra-link-disambiguators-removed.rs | 51 --------- src/test/rustdoc/intra-link-extern-crate.rs | 9 -- src/test/rustdoc/intra-link-extern-type.rs | 18 ---- src/test/rustdoc/intra-link-in-bodies.rs | 30 ------ src/test/rustdoc/intra-link-libstd-re-export.rs | 3 - src/test/rustdoc/intra-link-prim-assoc.rs | 5 - .../intra-link-prim-methods-external-core.rs | 18 ---- src/test/rustdoc/intra-link-prim-methods-local.rs | 28 ----- src/test/rustdoc/intra-link-prim-methods.rs | 9 -- src/test/rustdoc/intra-link-prim-precedence.rs | 17 --- .../intra-link-primitive-non-default-impl.rs | 32 ------ src/test/rustdoc/intra-link-private.rs | 8 -- src/test/rustdoc/intra-link-proc-macro.rs | 27 ----- src/test/rustdoc/intra-link-pub-use.rs | 27 ----- .../rustdoc/intra-link-reexport-additional-docs.rs | 23 ---- src/test/rustdoc/intra-link-self.rs | 117 --------------------- src/test/rustdoc/intra-link-trait-impl.rs | 35 ------ src/test/rustdoc/intra-link-trait-item.rs | 12 --- src/test/rustdoc/intra-links-anchors.rs | 12 --- src/test/rustdoc/intra-links-external-traits.rs | 12 --- src/test/rustdoc/intra-links.rs | 84 --------------- src/test/rustdoc/through-proc-macro.rs | 12 --- 112 files changed, 1088 insertions(+), 1092 deletions(-) delete mode 100644 src/test/rustdoc/auxiliary/intra-link-cross-crate-crate.rs delete mode 100644 src/test/rustdoc/auxiliary/intra-link-extern-crate.rs delete mode 100644 src/test/rustdoc/auxiliary/intra-link-proc-macro-macro.rs delete mode 100644 src/test/rustdoc/auxiliary/intra-link-pub-use.rs delete mode 100644 src/test/rustdoc/auxiliary/intra-link-reexport-additional-docs.rs delete mode 100644 src/test/rustdoc/auxiliary/intra-links-external-traits.rs delete mode 100644 src/test/rustdoc/auxiliary/my-core.rs delete mode 100644 src/test/rustdoc/auxiliary/through-proc-macro-aux.rs delete mode 100644 src/test/rustdoc/intra-doc-crate/additional_doc.rs delete mode 100644 src/test/rustdoc/intra-doc-crate/auxiliary/additional_doc.rs delete mode 100644 src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs delete mode 100644 src/test/rustdoc/intra-doc-crate/auxiliary/intra-doc-basic.rs delete mode 100644 src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs delete mode 100644 src/test/rustdoc/intra-doc-crate/auxiliary/module.rs delete mode 100644 src/test/rustdoc/intra-doc-crate/auxiliary/proc_macro.rs delete mode 100644 src/test/rustdoc/intra-doc-crate/auxiliary/submodule-inner.rs delete mode 100644 src/test/rustdoc/intra-doc-crate/auxiliary/submodule-outer.rs delete mode 100644 src/test/rustdoc/intra-doc-crate/auxiliary/traits.rs delete mode 100644 src/test/rustdoc/intra-doc-crate/basic.rs delete mode 100644 src/test/rustdoc/intra-doc-crate/hidden.rs delete mode 100644 src/test/rustdoc/intra-doc-crate/macro.rs delete mode 100644 src/test/rustdoc/intra-doc-crate/module.rs delete mode 100644 src/test/rustdoc/intra-doc-crate/submodule-inner.rs delete mode 100644 src/test/rustdoc/intra-doc-crate/submodule-outer.rs delete mode 100644 src/test/rustdoc/intra-doc-crate/traits.rs delete mode 100644 src/test/rustdoc/intra-doc-link-enum-struct-field.rs delete mode 100644 src/test/rustdoc/intra-doc-link-generic-params.rs delete mode 100644 src/test/rustdoc/intra-doc-link-mod-ambiguity.rs delete mode 100644 src/test/rustdoc/intra-doc-link-private.rs delete mode 100644 src/test/rustdoc/intra-doc-link-true-false.rs create mode 100644 src/test/rustdoc/intra-doc/anchors.rs create mode 100644 src/test/rustdoc/intra-doc/associated-defaults.rs create mode 100644 src/test/rustdoc/intra-doc/associated-items.rs create mode 100644 src/test/rustdoc/intra-doc/auxiliary/intra-link-extern-crate.rs create mode 100644 src/test/rustdoc/intra-doc/auxiliary/intra-link-pub-use.rs create mode 100644 src/test/rustdoc/intra-doc/auxiliary/intra-link-reexport-additional-docs.rs create mode 100644 src/test/rustdoc/intra-doc/auxiliary/intra-links-external-traits.rs create mode 100644 src/test/rustdoc/intra-doc/auxiliary/my-core.rs create mode 100644 src/test/rustdoc/intra-doc/auxiliary/proc-macro-macro.rs create mode 100644 src/test/rustdoc/intra-doc/auxiliary/through-proc-macro-aux.rs create mode 100644 src/test/rustdoc/intra-doc/basic.rs create mode 100644 src/test/rustdoc/intra-doc/builtin-macros.rs create mode 100644 src/test/rustdoc/intra-doc/cross-crate/additional_doc.rs create mode 100644 src/test/rustdoc/intra-doc/cross-crate/auxiliary/additional_doc.rs create mode 100644 src/test/rustdoc/intra-doc/cross-crate/auxiliary/hidden.rs create mode 100644 src/test/rustdoc/intra-doc/cross-crate/auxiliary/intra-doc-basic.rs create mode 100644 src/test/rustdoc/intra-doc/cross-crate/auxiliary/intra-link-cross-crate-crate.rs create mode 100644 src/test/rustdoc/intra-doc/cross-crate/auxiliary/macro_inner.rs create mode 100644 src/test/rustdoc/intra-doc/cross-crate/auxiliary/module.rs create mode 100644 src/test/rustdoc/intra-doc/cross-crate/auxiliary/proc_macro.rs create mode 100644 src/test/rustdoc/intra-doc/cross-crate/auxiliary/submodule-inner.rs create mode 100644 src/test/rustdoc/intra-doc/cross-crate/auxiliary/submodule-outer.rs create mode 100644 src/test/rustdoc/intra-doc/cross-crate/auxiliary/traits.rs create mode 100644 src/test/rustdoc/intra-doc/cross-crate/basic.rs create mode 100644 src/test/rustdoc/intra-doc/cross-crate/crate.rs create mode 100644 src/test/rustdoc/intra-doc/cross-crate/hidden.rs create mode 100644 src/test/rustdoc/intra-doc/cross-crate/macro.rs create mode 100644 src/test/rustdoc/intra-doc/cross-crate/module.rs create mode 100644 src/test/rustdoc/intra-doc/cross-crate/submodule-inner.rs create mode 100644 src/test/rustdoc/intra-doc/cross-crate/submodule-outer.rs create mode 100644 src/test/rustdoc/intra-doc/cross-crate/traits.rs create mode 100644 src/test/rustdoc/intra-doc/disambiguators-removed.rs create mode 100644 src/test/rustdoc/intra-doc/enum-struct-field.rs create mode 100644 src/test/rustdoc/intra-doc/extern-crate.rs create mode 100644 src/test/rustdoc/intra-doc/extern-type.rs create mode 100644 src/test/rustdoc/intra-doc/external-traits.rs create mode 100644 src/test/rustdoc/intra-doc/generic-params.rs create mode 100644 src/test/rustdoc/intra-doc/in-bodies.rs create mode 100644 src/test/rustdoc/intra-doc/libstd-re-export.rs create mode 100644 src/test/rustdoc/intra-doc/mod-ambiguity.rs create mode 100644 src/test/rustdoc/intra-doc/prim-assoc.rs create mode 100644 src/test/rustdoc/intra-doc/prim-methods-external-core.rs create mode 100644 src/test/rustdoc/intra-doc/prim-methods-local.rs create mode 100644 src/test/rustdoc/intra-doc/prim-methods.rs create mode 100644 src/test/rustdoc/intra-doc/prim-precedence.rs create mode 100644 src/test/rustdoc/intra-doc/primitive-non-default-impl.rs create mode 100644 src/test/rustdoc/intra-doc/private-failures-ignored.rs create mode 100644 src/test/rustdoc/intra-doc/private.rs create mode 100644 src/test/rustdoc/intra-doc/proc-macro.rs create mode 100644 src/test/rustdoc/intra-doc/pub-use.rs create mode 100644 src/test/rustdoc/intra-doc/reexport-additional-docs.rs create mode 100644 src/test/rustdoc/intra-doc/self.rs create mode 100644 src/test/rustdoc/intra-doc/through-proc-macro.rs create mode 100644 src/test/rustdoc/intra-doc/trait-impl.rs create mode 100644 src/test/rustdoc/intra-doc/trait-item.rs create mode 100644 src/test/rustdoc/intra-doc/true-false.rs delete mode 100644 src/test/rustdoc/intra-link-associated-defaults.rs delete mode 100644 src/test/rustdoc/intra-link-associated-items.rs delete mode 100644 src/test/rustdoc/intra-link-builtin-macros.rs delete mode 100644 src/test/rustdoc/intra-link-cross-crate-crate.rs delete mode 100644 src/test/rustdoc/intra-link-disambiguators-removed.rs delete mode 100644 src/test/rustdoc/intra-link-extern-crate.rs delete mode 100644 src/test/rustdoc/intra-link-extern-type.rs delete mode 100644 src/test/rustdoc/intra-link-in-bodies.rs delete mode 100644 src/test/rustdoc/intra-link-libstd-re-export.rs delete mode 100644 src/test/rustdoc/intra-link-prim-assoc.rs delete mode 100644 src/test/rustdoc/intra-link-prim-methods-external-core.rs delete mode 100644 src/test/rustdoc/intra-link-prim-methods-local.rs delete mode 100644 src/test/rustdoc/intra-link-prim-methods.rs delete mode 100644 src/test/rustdoc/intra-link-prim-precedence.rs delete mode 100644 src/test/rustdoc/intra-link-primitive-non-default-impl.rs delete mode 100644 src/test/rustdoc/intra-link-private.rs delete mode 100644 src/test/rustdoc/intra-link-proc-macro.rs delete mode 100644 src/test/rustdoc/intra-link-pub-use.rs delete mode 100644 src/test/rustdoc/intra-link-reexport-additional-docs.rs delete mode 100644 src/test/rustdoc/intra-link-self.rs delete mode 100644 src/test/rustdoc/intra-link-trait-impl.rs delete mode 100644 src/test/rustdoc/intra-link-trait-item.rs delete mode 100644 src/test/rustdoc/intra-links-anchors.rs delete mode 100644 src/test/rustdoc/intra-links-external-traits.rs delete mode 100644 src/test/rustdoc/intra-links.rs delete mode 100644 src/test/rustdoc/through-proc-macro.rs diff --git a/src/test/rustdoc/auxiliary/intra-link-cross-crate-crate.rs b/src/test/rustdoc/auxiliary/intra-link-cross-crate-crate.rs deleted file mode 100644 index a37848e23d9..00000000000 --- a/src/test/rustdoc/auxiliary/intra-link-cross-crate-crate.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![crate_name = "inner"] - -/// Links to [crate::g] -pub fn f() {} -pub fn g() {} diff --git a/src/test/rustdoc/auxiliary/intra-link-extern-crate.rs b/src/test/rustdoc/auxiliary/intra-link-extern-crate.rs deleted file mode 100644 index db3bb38ada0..00000000000 --- a/src/test/rustdoc/auxiliary/intra-link-extern-crate.rs +++ /dev/null @@ -1,3 +0,0 @@ -#![crate_name="inner"] - -//! ooh, i'm a rebel just for [kicks] diff --git a/src/test/rustdoc/auxiliary/intra-link-proc-macro-macro.rs b/src/test/rustdoc/auxiliary/intra-link-proc-macro-macro.rs deleted file mode 100644 index 04a431d9902..00000000000 --- a/src/test/rustdoc/auxiliary/intra-link-proc-macro-macro.rs +++ /dev/null @@ -1,35 +0,0 @@ -// force-host -// no-prefer-dynamic -// compile-flags: --crate-type proc-macro - -#![crate_type="proc-macro"] -#![crate_name="intra_link_proc_macro_macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(DeriveA)] -pub fn a_derive(input: TokenStream) -> TokenStream { - input -} - -#[proc_macro_derive(DeriveB)] -pub fn b_derive(input: TokenStream) -> TokenStream { - input -} - -#[proc_macro_derive(DeriveTrait)] -pub fn trait_derive(input: TokenStream) -> TokenStream { - input -} - -#[proc_macro_attribute] -pub fn attr_a(input: TokenStream, _args: TokenStream) -> TokenStream { - input -} - -#[proc_macro_attribute] -pub fn attr_b(input: TokenStream, _args: TokenStream) -> TokenStream { - input -} diff --git a/src/test/rustdoc/auxiliary/intra-link-pub-use.rs b/src/test/rustdoc/auxiliary/intra-link-pub-use.rs deleted file mode 100644 index a4db2ffc445..00000000000 --- a/src/test/rustdoc/auxiliary/intra-link-pub-use.rs +++ /dev/null @@ -1,4 +0,0 @@ -#![crate_name = "inner"] - -/// Documentation, including a link to [std::ptr] -pub fn f() {} diff --git a/src/test/rustdoc/auxiliary/intra-link-reexport-additional-docs.rs b/src/test/rustdoc/auxiliary/intra-link-reexport-additional-docs.rs deleted file mode 100644 index fc51995a94e..00000000000 --- a/src/test/rustdoc/auxiliary/intra-link-reexport-additional-docs.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![crate_name = "inner"] - -/// Links to [f()] -pub struct Inner; - -pub fn f() {} diff --git a/src/test/rustdoc/auxiliary/intra-links-external-traits.rs b/src/test/rustdoc/auxiliary/intra-links-external-traits.rs deleted file mode 100644 index 6142dcda986..00000000000 --- a/src/test/rustdoc/auxiliary/intra-links-external-traits.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub trait ThisTrait { - fn asdf(&self); - - /// let's link to [`asdf`](ThisTrait::asdf) - fn qwop(&self); -} diff --git a/src/test/rustdoc/auxiliary/my-core.rs b/src/test/rustdoc/auxiliary/my-core.rs deleted file mode 100644 index 54e986be9ec..00000000000 --- a/src/test/rustdoc/auxiliary/my-core.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![feature(no_core, lang_items)] -#![no_core] -#![crate_type="rlib"] - -#[lang = "char"] -impl char { - pub fn len_utf8(self) -> usize { - 42 - } -} - -#[lang = "sized"] -pub trait Sized {} - -#[lang = "clone"] -pub trait Clone: Sized {} - -#[lang = "copy"] -pub trait Copy: Clone {} diff --git a/src/test/rustdoc/auxiliary/through-proc-macro-aux.rs b/src/test/rustdoc/auxiliary/through-proc-macro-aux.rs deleted file mode 100644 index 5c4a01ee3a7..00000000000 --- a/src/test/rustdoc/auxiliary/through-proc-macro-aux.rs +++ /dev/null @@ -1,20 +0,0 @@ -// force-host -// no-prefer-dynamic -#![crate_type = "proc-macro"] -#![crate_name="some_macros"] - -extern crate proc_macro; -use proc_macro::TokenStream; - -#[proc_macro_attribute] -pub fn first(_attr: TokenStream, item: TokenStream) -> TokenStream { - item // This doesn't erase the spans. -} - -#[proc_macro_attribute] -pub fn second(_attr: TokenStream, item: TokenStream) -> TokenStream { - // Make a new `TokenStream` to erase the spans: - let mut out: TokenStream = TokenStream::new(); - out.extend(item); - out -} diff --git a/src/test/rustdoc/intra-doc-crate/additional_doc.rs b/src/test/rustdoc/intra-doc-crate/additional_doc.rs deleted file mode 100644 index 837390b3c71..00000000000 --- a/src/test/rustdoc/intra-doc-crate/additional_doc.rs +++ /dev/null @@ -1,10 +0,0 @@ -// aux-build:additional_doc.rs -// build-aux-docs -#![deny(broken_intra_doc_links)] - -extern crate my_rand; - -// @has 'additional_doc/trait.Rng.html' '//a[@href="../additional_doc/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/src/test/rustdoc/intra-doc-crate/auxiliary/additional_doc.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/additional_doc.rs deleted file mode 100644 index 849d2568733..00000000000 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/additional_doc.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![crate_name = "my_rand"] -#![deny(broken_intra_doc_links)] - -pub trait RngCore {} -/// Rng extends [`RngCore`]. -pub trait Rng: RngCore {} diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs deleted file mode 100644 index b543ae764c0..00000000000 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![crate_name = "hidden_dep"] -#![deny(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/src/test/rustdoc/intra-doc-crate/auxiliary/intra-doc-basic.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/intra-doc-basic.rs deleted file mode 100644 index 5342baecbc4..00000000000 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/intra-doc-basic.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![crate_name = "a"] -#![deny(broken_intra_doc_links)] - -pub struct Foo; - -/// Link to [Foo] -pub struct Bar; diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs deleted file mode 100644 index a94f9e5dcca..00000000000 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![crate_name = "macro_inner"] -#![deny(broken_intra_doc_links)] - -pub struct Foo; - -/// See also [`Foo`] -#[macro_export] -macro_rules! my_macro { - () => {} -} diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/module.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/module.rs deleted file mode 100644 index b7e3913f108..00000000000 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/module.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![crate_name = "module_inner"] -#![deny(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/src/test/rustdoc/intra-doc-crate/auxiliary/proc_macro.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/proc_macro.rs deleted file mode 100644 index 0d5a954075d..00000000000 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/proc_macro.rs +++ /dev/null @@ -1,20 +0,0 @@ -// 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/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-inner.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-inner.rs deleted file mode 100644 index 8ae0f6c16b3..00000000000 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-inner.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![crate_name = "a"] -#![deny(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/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-outer.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-outer.rs deleted file mode 100644 index d90c529e385..00000000000 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/submodule-outer.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![crate_name = "bar"] -#![deny(broken_intra_doc_links)] - -pub trait Foo { - /// [`Bar`] [`Baz`] - fn foo(); -} - -pub trait Bar { -} - -pub trait Baz { -} diff --git a/src/test/rustdoc/intra-doc-crate/auxiliary/traits.rs b/src/test/rustdoc/intra-doc-crate/auxiliary/traits.rs deleted file mode 100644 index c16e39d56f3..00000000000 --- a/src/test/rustdoc/intra-doc-crate/auxiliary/traits.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![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/src/test/rustdoc/intra-doc-crate/basic.rs b/src/test/rustdoc/intra-doc-crate/basic.rs deleted file mode 100644 index 6ab9140c3c3..00000000000 --- a/src/test/rustdoc/intra-doc-crate/basic.rs +++ /dev/null @@ -1,9 +0,0 @@ -// aux-build:intra-doc-basic.rs -// build-aux-docs -#![deny(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/src/test/rustdoc/intra-doc-crate/hidden.rs b/src/test/rustdoc/intra-doc-crate/hidden.rs deleted file mode 100644 index 9c9d4c64945..00000000000 --- a/src/test/rustdoc/intra-doc-crate/hidden.rs +++ /dev/null @@ -1,10 +0,0 @@ -// aux-build:hidden.rs -// build-aux-docs -#![deny(broken_intra_doc_links)] - -// tests https://github.com/rust-lang/rust/issues/73363 - -extern crate hidden_dep; - -// @has 'hidden/struct.Ready.html' '//a/@href' '../hidden/fn.ready.html' -pub use hidden_dep::future::{ready, Ready}; diff --git a/src/test/rustdoc/intra-doc-crate/macro.rs b/src/test/rustdoc/intra-doc-crate/macro.rs deleted file mode 100644 index 311b16dff13..00000000000 --- a/src/test/rustdoc/intra-doc-crate/macro.rs +++ /dev/null @@ -1,12 +0,0 @@ -// ignore-tidy-linelength -// aux-build:macro_inner.rs -// aux-build:proc_macro.rs -// build-aux-docs -#![deny(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/src/test/rustdoc/intra-doc-crate/module.rs b/src/test/rustdoc/intra-doc-crate/module.rs deleted file mode 100644 index 9039e344f7b..00000000000 --- a/src/test/rustdoc/intra-doc-crate/module.rs +++ /dev/null @@ -1,8 +0,0 @@ -// outer.rs -// aux-build: module.rs -// build-aux-docs -#![deny(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/src/test/rustdoc/intra-doc-crate/submodule-inner.rs b/src/test/rustdoc/intra-doc-crate/submodule-inner.rs deleted file mode 100644 index e1465816368..00000000000 --- a/src/test/rustdoc/intra-doc-crate/submodule-inner.rs +++ /dev/null @@ -1,8 +0,0 @@ -// aux-build:submodule-inner.rs -// build-aux-docs -#![deny(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/src/test/rustdoc/intra-doc-crate/submodule-outer.rs b/src/test/rustdoc/intra-doc-crate/submodule-outer.rs deleted file mode 100644 index 45f561328f2..00000000000 --- a/src/test/rustdoc/intra-doc-crate/submodule-outer.rs +++ /dev/null @@ -1,16 +0,0 @@ -// aux-build:submodule-outer.rs -// edition:2018 -#![deny(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="../submodule_outer/bar/trait.Bar.html"]' 'Bar' -// @has 'submodule_outer/trait.Foo.html' '//a[@href="../submodule_outer/trait.Baz.html"]' 'Baz' -pub use ::bar_::{Foo, Baz}; diff --git a/src/test/rustdoc/intra-doc-crate/traits.rs b/src/test/rustdoc/intra-doc-crate/traits.rs deleted file mode 100644 index 07decb48019..00000000000 --- a/src/test/rustdoc/intra-doc-crate/traits.rs +++ /dev/null @@ -1,15 +0,0 @@ -// aux-build:traits.rs -// build-aux-docs -// ignore-tidy-line-length -#![deny(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() {} -} diff --git a/src/test/rustdoc/intra-doc-link-enum-struct-field.rs b/src/test/rustdoc/intra-doc-link-enum-struct-field.rs deleted file mode 100644 index 70bf343a9a5..00000000000 --- a/src/test/rustdoc/intra-doc-link-enum-struct-field.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![crate_name = "foo"] - -pub enum Foo { - X { - y: u8, - } -} - -/// Hello -/// -/// I want [Foo::X::y]. -pub fn foo() {} - -// @has foo/fn.foo.html '//a/@href' '../foo/enum.Foo.html#variant.X.field.y' diff --git a/src/test/rustdoc/intra-doc-link-generic-params.rs b/src/test/rustdoc/intra-doc-link-generic-params.rs deleted file mode 100644 index 1de6410f10c..00000000000 --- a/src/test/rustdoc/intra-doc-link-generic-params.rs +++ /dev/null @@ -1,62 +0,0 @@ -// ignore-tidy-linelength - -#![crate_name = "foo"] - -//! Here's a link to [`Vec`] and one to [`Box>>`]. -//! Here's a link to [`Iterator>::Item`]. -//! -// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html"]' 'Vec' -// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html"]' 'Box>>' -// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item"]' 'Iterator>::Item' - -//! And what about a link to [just `Option`](Option) and, [with the generic, `Option`](Option)? -//! -// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html"]' 'just Option' -// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html"]' 'with the generic, Option' - -//! We should also try linking to [`Result`]; it has *two* generics! -//! And [`Result`] and [`Result`]. -//! -// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html"]' 'Result' -// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html"]' 'Result' -// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html"]' 'Result' - -//! Now let's test a trickier case: [`Vec::::new`], or you could write it -//! [with parentheses as `Vec::::new()`][Vec::::new()]. -//! And what about something even harder? That would be [`Vec::>::new()`]. -//! -// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html#method.new"]' 'Vec::::new' -// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html#method.new"]' 'with parentheses as Vec::::new()' -// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html#method.new"]' 'Vec::>::new()' - -//! This is also pretty tricky: [`TypeId::of::()`]. -//! And this too: [`Vec::::len`]. -//! -// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html#method.of"]' 'TypeId::of::()' -// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html#method.len"]' 'Vec::::len' - -//! We unofficially and implicitly support things that aren't valid in the actual Rust syntax, like -//! [`Box::new()`]. We may not support them in the future! -//! -// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html#method.new"]' 'Box::new()' - -//! These will be resolved as regular links: -//! - [`this is first`](https://www.rust-lang.org) -//! - [`this is twice`] -//! - [` thrice`](https://www.rust-lang.org) -//! - [` four times`][rlo] -//! - [a < b][rlo] -//! - [c > d] -//! -//! [`this is twice`]: https://www.rust-lang.org -//! [rlo]: https://www.rust-lang.org -//! [c > d]: https://www.rust-lang.org -//! -// @has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'this is first' -// @has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'this is twice' -// @has foo/index.html '//a[@href="https://www.rust-lang.org"]' ' thrice' -// @has foo/index.html '//a[@href="https://www.rust-lang.org"]' ' four times' -// @has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'a < b' -// @has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'c > d' - -use std::any::TypeId; diff --git a/src/test/rustdoc/intra-doc-link-mod-ambiguity.rs b/src/test/rustdoc/intra-doc-link-mod-ambiguity.rs deleted file mode 100644 index bd733e10230..00000000000 --- a/src/test/rustdoc/intra-doc-link-mod-ambiguity.rs +++ /dev/null @@ -1,18 +0,0 @@ -// ignore-tidy-linelength - -#![deny(broken_intra_doc_links)] - - -pub fn foo() { - -} - -pub mod foo {} -// @has intra_doc_link_mod_ambiguity/struct.A.html '//a/@href' '../intra_doc_link_mod_ambiguity/foo/index.html' -/// Module is [`module@foo`] -pub struct A; - - -// @has intra_doc_link_mod_ambiguity/struct.B.html '//a/@href' '../intra_doc_link_mod_ambiguity/fn.foo.html' -/// Function is [`fn@foo`] -pub struct B; diff --git a/src/test/rustdoc/intra-doc-link-private.rs b/src/test/rustdoc/intra-doc-link-private.rs deleted file mode 100644 index f86ca44403d..00000000000 --- a/src/test/rustdoc/intra-doc-link-private.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![crate_name = "private"] -// compile-flags: --document-private-items -/// docs [DontDocMe] -// @has private/struct.DocMe.html '//*a[@href="../private/struct.DontDocMe.html"]' 'DontDocMe' -pub struct DocMe; -struct DontDocMe; diff --git a/src/test/rustdoc/intra-doc-link-true-false.rs b/src/test/rustdoc/intra-doc-link-true-false.rs deleted file mode 100644 index 7b21e934147..00000000000 --- a/src/test/rustdoc/intra-doc-link-true-false.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![deny(broken_intra_doc_links)] -#![crate_name = "foo"] - -// ignore-tidy-linelength - -// @has foo/index.html -// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.bool.html"]' 'true' -// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.bool.html"]' 'false' - -//! A `bool` is either [`true`] or [`false`]. diff --git a/src/test/rustdoc/intra-doc/anchors.rs b/src/test/rustdoc/intra-doc/anchors.rs new file mode 100644 index 00000000000..e4f0c737bdd --- /dev/null +++ b/src/test/rustdoc/intra-doc/anchors.rs @@ -0,0 +1,12 @@ +/// I want... +/// +/// # Anchor! +pub struct Something; + +// @has anchors/struct.SomeOtherType.html +// @has - '//a/@href' '../anchors/struct.Something.html#Anchor!' + +/// I want... +/// +/// To link to [Something#Anchor!] +pub struct SomeOtherType; diff --git a/src/test/rustdoc/intra-doc/associated-defaults.rs b/src/test/rustdoc/intra-doc/associated-defaults.rs new file mode 100644 index 00000000000..f99d9b5baea --- /dev/null +++ b/src/test/rustdoc/intra-doc/associated-defaults.rs @@ -0,0 +1,27 @@ +// ignore-tidy-linelength +#![deny(intra_doc_link_resolution_failure)] +#![feature(associated_type_defaults)] + +pub trait TraitWithDefault { + type T = usize; + fn f() -> Self::T { + 0 + } +} + +/// Link to [UsesDefaults::T] and [UsesDefaults::f] +// @has 'associated_defaults/struct.UsesDefaults.html' '//a[@href="../associated_defaults/struct.UsesDefaults.html#associatedtype.T"]' 'UsesDefaults::T' +// @has 'associated_defaults/struct.UsesDefaults.html' '//a[@href="../associated_defaults/struct.UsesDefaults.html#method.f"]' 'UsesDefaults::f' +pub struct UsesDefaults; +impl TraitWithDefault for UsesDefaults {} + +/// Link to [OverridesDefaults::T] and [OverridesDefaults::f] +// @has 'associated_defaults/struct.OverridesDefaults.html' '//a[@href="../associated_defaults/struct.OverridesDefaults.html#associatedtype.T"]' 'OverridesDefaults::T' +// @has 'associated_defaults/struct.OverridesDefaults.html' '//a[@href="../associated_defaults/struct.OverridesDefaults.html#method.f"]' 'OverridesDefaults::f' +pub struct OverridesDefaults; +impl TraitWithDefault for OverridesDefaults { + type T = bool; + fn f() -> bool { + true + } +} diff --git a/src/test/rustdoc/intra-doc/associated-items.rs b/src/test/rustdoc/intra-doc/associated-items.rs new file mode 100644 index 00000000000..09dfbfcf68a --- /dev/null +++ b/src/test/rustdoc/intra-doc/associated-items.rs @@ -0,0 +1,61 @@ +// ignore-tidy-linelength +#![deny(intra_doc_link_resolution_failure)] + +/// [`std::collections::BTreeMap::into_iter`] +/// [`String::from`] is ambiguous as to which `From` impl +/// [Vec::into_iter()] uses a disambiguator +// @has 'associated_items/fn.foo.html' '//a[@href="https://doc.rust-lang.org/nightly/alloc/collections/btree/map/struct.BTreeMap.html#method.into_iter"]' 'std::collections::BTreeMap::into_iter' +// @has 'associated_items/fn.foo.html' '//a[@href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html#method.from"]' 'String::from' +// @has 'associated_items/fn.foo.html' '//a[@href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html#method.into_iter"]' 'Vec::into_iter' +pub fn foo() {} + +/// Link to [MyStruct], [link from struct][MyStruct::method], [MyStruct::clone], [MyStruct::Input] +// @has 'associated_items/struct.MyStruct.html' '//a[@href="../associated_items/struct.MyStruct.html"]' 'MyStruct' +// @has 'associated_items/struct.MyStruct.html' '//a[@href="../associated_items/struct.MyStruct.html#method.method"]' 'link from struct' +// @has 'associated_items/struct.MyStruct.html' '//a[@href="../associated_items/struct.MyStruct.html#method.clone"]' 'MyStruct::clone' +// @has 'associated_items/struct.MyStruct.html' '//a[@href="../associated_items/struct.MyStruct.html#associatedtype.Input"]' 'MyStruct::Input' +pub struct MyStruct { foo: () } + +impl Clone for MyStruct { + fn clone(&self) -> Self { + MyStruct + } +} + +pub trait T { + type Input; + fn method(i: Self::Input); +} + +impl T for MyStruct { + type Input = usize; + + /// [link from method][MyStruct::method] on method + // @has 'associated_items/struct.MyStruct.html' '//a[@href="../associated_items/struct.MyStruct.html#method.method"]' 'link from method' + fn method(i: usize) { + } +} + +/// Ambiguity between which trait to use +pub trait T1 { + fn ambiguous_method(); +} + +pub trait T2 { + fn ambiguous_method(); +} + +/// Link to [S::ambiguous_method] +// FIXME: there is no way to disambiguate these. +// Since we have `#[deny(intra_doc_failure)]`, we still know it was one or the other. +pub struct S; + +impl T1 for S { + fn ambiguous_method() {} +} + +impl T2 for S { + fn ambiguous_method() {} +} + +fn main() {} diff --git a/src/test/rustdoc/intra-doc/auxiliary/intra-link-extern-crate.rs b/src/test/rustdoc/intra-doc/auxiliary/intra-link-extern-crate.rs new file mode 100644 index 00000000000..db3bb38ada0 --- /dev/null +++ b/src/test/rustdoc/intra-doc/auxiliary/intra-link-extern-crate.rs @@ -0,0 +1,3 @@ +#![crate_name="inner"] + +//! ooh, i'm a rebel just for [kicks] diff --git a/src/test/rustdoc/intra-doc/auxiliary/intra-link-pub-use.rs b/src/test/rustdoc/intra-doc/auxiliary/intra-link-pub-use.rs new file mode 100644 index 00000000000..a4db2ffc445 --- /dev/null +++ b/src/test/rustdoc/intra-doc/auxiliary/intra-link-pub-use.rs @@ -0,0 +1,4 @@ +#![crate_name = "inner"] + +/// Documentation, including a link to [std::ptr] +pub fn f() {} diff --git a/src/test/rustdoc/intra-doc/auxiliary/intra-link-reexport-additional-docs.rs b/src/test/rustdoc/intra-doc/auxiliary/intra-link-reexport-additional-docs.rs new file mode 100644 index 00000000000..fc51995a94e --- /dev/null +++ b/src/test/rustdoc/intra-doc/auxiliary/intra-link-reexport-additional-docs.rs @@ -0,0 +1,6 @@ +#![crate_name = "inner"] + +/// Links to [f()] +pub struct Inner; + +pub fn f() {} diff --git a/src/test/rustdoc/intra-doc/auxiliary/intra-links-external-traits.rs b/src/test/rustdoc/intra-doc/auxiliary/intra-links-external-traits.rs new file mode 100644 index 00000000000..6142dcda986 --- /dev/null +++ b/src/test/rustdoc/intra-doc/auxiliary/intra-links-external-traits.rs @@ -0,0 +1,6 @@ +pub trait ThisTrait { + fn asdf(&self); + + /// let's link to [`asdf`](ThisTrait::asdf) + fn qwop(&self); +} diff --git a/src/test/rustdoc/intra-doc/auxiliary/my-core.rs b/src/test/rustdoc/intra-doc/auxiliary/my-core.rs new file mode 100644 index 00000000000..54e986be9ec --- /dev/null +++ b/src/test/rustdoc/intra-doc/auxiliary/my-core.rs @@ -0,0 +1,19 @@ +#![feature(no_core, lang_items)] +#![no_core] +#![crate_type="rlib"] + +#[lang = "char"] +impl char { + pub fn len_utf8(self) -> usize { + 42 + } +} + +#[lang = "sized"] +pub trait Sized {} + +#[lang = "clone"] +pub trait Clone: Sized {} + +#[lang = "copy"] +pub trait Copy: Clone {} diff --git a/src/test/rustdoc/intra-doc/auxiliary/proc-macro-macro.rs b/src/test/rustdoc/intra-doc/auxiliary/proc-macro-macro.rs new file mode 100644 index 00000000000..5ba132f25b4 --- /dev/null +++ b/src/test/rustdoc/intra-doc/auxiliary/proc-macro-macro.rs @@ -0,0 +1,34 @@ +// force-host +// no-prefer-dynamic +// compile-flags: --crate-type proc-macro + +#![crate_type="proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(DeriveA)] +pub fn a_derive(input: TokenStream) -> TokenStream { + input +} + +#[proc_macro_derive(DeriveB)] +pub fn b_derive(input: TokenStream) -> TokenStream { + input +} + +#[proc_macro_derive(DeriveTrait)] +pub fn trait_derive(input: TokenStream) -> TokenStream { + input +} + +#[proc_macro_attribute] +pub fn attr_a(input: TokenStream, _args: TokenStream) -> TokenStream { + input +} + +#[proc_macro_attribute] +pub fn attr_b(input: TokenStream, _args: TokenStream) -> TokenStream { + input +} diff --git a/src/test/rustdoc/intra-doc/auxiliary/through-proc-macro-aux.rs b/src/test/rustdoc/intra-doc/auxiliary/through-proc-macro-aux.rs new file mode 100644 index 00000000000..5c4a01ee3a7 --- /dev/null +++ b/src/test/rustdoc/intra-doc/auxiliary/through-proc-macro-aux.rs @@ -0,0 +1,20 @@ +// force-host +// no-prefer-dynamic +#![crate_type = "proc-macro"] +#![crate_name="some_macros"] + +extern crate proc_macro; +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn first(_attr: TokenStream, item: TokenStream) -> TokenStream { + item // This doesn't erase the spans. +} + +#[proc_macro_attribute] +pub fn second(_attr: TokenStream, item: TokenStream) -> TokenStream { + // Make a new `TokenStream` to erase the spans: + let mut out: TokenStream = TokenStream::new(); + out.extend(item); + out +} diff --git a/src/test/rustdoc/intra-doc/basic.rs b/src/test/rustdoc/intra-doc/basic.rs new file mode 100644 index 00000000000..7760546e1fa --- /dev/null +++ b/src/test/rustdoc/intra-doc/basic.rs @@ -0,0 +1,84 @@ +// @has basic/index.html +// @has - '//a/@href' '../basic/struct.ThisType.html' +// @has - '//a/@href' '../basic/struct.ThisType.html#method.this_method' +// @has - '//a/@href' '../basic/enum.ThisEnum.html' +// @has - '//a/@href' '../basic/enum.ThisEnum.html#variant.ThisVariant' +// @has - '//a/@href' '../basic/trait.ThisTrait.html' +// @has - '//a/@href' '../basic/trait.ThisTrait.html#tymethod.this_associated_method' +// @has - '//a/@href' '../basic/trait.ThisTrait.html#associatedtype.ThisAssociatedType' +// @has - '//a/@href' '../basic/trait.ThisTrait.html#associatedconstant.THIS_ASSOCIATED_CONST' +// @has - '//a/@href' '../basic/trait.ThisTrait.html' +// @has - '//a/@href' '../basic/type.ThisAlias.html' +// @has - '//a/@href' '../basic/union.ThisUnion.html' +// @has - '//a/@href' '../basic/fn.this_function.html' +// @has - '//a/@href' '../basic/constant.THIS_CONST.html' +// @has - '//a/@href' '../basic/static.THIS_STATIC.html' +// @has - '//a/@href' '../basic/macro.this_macro.html' +// @has - '//a/@href' '../basic/trait.SoAmbiguous.html' +// @has - '//a/@href' '../basic/fn.SoAmbiguous.html' +//! In this crate we would like to link to: +//! +//! * [`ThisType`](ThisType) +//! * [`ThisType::this_method`](ThisType::this_method) +//! * [`ThisEnum`](ThisEnum) +//! * [`ThisEnum::ThisVariant`](ThisEnum::ThisVariant) +//! * [`ThisEnum::ThisVariantCtor`](ThisEnum::ThisVariantCtor) +//! * [`ThisTrait`](ThisTrait) +//! * [`ThisTrait::this_associated_method`](ThisTrait::this_associated_method) +//! * [`ThisTrait::ThisAssociatedType`](ThisTrait::ThisAssociatedType) +//! * [`ThisTrait::THIS_ASSOCIATED_CONST`](ThisTrait::THIS_ASSOCIATED_CONST) +//! * [`ThisAlias`](ThisAlias) +//! * [`ThisUnion`](ThisUnion) +//! * [`this_function`](this_function()) +//! * [`THIS_CONST`](const@THIS_CONST) +//! * [`THIS_STATIC`](static@THIS_STATIC) +//! * [`this_macro`](this_macro!) +//! +//! In addition, there's some specifics we want to look at. There's [a trait called +//! SoAmbiguous][ambig-trait], but there's also [a function called SoAmbiguous][ambig-fn] too! +//! Whatever shall we do? +//! +//! [ambig-trait]: trait@SoAmbiguous +//! [ambig-fn]: SoAmbiguous() + +#[macro_export] +macro_rules! this_macro { + () => {}; +} + +// @has basic/struct.ThisType.html '//a/@href' '../basic/macro.this_macro.html' +/// another link to [`this_macro!()`] +pub struct ThisType; + +impl ThisType { + pub fn this_method() {} +} +pub enum ThisEnum { ThisVariant, ThisVariantCtor(u32), } +pub trait ThisTrait { + type ThisAssociatedType; + const THIS_ASSOCIATED_CONST: u8; + fn this_associated_method(); +} +pub type ThisAlias = Result<(), ()>; +pub union ThisUnion { this_field: usize, } + +pub fn this_function() {} +pub const THIS_CONST: usize = 5usize; +pub static THIS_STATIC: usize = 5usize; + +pub trait SoAmbiguous {} + +#[allow(nonstandard_style)] +pub fn SoAmbiguous() {} + + +// @has basic/struct.SomeOtherType.html '//a/@href' '../basic/struct.ThisType.html' +// @has - '//a/@href' '../basic/struct.ThisType.html#method.this_method' +// @has - '//a/@href' '../basic/enum.ThisEnum.html' +// @has - '//a/@href' '../basic/enum.ThisEnum.html#variant.ThisVariant' +/// Shortcut links for: +/// * [`ThisType`] +/// * [`ThisType::this_method`] +/// * [ThisEnum] +/// * [ThisEnum::ThisVariant] +pub struct SomeOtherType; diff --git a/src/test/rustdoc/intra-doc/builtin-macros.rs b/src/test/rustdoc/intra-doc/builtin-macros.rs new file mode 100644 index 00000000000..74216a587e1 --- /dev/null +++ b/src/test/rustdoc/intra-doc/builtin-macros.rs @@ -0,0 +1,3 @@ +// @has builtin_macros/index.html +// @has - '//a/@href' 'https://doc.rust-lang.org/nightly/core/macro.cfg.html' +//! [cfg] diff --git a/src/test/rustdoc/intra-doc/cross-crate/additional_doc.rs b/src/test/rustdoc/intra-doc/cross-crate/additional_doc.rs new file mode 100644 index 00000000000..837390b3c71 --- /dev/null +++ b/src/test/rustdoc/intra-doc/cross-crate/additional_doc.rs @@ -0,0 +1,10 @@ +// aux-build:additional_doc.rs +// build-aux-docs +#![deny(broken_intra_doc_links)] + +extern crate my_rand; + +// @has 'additional_doc/trait.Rng.html' '//a[@href="../additional_doc/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/src/test/rustdoc/intra-doc/cross-crate/auxiliary/additional_doc.rs b/src/test/rustdoc/intra-doc/cross-crate/auxiliary/additional_doc.rs new file mode 100644 index 00000000000..849d2568733 --- /dev/null +++ b/src/test/rustdoc/intra-doc/cross-crate/auxiliary/additional_doc.rs @@ -0,0 +1,6 @@ +#![crate_name = "my_rand"] +#![deny(broken_intra_doc_links)] + +pub trait RngCore {} +/// Rng extends [`RngCore`]. +pub trait Rng: RngCore {} diff --git a/src/test/rustdoc/intra-doc/cross-crate/auxiliary/hidden.rs b/src/test/rustdoc/intra-doc/cross-crate/auxiliary/hidden.rs new file mode 100644 index 00000000000..b543ae764c0 --- /dev/null +++ b/src/test/rustdoc/intra-doc/cross-crate/auxiliary/hidden.rs @@ -0,0 +1,19 @@ +#![crate_name = "hidden_dep"] +#![deny(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/src/test/rustdoc/intra-doc/cross-crate/auxiliary/intra-doc-basic.rs b/src/test/rustdoc/intra-doc/cross-crate/auxiliary/intra-doc-basic.rs new file mode 100644 index 00000000000..5342baecbc4 --- /dev/null +++ b/src/test/rustdoc/intra-doc/cross-crate/auxiliary/intra-doc-basic.rs @@ -0,0 +1,7 @@ +#![crate_name = "a"] +#![deny(broken_intra_doc_links)] + +pub struct Foo; + +/// Link to [Foo] +pub struct Bar; diff --git a/src/test/rustdoc/intra-doc/cross-crate/auxiliary/intra-link-cross-crate-crate.rs b/src/test/rustdoc/intra-doc/cross-crate/auxiliary/intra-link-cross-crate-crate.rs new file mode 100644 index 00000000000..a37848e23d9 --- /dev/null +++ b/src/test/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/src/test/rustdoc/intra-doc/cross-crate/auxiliary/macro_inner.rs b/src/test/rustdoc/intra-doc/cross-crate/auxiliary/macro_inner.rs new file mode 100644 index 00000000000..a94f9e5dcca --- /dev/null +++ b/src/test/rustdoc/intra-doc/cross-crate/auxiliary/macro_inner.rs @@ -0,0 +1,10 @@ +#![crate_name = "macro_inner"] +#![deny(broken_intra_doc_links)] + +pub struct Foo; + +/// See also [`Foo`] +#[macro_export] +macro_rules! my_macro { + () => {} +} diff --git a/src/test/rustdoc/intra-doc/cross-crate/auxiliary/module.rs b/src/test/rustdoc/intra-doc/cross-crate/auxiliary/module.rs new file mode 100644 index 00000000000..b7e3913f108 --- /dev/null +++ b/src/test/rustdoc/intra-doc/cross-crate/auxiliary/module.rs @@ -0,0 +1,7 @@ +#![crate_name = "module_inner"] +#![deny(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/src/test/rustdoc/intra-doc/cross-crate/auxiliary/proc_macro.rs b/src/test/rustdoc/intra-doc/cross-crate/auxiliary/proc_macro.rs new file mode 100644 index 00000000000..0d5a954075d --- /dev/null +++ b/src/test/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/src/test/rustdoc/intra-doc/cross-crate/auxiliary/submodule-inner.rs b/src/test/rustdoc/intra-doc/cross-crate/auxiliary/submodule-inner.rs new file mode 100644 index 00000000000..8ae0f6c16b3 --- /dev/null +++ b/src/test/rustdoc/intra-doc/cross-crate/auxiliary/submodule-inner.rs @@ -0,0 +1,12 @@ +#![crate_name = "a"] +#![deny(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/src/test/rustdoc/intra-doc/cross-crate/auxiliary/submodule-outer.rs b/src/test/rustdoc/intra-doc/cross-crate/auxiliary/submodule-outer.rs new file mode 100644 index 00000000000..d90c529e385 --- /dev/null +++ b/src/test/rustdoc/intra-doc/cross-crate/auxiliary/submodule-outer.rs @@ -0,0 +1,13 @@ +#![crate_name = "bar"] +#![deny(broken_intra_doc_links)] + +pub trait Foo { + /// [`Bar`] [`Baz`] + fn foo(); +} + +pub trait Bar { +} + +pub trait Baz { +} diff --git a/src/test/rustdoc/intra-doc/cross-crate/auxiliary/traits.rs b/src/test/rustdoc/intra-doc/cross-crate/auxiliary/traits.rs new file mode 100644 index 00000000000..c16e39d56f3 --- /dev/null +++ b/src/test/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/src/test/rustdoc/intra-doc/cross-crate/basic.rs b/src/test/rustdoc/intra-doc/cross-crate/basic.rs new file mode 100644 index 00000000000..6ab9140c3c3 --- /dev/null +++ b/src/test/rustdoc/intra-doc/cross-crate/basic.rs @@ -0,0 +1,9 @@ +// aux-build:intra-doc-basic.rs +// build-aux-docs +#![deny(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/src/test/rustdoc/intra-doc/cross-crate/crate.rs b/src/test/rustdoc/intra-doc/cross-crate/crate.rs new file mode 100644 index 00000000000..edf544708b6 --- /dev/null +++ b/src/test/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/src/test/rustdoc/intra-doc/cross-crate/hidden.rs b/src/test/rustdoc/intra-doc/cross-crate/hidden.rs new file mode 100644 index 00000000000..9c9d4c64945 --- /dev/null +++ b/src/test/rustdoc/intra-doc/cross-crate/hidden.rs @@ -0,0 +1,10 @@ +// aux-build:hidden.rs +// build-aux-docs +#![deny(broken_intra_doc_links)] + +// tests https://github.com/rust-lang/rust/issues/73363 + +extern crate hidden_dep; + +// @has 'hidden/struct.Ready.html' '//a/@href' '../hidden/fn.ready.html' +pub use hidden_dep::future::{ready, Ready}; diff --git a/src/test/rustdoc/intra-doc/cross-crate/macro.rs b/src/test/rustdoc/intra-doc/cross-crate/macro.rs new file mode 100644 index 00000000000..311b16dff13 --- /dev/null +++ b/src/test/rustdoc/intra-doc/cross-crate/macro.rs @@ -0,0 +1,12 @@ +// ignore-tidy-linelength +// aux-build:macro_inner.rs +// aux-build:proc_macro.rs +// build-aux-docs +#![deny(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/src/test/rustdoc/intra-doc/cross-crate/module.rs b/src/test/rustdoc/intra-doc/cross-crate/module.rs new file mode 100644 index 00000000000..9039e344f7b --- /dev/null +++ b/src/test/rustdoc/intra-doc/cross-crate/module.rs @@ -0,0 +1,8 @@ +// outer.rs +// aux-build: module.rs +// build-aux-docs +#![deny(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/src/test/rustdoc/intra-doc/cross-crate/submodule-inner.rs b/src/test/rustdoc/intra-doc/cross-crate/submodule-inner.rs new file mode 100644 index 00000000000..e1465816368 --- /dev/null +++ b/src/test/rustdoc/intra-doc/cross-crate/submodule-inner.rs @@ -0,0 +1,8 @@ +// aux-build:submodule-inner.rs +// build-aux-docs +#![deny(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/src/test/rustdoc/intra-doc/cross-crate/submodule-outer.rs b/src/test/rustdoc/intra-doc/cross-crate/submodule-outer.rs new file mode 100644 index 00000000000..45f561328f2 --- /dev/null +++ b/src/test/rustdoc/intra-doc/cross-crate/submodule-outer.rs @@ -0,0 +1,16 @@ +// aux-build:submodule-outer.rs +// edition:2018 +#![deny(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="../submodule_outer/bar/trait.Bar.html"]' 'Bar' +// @has 'submodule_outer/trait.Foo.html' '//a[@href="../submodule_outer/trait.Baz.html"]' 'Baz' +pub use ::bar_::{Foo, Baz}; diff --git a/src/test/rustdoc/intra-doc/cross-crate/traits.rs b/src/test/rustdoc/intra-doc/cross-crate/traits.rs new file mode 100644 index 00000000000..07decb48019 --- /dev/null +++ b/src/test/rustdoc/intra-doc/cross-crate/traits.rs @@ -0,0 +1,15 @@ +// aux-build:traits.rs +// build-aux-docs +// ignore-tidy-line-length +#![deny(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() {} +} diff --git a/src/test/rustdoc/intra-doc/disambiguators-removed.rs b/src/test/rustdoc/intra-doc/disambiguators-removed.rs new file mode 100644 index 00000000000..aa0ced62aaf --- /dev/null +++ b/src/test/rustdoc/intra-doc/disambiguators-removed.rs @@ -0,0 +1,51 @@ +// ignore-tidy-linelength +#![deny(intra_doc_link_resolution_failure)] +// first try backticks +/// Trait: [`trait@Name`], fn: [`fn@Name`], [`Name`][`macro@Name`] +// @has disambiguators_removed/struct.AtDisambiguator.html +// @has - '//a[@href="../disambiguators_removed/trait.Name.html"][code]' "Name" +// @has - '//a[@href="../disambiguators_removed/fn.Name.html"][code]' "Name" +// @has - '//a[@href="../disambiguators_removed/macro.Name.html"][code]' "Name" +pub struct AtDisambiguator; + +/// fn: [`Name()`], macro: [`Name!`] +// @has disambiguators_removed/struct.SymbolDisambiguator.html +// @has - '//a[@href="../disambiguators_removed/fn.Name.html"][code]' "Name()" +// @has - '//a[@href="../disambiguators_removed/macro.Name.html"][code]' "Name!" +pub struct SymbolDisambiguator; + +// Now make sure that backticks aren't added if they weren't already there +/// [fn@Name] +// @has disambiguators_removed/trait.Name.html +// @has - '//a[@href="../disambiguators_removed/fn.Name.html"]' "Name" +// @!has - '//a[@href="../disambiguators_removed/fn.Name.html"][code]' "Name" + +// FIXME: this will turn !() into ! alone +/// [Name!()] +// @has - '//a[@href="../disambiguators_removed/macro.Name.html"]' "Name!" +pub trait Name {} + +#[allow(non_snake_case)] + +// Try collapsed reference links +/// [macro@Name][] +// @has disambiguators_removed/fn.Name.html +// @has - '//a[@href="../disambiguators_removed/macro.Name.html"]' "Name" + +// Try links that have the same text as a generated URL +/// Weird URL aligned [../disambiguators_removed/macro.Name.html][trait@Name] +// @has - '//a[@href="../disambiguators_removed/trait.Name.html"]' "../disambiguators_removed/macro.Name.html" +pub fn Name() {} + +#[macro_export] +// Rustdoc doesn't currently handle links that have weird interspersing of inline code blocks. +/// [fn@Na`m`e] +// @has disambiguators_removed/macro.Name.html +// @has - '//a[@href="../disambiguators_removed/fn.Name.html"]' "fn@Name" + +// It also doesn't handle any case where the code block isn't the whole link text: +/// [trait@`Name`] +// @has - '//a[@href="../disambiguators_removed/trait.Name.html"]' "trait@Name" +macro_rules! Name { + () => () +} diff --git a/src/test/rustdoc/intra-doc/enum-struct-field.rs b/src/test/rustdoc/intra-doc/enum-struct-field.rs new file mode 100644 index 00000000000..70bf343a9a5 --- /dev/null +++ b/src/test/rustdoc/intra-doc/enum-struct-field.rs @@ -0,0 +1,14 @@ +#![crate_name = "foo"] + +pub enum Foo { + X { + y: u8, + } +} + +/// Hello +/// +/// I want [Foo::X::y]. +pub fn foo() {} + +// @has foo/fn.foo.html '//a/@href' '../foo/enum.Foo.html#variant.X.field.y' diff --git a/src/test/rustdoc/intra-doc/extern-crate.rs b/src/test/rustdoc/intra-doc/extern-crate.rs new file mode 100644 index 00000000000..193bca704bf --- /dev/null +++ b/src/test/rustdoc/intra-doc/extern-crate.rs @@ -0,0 +1,9 @@ +// aux-build:intra-link-extern-crate.rs + +// When loading `extern crate` statements, we would pull in their docs at the same time, even +// though they would never actually get displayed. This tripped intra-doc-link resolution failures, +// for items that aren't under our control, and not actually getting documented! + +#![deny(broken_intra_doc_links)] + +extern crate inner; diff --git a/src/test/rustdoc/intra-doc/extern-type.rs b/src/test/rustdoc/intra-doc/extern-type.rs new file mode 100644 index 00000000000..e1934698d1f --- /dev/null +++ b/src/test/rustdoc/intra-doc/extern-type.rs @@ -0,0 +1,17 @@ +#![feature(extern_types)] + +extern { + pub type ExternType; +} + +impl ExternType { + pub fn f(&self) { + + } +} + +// @has 'extern_type/foreigntype.ExternType.html' +// @has 'extern_type/fn.links_to_extern_type.html' \ +// 'href="../extern_type/foreigntype.ExternType.html#method.f"' +/// See also [ExternType::f] +pub fn links_to_extern_type() {} diff --git a/src/test/rustdoc/intra-doc/external-traits.rs b/src/test/rustdoc/intra-doc/external-traits.rs new file mode 100644 index 00000000000..de76f29476c --- /dev/null +++ b/src/test/rustdoc/intra-doc/external-traits.rs @@ -0,0 +1,12 @@ +// aux-build:intra-links-external-traits.rs +// ignore-cross-compile + +#![crate_name = "outer"] +#![deny(broken_intra_doc_links)] + +// using a trait that has intra-doc links on it from another crate (whether re-exporting or just +// implementing it) used to give spurious resolution failure warnings + +extern crate intra_links_external_traits; + +pub use intra_links_external_traits::ThisTrait; diff --git a/src/test/rustdoc/intra-doc/generic-params.rs b/src/test/rustdoc/intra-doc/generic-params.rs new file mode 100644 index 00000000000..1de6410f10c --- /dev/null +++ b/src/test/rustdoc/intra-doc/generic-params.rs @@ -0,0 +1,62 @@ +// ignore-tidy-linelength + +#![crate_name = "foo"] + +//! Here's a link to [`Vec`] and one to [`Box>>`]. +//! Here's a link to [`Iterator>::Item`]. +//! +// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html"]' 'Vec' +// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html"]' 'Box>>' +// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item"]' 'Iterator>::Item' + +//! And what about a link to [just `Option`](Option) and, [with the generic, `Option`](Option)? +//! +// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html"]' 'just Option' +// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html"]' 'with the generic, Option' + +//! We should also try linking to [`Result`]; it has *two* generics! +//! And [`Result`] and [`Result`]. +//! +// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html"]' 'Result' +// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html"]' 'Result' +// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html"]' 'Result' + +//! Now let's test a trickier case: [`Vec::::new`], or you could write it +//! [with parentheses as `Vec::::new()`][Vec::::new()]. +//! And what about something even harder? That would be [`Vec::>::new()`]. +//! +// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html#method.new"]' 'Vec::::new' +// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html#method.new"]' 'with parentheses as Vec::::new()' +// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html#method.new"]' 'Vec::>::new()' + +//! This is also pretty tricky: [`TypeId::of::()`]. +//! And this too: [`Vec::::len`]. +//! +// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html#method.of"]' 'TypeId::of::()' +// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html#method.len"]' 'Vec::::len' + +//! We unofficially and implicitly support things that aren't valid in the actual Rust syntax, like +//! [`Box::new()`]. We may not support them in the future! +//! +// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html#method.new"]' 'Box::new()' + +//! These will be resolved as regular links: +//! - [`this is first`](https://www.rust-lang.org) +//! - [`this is twice`] +//! - [` thrice`](https://www.rust-lang.org) +//! - [` four times`][rlo] +//! - [a < b][rlo] +//! - [c > d] +//! +//! [`this is twice`]: https://www.rust-lang.org +//! [rlo]: https://www.rust-lang.org +//! [c > d]: https://www.rust-lang.org +//! +// @has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'this is first' +// @has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'this is twice' +// @has foo/index.html '//a[@href="https://www.rust-lang.org"]' ' thrice' +// @has foo/index.html '//a[@href="https://www.rust-lang.org"]' ' four times' +// @has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'a < b' +// @has foo/index.html '//a[@href="https://www.rust-lang.org"]' 'c > d' + +use std::any::TypeId; diff --git a/src/test/rustdoc/intra-doc/in-bodies.rs b/src/test/rustdoc/intra-doc/in-bodies.rs new file mode 100644 index 00000000000..ec965a99dc2 --- /dev/null +++ b/src/test/rustdoc/intra-doc/in-bodies.rs @@ -0,0 +1,30 @@ +// we need to make sure that intra-doc links on trait impls get resolved in the right scope + +#![deny(broken_intra_doc_links)] + +pub mod inner { + pub struct SomethingOutOfScope; +} + +pub mod other { + use inner::SomethingOutOfScope; + use SomeTrait; + + pub struct OtherStruct; + + /// Let's link to [SomethingOutOfScope] while we're at it. + impl SomeTrait for OtherStruct {} +} + +pub trait SomeTrait {} + +pub struct SomeStruct; + +fn __implementation_details() { + use inner::SomethingOutOfScope; + + // FIXME: intra-links resolve in their nearest module scope, not their actual scope in cases + // like this + // Let's link to [SomethingOutOfScope] while we're at it. + impl SomeTrait for SomeStruct {} +} diff --git a/src/test/rustdoc/intra-doc/libstd-re-export.rs b/src/test/rustdoc/intra-doc/libstd-re-export.rs new file mode 100644 index 00000000000..d0af3aec660 --- /dev/null +++ b/src/test/rustdoc/intra-doc/libstd-re-export.rs @@ -0,0 +1,3 @@ +#![deny(broken_intra_doc_links)] + +pub use std::*; diff --git a/src/test/rustdoc/intra-doc/mod-ambiguity.rs b/src/test/rustdoc/intra-doc/mod-ambiguity.rs new file mode 100644 index 00000000000..feb013b22be --- /dev/null +++ b/src/test/rustdoc/intra-doc/mod-ambiguity.rs @@ -0,0 +1,16 @@ +#![deny(broken_intra_doc_links)] + + +pub fn foo() { + +} + +pub mod foo {} +// @has mod_ambiguity/struct.A.html '//a/@href' '../mod_ambiguity/foo/index.html' +/// Module is [`module@foo`] +pub struct A; + + +// @has mod_ambiguity/struct.B.html '//a/@href' '../mod_ambiguity/fn.foo.html' +/// Function is [`fn@foo`] +pub struct B; diff --git a/src/test/rustdoc/intra-doc/prim-assoc.rs b/src/test/rustdoc/intra-doc/prim-assoc.rs new file mode 100644 index 00000000000..d687cbd69bb --- /dev/null +++ b/src/test/rustdoc/intra-doc/prim-assoc.rs @@ -0,0 +1,5 @@ +// ignore-tidy-linelength +#![deny(broken_intra_doc_links)] + +//! [i32::MAX] +// @has prim_assoc/index.html '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.i32.html#associatedconstant.MAX"]' "i32::MAX" diff --git a/src/test/rustdoc/intra-doc/prim-methods-external-core.rs b/src/test/rustdoc/intra-doc/prim-methods-external-core.rs new file mode 100644 index 00000000000..434e0338983 --- /dev/null +++ b/src/test/rustdoc/intra-doc/prim-methods-external-core.rs @@ -0,0 +1,18 @@ +// aux-build:my-core.rs +// build-aux-docs +// ignore-cross-compile +// ignore-windows +// ignore-tidy-linelength + +#![deny(broken_intra_doc_links)] +#![feature(no_core, lang_items)] +#![no_core] +#![crate_type = "rlib"] + +// @has prim_methods_external_core/index.html +// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char' +// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8' + +//! A [`char`] and its [`char::len_utf8`]. + +extern crate my_core; diff --git a/src/test/rustdoc/intra-doc/prim-methods-local.rs b/src/test/rustdoc/intra-doc/prim-methods-local.rs new file mode 100644 index 00000000000..9888f29db5b --- /dev/null +++ b/src/test/rustdoc/intra-doc/prim-methods-local.rs @@ -0,0 +1,28 @@ +#![deny(broken_intra_doc_links)] +#![feature(no_core, lang_items)] +#![no_core] +#![crate_type = "rlib"] + +// ignore-tidy-linelength + +// @has prim_methods_local/index.html +// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char' +// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8' + +//! A [`char`] and its [`char::len_utf8`]. + +#[lang = "char"] +impl char { + pub fn len_utf8(self) -> usize { + 42 + } +} + +#[lang = "sized"] +pub trait Sized {} + +#[lang = "clone"] +pub trait Clone: Sized {} + +#[lang = "copy"] +pub trait Copy: Clone {} diff --git a/src/test/rustdoc/intra-doc/prim-methods.rs b/src/test/rustdoc/intra-doc/prim-methods.rs new file mode 100644 index 00000000000..f19cff7d34a --- /dev/null +++ b/src/test/rustdoc/intra-doc/prim-methods.rs @@ -0,0 +1,9 @@ +#![deny(broken_intra_doc_links)] + +// ignore-tidy-linelength + +// @has prim_methods/index.html +// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char' +// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8' + +//! A [`char`] and its [`char::len_utf8`]. diff --git a/src/test/rustdoc/intra-doc/prim-precedence.rs b/src/test/rustdoc/intra-doc/prim-precedence.rs new file mode 100644 index 00000000000..ed2c2cda718 --- /dev/null +++ b/src/test/rustdoc/intra-doc/prim-precedence.rs @@ -0,0 +1,17 @@ +// ignore-tidy-linelength +#![deny(broken_intra_doc_links)] + +pub mod char { + /// [char] + // @has prim_precedence/char/struct.Inner.html '//a/@href' 'https://doc.rust-lang.org/nightly/std/primitive.char.html' + pub struct Inner; +} + +/// See [prim@char] +// @has prim_precedence/struct.MyString.html '//a/@href' 'https://doc.rust-lang.org/nightly/std/primitive.char.html' +pub struct MyString; + +/// See also [crate::char] and [mod@char] +// @has prim_precedence/struct.MyString2.html '//*[@href="../prim_precedence/char/index.html"]' 'crate::char' +// @has - '//*[@href="../prim_precedence/char/index.html"]' 'mod@char' +pub struct MyString2; diff --git a/src/test/rustdoc/intra-doc/primitive-non-default-impl.rs b/src/test/rustdoc/intra-doc/primitive-non-default-impl.rs new file mode 100644 index 00000000000..548eb090a32 --- /dev/null +++ b/src/test/rustdoc/intra-doc/primitive-non-default-impl.rs @@ -0,0 +1,32 @@ +#![deny(broken_intra_doc_links)] + +// ignore-tidy-linelength + +// @has primitive_non_default_impl/fn.str_methods.html +/// [`str::trim`] +// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.str.html#method.trim"]' 'str::trim' +/// [`str::to_lowercase`] +// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.str.html#method.to_lowercase"]' 'str::to_lowercase' +/// [`str::into_boxed_bytes`] +// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.str.html#method.into_boxed_bytes"]' 'str::into_boxed_bytes' +/// [`str::replace`] +// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.str.html#method.replace"]' 'str::replace' +pub fn str_methods() {} + +// @has primitive_non_default_impl/fn.f32_methods.html +/// [f32::powi] +// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.f32.html#method.powi"]' 'f32::powi' +/// [f32::sqrt] +// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.f32.html#method.sqrt"]' 'f32::sqrt' +/// [f32::mul_add] +// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.f32.html#method.mul_add"]' 'f32::mul_add' +pub fn f32_methods() {} + +// @has primitive_non_default_impl/fn.f64_methods.html +/// [`f64::powi`] +// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.f64.html#method.powi"]' 'f64::powi' +/// [`f64::sqrt`] +// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.f64.html#method.sqrt"]' 'f64::sqrt' +/// [`f64::mul_add`] +// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.f64.html#method.mul_add"]' 'f64::mul_add' +pub fn f64_methods() {} diff --git a/src/test/rustdoc/intra-doc/private-failures-ignored.rs b/src/test/rustdoc/intra-doc/private-failures-ignored.rs new file mode 100644 index 00000000000..cf8bc0b1586 --- /dev/null +++ b/src/test/rustdoc/intra-doc/private-failures-ignored.rs @@ -0,0 +1,8 @@ +// Rustdoc would previously report resolution failures on items that weren't in the public docs. +// These failures were legitimate, but not truly relevant - the docs in question couldn't be +// checked for accuracy anyway. + +#![deny(broken_intra_doc_links)] + +/// ooh, i'm a [rebel] just for kicks +struct SomeStruct; diff --git a/src/test/rustdoc/intra-doc/private.rs b/src/test/rustdoc/intra-doc/private.rs new file mode 100644 index 00000000000..f86ca44403d --- /dev/null +++ b/src/test/rustdoc/intra-doc/private.rs @@ -0,0 +1,6 @@ +#![crate_name = "private"] +// compile-flags: --document-private-items +/// docs [DontDocMe] +// @has private/struct.DocMe.html '//*a[@href="../private/struct.DontDocMe.html"]' 'DontDocMe' +pub struct DocMe; +struct DontDocMe; diff --git a/src/test/rustdoc/intra-doc/proc-macro.rs b/src/test/rustdoc/intra-doc/proc-macro.rs new file mode 100644 index 00000000000..ab4626ccfc3 --- /dev/null +++ b/src/test/rustdoc/intra-doc/proc-macro.rs @@ -0,0 +1,27 @@ +// aux-build:proc-macro-macro.rs +// build-aux-docs +#![deny(broken_intra_doc_links)] + +extern crate proc_macro_macro; + + +pub use proc_macro_macro::{DeriveA, attr_a}; +use proc_macro_macro::{DeriveB, attr_b}; + +// @has proc_macro/struct.Foo.html +// @has - '//a/@href' '../proc_macro/derive.DeriveA.html' +// @has - '//a/@href' '../proc_macro/attr.attr_a.html' +// @has - '//a/@href' '../proc_macro/trait.DeriveTrait.html' +// @has - '//a/@href' '../proc_macro_macro/derive.DeriveB.html' +// @has - '//a/@href' '../proc_macro_macro/attr.attr_b.html' +/// Link to [DeriveA], [attr_a], [DeriveB], [attr_b], [DeriveTrait] +pub struct Foo; + +// @has proc_macro/struct.Bar.html +// @has - '//a/@href' '../proc_macro/derive.DeriveA.html' +// @has - '//a/@href' '../proc_macro/attr.attr_a.html' +/// Link to [deriveA](derive@DeriveA) [attr](macro@attr_a) +pub struct Bar; + +// this should not cause ambiguity errors +pub trait DeriveTrait {} diff --git a/src/test/rustdoc/intra-doc/pub-use.rs b/src/test/rustdoc/intra-doc/pub-use.rs new file mode 100644 index 00000000000..dd52249abc6 --- /dev/null +++ b/src/test/rustdoc/intra-doc/pub-use.rs @@ -0,0 +1,27 @@ +// aux-build: intra-link-pub-use.rs +#![deny(broken_intra_doc_links)] +#![crate_name = "outer"] + +extern crate inner; + +/// [mod@std::env] [g] + +// FIXME: This can't be tested because rustdoc doesn't show documentation on pub re-exports. +// Until then, comment out the `htmldocck` test. +// This test still does something; namely check that no incorrect errors are emitted when +// documenting the re-export. + +// @has outer/index.html +// @ has - '//a[@href="https://doc.rust-lang.org/nightly/std/env/fn.var.html"]' "std::env" +// @ has - '//a[@href="../outer/fn.f.html"]' "g" +pub use f as g; + +// FIXME: same as above +/// [std::env] +extern crate self as _; + +// Make sure the documentation is actually correct by documenting an inlined re-export +/// [mod@std::env] +// @has outer/fn.f.html +// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/env/index.html"]' "std::env" +pub use inner::f; diff --git a/src/test/rustdoc/intra-doc/reexport-additional-docs.rs b/src/test/rustdoc/intra-doc/reexport-additional-docs.rs new file mode 100644 index 00000000000..96f3580f305 --- /dev/null +++ b/src/test/rustdoc/intra-doc/reexport-additional-docs.rs @@ -0,0 +1,23 @@ +// aux-build:intra-link-reexport-additional-docs.rs +// build-aux-docs +#![crate_name = "foo"] +extern crate inner; + +// @has foo/struct.Inner.html '//a[@href="../foo/fn.with_code.html"]' 'crate::with_code' +/// [crate::with_code] +// @has - '//a[@href="../foo/fn.with_code.html"]' 'different text' +/// [different text][with_code] +// @has - '//a[@href="../foo/fn.me_too.html"]' 'me_too' +#[doc = "[me_too]"] +// @has - '//a[@href="../foo/fn.me_three.html"]' 'reference link' +/// This [reference link] +#[doc = "has an attr in the way"] +/// +/// [reference link]: me_three +// Should still resolve links from the original module in that scope +// @has - '//a[@href="../inner/fn.f.html"]' 'f()' +pub use inner::Inner; + +pub fn with_code() {} +pub fn me_too() {} +pub fn me_three() {} diff --git a/src/test/rustdoc/intra-doc/self.rs b/src/test/rustdoc/intra-doc/self.rs new file mode 100644 index 00000000000..81545fec741 --- /dev/null +++ b/src/test/rustdoc/intra-doc/self.rs @@ -0,0 +1,117 @@ +#![crate_name = "foo"] + +// ignore-tidy-linelength + +// @has foo/index.html '//a/@href' '../foo/struct.Foo.html#method.new' +// @has foo/struct.Foo.html '//a/@href' '../foo/struct.Foo.html#method.new' + +/// Use [`new`] to create a new instance. +/// +/// [`new`]: Self::new +pub struct Foo; + +impl Foo { + pub fn new() -> Self { + unimplemented!() + } +} + +// @has foo/index.html '//a/@href' '../foo/struct.Bar.html#method.new2' +// @has foo/struct.Bar.html '//a/@href' '../foo/struct.Bar.html#method.new2' + +/// Use [`new2`] to create a new instance. +/// +/// [`new2`]: Self::new2 +pub struct Bar; + +impl Bar { + pub fn new2() -> Self { + unimplemented!() + } +} + +pub struct MyStruct { + // @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#structfield.struct_field' + + /// [`struct_field`] + /// + /// [`struct_field`]: Self::struct_field + pub struct_field: u8, +} + +pub enum MyEnum { + // @has foo/enum.MyEnum.html '//a/@href' '../foo/enum.MyEnum.html#variant.EnumVariant' + + /// [`EnumVariant`] + /// + /// [`EnumVariant`]: Self::EnumVariant + EnumVariant, +} + +pub union MyUnion { + // @has foo/union.MyUnion.html '//a/@href' '../foo/union.MyUnion.html#structfield.union_field' + + /// [`union_field`] + /// + /// [`union_field`]: Self::union_field + pub union_field: f32, +} + +pub trait MyTrait { + // @has foo/trait.MyTrait.html '//a/@href' '../foo/trait.MyTrait.html#associatedtype.AssoType' + + /// [`AssoType`] + /// + /// [`AssoType`]: Self::AssoType + type AssoType; + + // @has foo/trait.MyTrait.html '//a/@href' '../foo/trait.MyTrait.html#associatedconstant.ASSO_CONST' + + /// [`ASSO_CONST`] + /// + /// [`ASSO_CONST`]: Self::ASSO_CONST + const ASSO_CONST: i32 = 1; + + // @has foo/trait.MyTrait.html '//a/@href' '../foo/trait.MyTrait.html#method.asso_fn' + + /// [`asso_fn`] + /// + /// [`asso_fn`]: Self::asso_fn + fn asso_fn() {} +} + +impl MyStruct { + // @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#method.for_impl' + + /// [`for_impl`] + /// + /// [`for_impl`]: Self::for_impl + pub fn for_impl() { + unimplemented!() + } +} + +impl MyTrait for MyStruct { + // @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#associatedtype.AssoType' + + /// [`AssoType`] + /// + /// [`AssoType`]: Self::AssoType + type AssoType = u32; + + // @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#associatedconstant.ASSO_CONST' + + /// [`ASSO_CONST`] + /// + /// [`ASSO_CONST`]: Self::ASSO_CONST + const ASSO_CONST: i32 = 10; + + // @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#method.asso_fn' + + /// [`asso_fn`] + /// + /// [`asso_fn`]: Self::asso_fn + fn asso_fn() { + unimplemented!() + } +} diff --git a/src/test/rustdoc/intra-doc/through-proc-macro.rs b/src/test/rustdoc/intra-doc/through-proc-macro.rs new file mode 100644 index 00000000000..613410871f0 --- /dev/null +++ b/src/test/rustdoc/intra-doc/through-proc-macro.rs @@ -0,0 +1,12 @@ +// aux-build:through-proc-macro-aux.rs +// build-aux-docs +#![warn(broken_intra_doc_links)] +extern crate some_macros; + +#[some_macros::second] +pub enum Boom { + /// [Oooops] + Bam, +} + +fn main() {} diff --git a/src/test/rustdoc/intra-doc/trait-impl.rs b/src/test/rustdoc/intra-doc/trait-impl.rs new file mode 100644 index 00000000000..fab8406d525 --- /dev/null +++ b/src/test/rustdoc/intra-doc/trait-impl.rs @@ -0,0 +1,35 @@ +#![crate_name = "foo"] + +// ignore-tidy-linelength + +pub struct MyStruct; + +impl MyTrait for MyStruct { + +// @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#associatedtype.AssoType' + + /// [`AssoType`] + /// + /// [`AssoType`]: MyStruct::AssoType + type AssoType = u32; + +// @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#associatedconstant.ASSO_CONST' + + /// [`ASSO_CONST`] + /// + /// [`ASSO_CONST`]: MyStruct::ASSO_CONST + const ASSO_CONST: i32 = 10; + +// @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#method.trait_fn' + + /// [`trait_fn`] + /// + /// [`trait_fn`]: MyStruct::trait_fn + fn trait_fn() { } +} + +pub trait MyTrait { + type AssoType; + const ASSO_CONST: i32 = 1; + fn trait_fn(); +} diff --git a/src/test/rustdoc/intra-doc/trait-item.rs b/src/test/rustdoc/intra-doc/trait-item.rs new file mode 100644 index 00000000000..de8585f4c9a --- /dev/null +++ b/src/test/rustdoc/intra-doc/trait-item.rs @@ -0,0 +1,12 @@ +// ignore-tidy-linelength +#![deny(broken_intra_doc_links)] + +/// Link to [S::assoc_fn()] +/// Link to [Default::default()] +// @has trait_item/struct.S.html '//*[@href="../trait_item/struct.S.html#method.assoc_fn"]' 'S::assoc_fn()' +// @has - '//*[@href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default"]' 'Default::default()' +pub struct S; + +impl S { + pub fn assoc_fn() {} +} diff --git a/src/test/rustdoc/intra-doc/true-false.rs b/src/test/rustdoc/intra-doc/true-false.rs new file mode 100644 index 00000000000..7b21e934147 --- /dev/null +++ b/src/test/rustdoc/intra-doc/true-false.rs @@ -0,0 +1,10 @@ +#![deny(broken_intra_doc_links)] +#![crate_name = "foo"] + +// ignore-tidy-linelength + +// @has foo/index.html +// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.bool.html"]' 'true' +// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.bool.html"]' 'false' + +//! A `bool` is either [`true`] or [`false`]. diff --git a/src/test/rustdoc/intra-link-associated-defaults.rs b/src/test/rustdoc/intra-link-associated-defaults.rs deleted file mode 100644 index 2051129b948..00000000000 --- a/src/test/rustdoc/intra-link-associated-defaults.rs +++ /dev/null @@ -1,27 +0,0 @@ -// ignore-tidy-linelength -#![deny(intra_doc_link_resolution_failure)] -#![feature(associated_type_defaults)] - -pub trait TraitWithDefault { - type T = usize; - fn f() -> Self::T { - 0 - } -} - -/// Link to [UsesDefaults::T] and [UsesDefaults::f] -// @has 'intra_link_associated_defaults/struct.UsesDefaults.html' '//a[@href="../intra_link_associated_defaults/struct.UsesDefaults.html#associatedtype.T"]' 'UsesDefaults::T' -// @has 'intra_link_associated_defaults/struct.UsesDefaults.html' '//a[@href="../intra_link_associated_defaults/struct.UsesDefaults.html#method.f"]' 'UsesDefaults::f' -pub struct UsesDefaults; -impl TraitWithDefault for UsesDefaults {} - -/// Link to [OverridesDefaults::T] and [OverridesDefaults::f] -// @has 'intra_link_associated_defaults/struct.OverridesDefaults.html' '//a[@href="../intra_link_associated_defaults/struct.OverridesDefaults.html#associatedtype.T"]' 'OverridesDefaults::T' -// @has 'intra_link_associated_defaults/struct.OverridesDefaults.html' '//a[@href="../intra_link_associated_defaults/struct.OverridesDefaults.html#method.f"]' 'OverridesDefaults::f' -pub struct OverridesDefaults; -impl TraitWithDefault for OverridesDefaults { - type T = bool; - fn f() -> bool { - true - } -} diff --git a/src/test/rustdoc/intra-link-associated-items.rs b/src/test/rustdoc/intra-link-associated-items.rs deleted file mode 100644 index daf7075a917..00000000000 --- a/src/test/rustdoc/intra-link-associated-items.rs +++ /dev/null @@ -1,61 +0,0 @@ -// ignore-tidy-linelength -#![deny(intra_doc_link_resolution_failure)] - -/// [`std::collections::BTreeMap::into_iter`] -/// [`String::from`] is ambiguous as to which `From` impl -/// [Vec::into_iter()] uses a disambiguator -// @has 'intra_link_associated_items/fn.foo.html' '//a[@href="https://doc.rust-lang.org/nightly/alloc/collections/btree/map/struct.BTreeMap.html#method.into_iter"]' 'std::collections::BTreeMap::into_iter' -// @has 'intra_link_associated_items/fn.foo.html' '//a[@href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html#method.from"]' 'String::from' -// @has 'intra_link_associated_items/fn.foo.html' '//a[@href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html#method.into_iter"]' 'Vec::into_iter' -pub fn foo() {} - -/// Link to [MyStruct], [link from struct][MyStruct::method], [MyStruct::clone], [MyStruct::Input] -// @has 'intra_link_associated_items/struct.MyStruct.html' '//a[@href="../intra_link_associated_items/struct.MyStruct.html"]' 'MyStruct' -// @has 'intra_link_associated_items/struct.MyStruct.html' '//a[@href="../intra_link_associated_items/struct.MyStruct.html#method.method"]' 'link from struct' -// @has 'intra_link_associated_items/struct.MyStruct.html' '//a[@href="../intra_link_associated_items/struct.MyStruct.html#method.clone"]' 'MyStruct::clone' -// @has 'intra_link_associated_items/struct.MyStruct.html' '//a[@href="../intra_link_associated_items/struct.MyStruct.html#associatedtype.Input"]' 'MyStruct::Input' -pub struct MyStruct { foo: () } - -impl Clone for MyStruct { - fn clone(&self) -> Self { - MyStruct - } -} - -pub trait T { - type Input; - fn method(i: Self::Input); -} - -impl T for MyStruct { - type Input = usize; - - /// [link from method][MyStruct::method] on method - // @has 'intra_link_associated_items/struct.MyStruct.html' '//a[@href="../intra_link_associated_items/struct.MyStruct.html#method.method"]' 'link from method' - fn method(i: usize) { - } -} - -/// Ambiguity between which trait to use -pub trait T1 { - fn ambiguous_method(); -} - -pub trait T2 { - fn ambiguous_method(); -} - -/// Link to [S::ambiguous_method] -// FIXME: there is no way to disambiguate these. -// Since we have `#[deny(intra_doc_failure)]`, we still know it was one or the other. -pub struct S; - -impl T1 for S { - fn ambiguous_method() {} -} - -impl T2 for S { - fn ambiguous_method() {} -} - -fn main() {} diff --git a/src/test/rustdoc/intra-link-builtin-macros.rs b/src/test/rustdoc/intra-link-builtin-macros.rs deleted file mode 100644 index 4d40eb3b88f..00000000000 --- a/src/test/rustdoc/intra-link-builtin-macros.rs +++ /dev/null @@ -1,3 +0,0 @@ -// @has intra_link_builtin_macros/index.html -// @has - '//a/@href' 'https://doc.rust-lang.org/nightly/core/macro.cfg.html' -//! [cfg] diff --git a/src/test/rustdoc/intra-link-cross-crate-crate.rs b/src/test/rustdoc/intra-link-cross-crate-crate.rs deleted file mode 100644 index edf544708b6..00000000000 --- a/src/test/rustdoc/intra-link-cross-crate-crate.rs +++ /dev/null @@ -1,6 +0,0 @@ -// 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/src/test/rustdoc/intra-link-disambiguators-removed.rs b/src/test/rustdoc/intra-link-disambiguators-removed.rs deleted file mode 100644 index 26d05b484b9..00000000000 --- a/src/test/rustdoc/intra-link-disambiguators-removed.rs +++ /dev/null @@ -1,51 +0,0 @@ -// ignore-tidy-linelength -#![deny(intra_doc_link_resolution_failure)] -// first try backticks -/// Trait: [`trait@Name`], fn: [`fn@Name`], [`Name`][`macro@Name`] -// @has intra_link_disambiguators_removed/struct.AtDisambiguator.html -// @has - '//a[@href="../intra_link_disambiguators_removed/trait.Name.html"][code]' "Name" -// @has - '//a[@href="../intra_link_disambiguators_removed/fn.Name.html"][code]' "Name" -// @has - '//a[@href="../intra_link_disambiguators_removed/macro.Name.html"][code]' "Name" -pub struct AtDisambiguator; - -/// fn: [`Name()`], macro: [`Name!`] -// @has intra_link_disambiguators_removed/struct.SymbolDisambiguator.html -// @has - '//a[@href="../intra_link_disambiguators_removed/fn.Name.html"][code]' "Name()" -// @has - '//a[@href="../intra_link_disambiguators_removed/macro.Name.html"][code]' "Name!" -pub struct SymbolDisambiguator; - -// Now make sure that backticks aren't added if they weren't already there -/// [fn@Name] -// @has intra_link_disambiguators_removed/trait.Name.html -// @has - '//a[@href="../intra_link_disambiguators_removed/fn.Name.html"]' "Name" -// @!has - '//a[@href="../intra_link_disambiguators_removed/fn.Name.html"][code]' "Name" - -// FIXME: this will turn !() into ! alone -/// [Name!()] -// @has - '//a[@href="../intra_link_disambiguators_removed/macro.Name.html"]' "Name!" -pub trait Name {} - -#[allow(non_snake_case)] - -// Try collapsed reference links -/// [macro@Name][] -// @has intra_link_disambiguators_removed/fn.Name.html -// @has - '//a[@href="../intra_link_disambiguators_removed/macro.Name.html"]' "Name" - -// Try links that have the same text as a generated URL -/// Weird URL aligned [../intra_link_disambiguators_removed/macro.Name.html][trait@Name] -// @has - '//a[@href="../intra_link_disambiguators_removed/trait.Name.html"]' "../intra_link_disambiguators_removed/macro.Name.html" -pub fn Name() {} - -#[macro_export] -// Rustdoc doesn't currently handle links that have weird interspersing of inline code blocks. -/// [fn@Na`m`e] -// @has intra_link_disambiguators_removed/macro.Name.html -// @has - '//a[@href="../intra_link_disambiguators_removed/fn.Name.html"]' "fn@Name" - -// It also doesn't handle any case where the code block isn't the whole link text: -/// [trait@`Name`] -// @has - '//a[@href="../intra_link_disambiguators_removed/trait.Name.html"]' "trait@Name" -macro_rules! Name { - () => () -} diff --git a/src/test/rustdoc/intra-link-extern-crate.rs b/src/test/rustdoc/intra-link-extern-crate.rs deleted file mode 100644 index 193bca704bf..00000000000 --- a/src/test/rustdoc/intra-link-extern-crate.rs +++ /dev/null @@ -1,9 +0,0 @@ -// aux-build:intra-link-extern-crate.rs - -// When loading `extern crate` statements, we would pull in their docs at the same time, even -// though they would never actually get displayed. This tripped intra-doc-link resolution failures, -// for items that aren't under our control, and not actually getting documented! - -#![deny(broken_intra_doc_links)] - -extern crate inner; diff --git a/src/test/rustdoc/intra-link-extern-type.rs b/src/test/rustdoc/intra-link-extern-type.rs deleted file mode 100644 index 418e0d91ea7..00000000000 --- a/src/test/rustdoc/intra-link-extern-type.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![feature(extern_types)] - -extern { - pub type ExternType; -} - -impl ExternType { - pub fn f(&self) { - - } -} - -// @has 'intra_link_extern_type/foreigntype.ExternType.html' -// @has 'intra_link_extern_type/fn.links_to_extern_type.html' \ -// 'href="../intra_link_extern_type/foreigntype.ExternType.html#method.f"' -/// See also [ExternType::f] -pub fn links_to_extern_type() { -} diff --git a/src/test/rustdoc/intra-link-in-bodies.rs b/src/test/rustdoc/intra-link-in-bodies.rs deleted file mode 100644 index ec965a99dc2..00000000000 --- a/src/test/rustdoc/intra-link-in-bodies.rs +++ /dev/null @@ -1,30 +0,0 @@ -// we need to make sure that intra-doc links on trait impls get resolved in the right scope - -#![deny(broken_intra_doc_links)] - -pub mod inner { - pub struct SomethingOutOfScope; -} - -pub mod other { - use inner::SomethingOutOfScope; - use SomeTrait; - - pub struct OtherStruct; - - /// Let's link to [SomethingOutOfScope] while we're at it. - impl SomeTrait for OtherStruct {} -} - -pub trait SomeTrait {} - -pub struct SomeStruct; - -fn __implementation_details() { - use inner::SomethingOutOfScope; - - // FIXME: intra-links resolve in their nearest module scope, not their actual scope in cases - // like this - // Let's link to [SomethingOutOfScope] while we're at it. - impl SomeTrait for SomeStruct {} -} diff --git a/src/test/rustdoc/intra-link-libstd-re-export.rs b/src/test/rustdoc/intra-link-libstd-re-export.rs deleted file mode 100644 index d0af3aec660..00000000000 --- a/src/test/rustdoc/intra-link-libstd-re-export.rs +++ /dev/null @@ -1,3 +0,0 @@ -#![deny(broken_intra_doc_links)] - -pub use std::*; diff --git a/src/test/rustdoc/intra-link-prim-assoc.rs b/src/test/rustdoc/intra-link-prim-assoc.rs deleted file mode 100644 index c0066885e19..00000000000 --- a/src/test/rustdoc/intra-link-prim-assoc.rs +++ /dev/null @@ -1,5 +0,0 @@ -// ignore-tidy-linelength -#![deny(broken_intra_doc_links)] - -//! [i32::MAX] -// @has intra_link_prim_assoc/index.html '//a[@href="https://doc.rust-lang.org/nightly/std/primitive.i32.html#associatedconstant.MAX"]' "i32::MAX" diff --git a/src/test/rustdoc/intra-link-prim-methods-external-core.rs b/src/test/rustdoc/intra-link-prim-methods-external-core.rs deleted file mode 100644 index c8ef4c01599..00000000000 --- a/src/test/rustdoc/intra-link-prim-methods-external-core.rs +++ /dev/null @@ -1,18 +0,0 @@ -// aux-build:my-core.rs -// build-aux-docs -// ignore-cross-compile -// ignore-windows -// ignore-tidy-linelength - -#![deny(broken_intra_doc_links)] -#![feature(no_core, lang_items)] -#![no_core] -#![crate_type = "rlib"] - -// @has intra_link_prim_methods_external_core/index.html -// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char' -// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8' - -//! A [`char`] and its [`char::len_utf8`]. - -extern crate my_core; diff --git a/src/test/rustdoc/intra-link-prim-methods-local.rs b/src/test/rustdoc/intra-link-prim-methods-local.rs deleted file mode 100644 index d448acf7f96..00000000000 --- a/src/test/rustdoc/intra-link-prim-methods-local.rs +++ /dev/null @@ -1,28 +0,0 @@ -#![deny(broken_intra_doc_links)] -#![feature(no_core, lang_items)] -#![no_core] -#![crate_type = "rlib"] - -// ignore-tidy-linelength - -// @has intra_link_prim_methods_local/index.html -// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char' -// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8' - -//! A [`char`] and its [`char::len_utf8`]. - -#[lang = "char"] -impl char { - pub fn len_utf8(self) -> usize { - 42 - } -} - -#[lang = "sized"] -pub trait Sized {} - -#[lang = "clone"] -pub trait Clone: Sized {} - -#[lang = "copy"] -pub trait Copy: Clone {} diff --git a/src/test/rustdoc/intra-link-prim-methods.rs b/src/test/rustdoc/intra-link-prim-methods.rs deleted file mode 100644 index 94c80c996c1..00000000000 --- a/src/test/rustdoc/intra-link-prim-methods.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![deny(broken_intra_doc_links)] - -// ignore-tidy-linelength - -// @has intra_link_prim_methods/index.html -// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html"]' 'char' -// @has - '//*[@id="main"]//a[@href="https://doc.rust-lang.org/nightly/std/primitive.char.html#method.len_utf8"]' 'char::len_utf8' - -//! A [`char`] and its [`char::len_utf8`]. diff --git a/src/test/rustdoc/intra-link-prim-precedence.rs b/src/test/rustdoc/intra-link-prim-precedence.rs deleted file mode 100644 index 0a4e57ef643..00000000000 --- a/src/test/rustdoc/intra-link-prim-precedence.rs +++ /dev/null @@ -1,17 +0,0 @@ -// ignore-tidy-linelength -#![deny(broken_intra_doc_links)] - -pub mod char { - /// [char] - // @has intra_link_prim_precedence/char/struct.Inner.html '//a/@href' 'https://doc.rust-lang.org/nightly/std/primitive.char.html' - pub struct Inner; -} - -/// See [prim@char] -// @has intra_link_prim_precedence/struct.MyString.html '//a/@href' 'https://doc.rust-lang.org/nightly/std/primitive.char.html' -pub struct MyString; - -/// See also [crate::char] and [mod@char] -// @has intra_link_prim_precedence/struct.MyString2.html '//*[@href="../intra_link_prim_precedence/char/index.html"]' 'crate::char' -// @has - '//*[@href="../intra_link_prim_precedence/char/index.html"]' 'mod@char' -pub struct MyString2; diff --git a/src/test/rustdoc/intra-link-primitive-non-default-impl.rs b/src/test/rustdoc/intra-link-primitive-non-default-impl.rs deleted file mode 100644 index 160b18a967b..00000000000 --- a/src/test/rustdoc/intra-link-primitive-non-default-impl.rs +++ /dev/null @@ -1,32 +0,0 @@ -#![deny(broken_intra_doc_links)] - -// ignore-tidy-linelength - -// @has intra_link_primitive_non_default_impl/fn.str_methods.html -/// [`str::trim`] -// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.str.html#method.trim"]' 'str::trim' -/// [`str::to_lowercase`] -// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.str.html#method.to_lowercase"]' 'str::to_lowercase' -/// [`str::into_boxed_bytes`] -// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.str.html#method.into_boxed_bytes"]' 'str::into_boxed_bytes' -/// [`str::replace`] -// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.str.html#method.replace"]' 'str::replace' -pub fn str_methods() {} - -// @has intra_link_primitive_non_default_impl/fn.f32_methods.html -/// [f32::powi] -// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.f32.html#method.powi"]' 'f32::powi' -/// [f32::sqrt] -// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.f32.html#method.sqrt"]' 'f32::sqrt' -/// [f32::mul_add] -// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.f32.html#method.mul_add"]' 'f32::mul_add' -pub fn f32_methods() {} - -// @has intra_link_primitive_non_default_impl/fn.f64_methods.html -/// [`f64::powi`] -// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.f64.html#method.powi"]' 'f64::powi' -/// [`f64::sqrt`] -// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.f64.html#method.sqrt"]' 'f64::sqrt' -/// [`f64::mul_add`] -// @has - '//*[@href="https://doc.rust-lang.org/nightly/std/primitive.f64.html#method.mul_add"]' 'f64::mul_add' -pub fn f64_methods() {} diff --git a/src/test/rustdoc/intra-link-private.rs b/src/test/rustdoc/intra-link-private.rs deleted file mode 100644 index cf8bc0b1586..00000000000 --- a/src/test/rustdoc/intra-link-private.rs +++ /dev/null @@ -1,8 +0,0 @@ -// Rustdoc would previously report resolution failures on items that weren't in the public docs. -// These failures were legitimate, but not truly relevant - the docs in question couldn't be -// checked for accuracy anyway. - -#![deny(broken_intra_doc_links)] - -/// ooh, i'm a [rebel] just for kicks -struct SomeStruct; diff --git a/src/test/rustdoc/intra-link-proc-macro.rs b/src/test/rustdoc/intra-link-proc-macro.rs deleted file mode 100644 index 7a8403255ed..00000000000 --- a/src/test/rustdoc/intra-link-proc-macro.rs +++ /dev/null @@ -1,27 +0,0 @@ -// aux-build:intra-link-proc-macro-macro.rs -// build-aux-docs -#![deny(broken_intra_doc_links)] - -extern crate intra_link_proc_macro_macro; - - -pub use intra_link_proc_macro_macro::{DeriveA, attr_a}; -use intra_link_proc_macro_macro::{DeriveB, attr_b}; - -// @has intra_link_proc_macro/struct.Foo.html -// @has - '//a/@href' '../intra_link_proc_macro/derive.DeriveA.html' -// @has - '//a/@href' '../intra_link_proc_macro/attr.attr_a.html' -// @has - '//a/@href' '../intra_link_proc_macro/trait.DeriveTrait.html' -// @has - '//a/@href' '../intra_link_proc_macro_macro/derive.DeriveB.html' -// @has - '//a/@href' '../intra_link_proc_macro_macro/attr.attr_b.html' -/// Link to [DeriveA], [attr_a], [DeriveB], [attr_b], [DeriveTrait] -pub struct Foo; - -// @has intra_link_proc_macro/struct.Bar.html -// @has - '//a/@href' '../intra_link_proc_macro/derive.DeriveA.html' -// @has - '//a/@href' '../intra_link_proc_macro/attr.attr_a.html' -/// Link to [deriveA](derive@DeriveA) [attr](macro@attr_a) -pub struct Bar; - -// this should not cause ambiguity errors -pub trait DeriveTrait {} diff --git a/src/test/rustdoc/intra-link-pub-use.rs b/src/test/rustdoc/intra-link-pub-use.rs deleted file mode 100644 index dd52249abc6..00000000000 --- a/src/test/rustdoc/intra-link-pub-use.rs +++ /dev/null @@ -1,27 +0,0 @@ -// aux-build: intra-link-pub-use.rs -#![deny(broken_intra_doc_links)] -#![crate_name = "outer"] - -extern crate inner; - -/// [mod@std::env] [g] - -// FIXME: This can't be tested because rustdoc doesn't show documentation on pub re-exports. -// Until then, comment out the `htmldocck` test. -// This test still does something; namely check that no incorrect errors are emitted when -// documenting the re-export. - -// @has outer/index.html -// @ has - '//a[@href="https://doc.rust-lang.org/nightly/std/env/fn.var.html"]' "std::env" -// @ has - '//a[@href="../outer/fn.f.html"]' "g" -pub use f as g; - -// FIXME: same as above -/// [std::env] -extern crate self as _; - -// Make sure the documentation is actually correct by documenting an inlined re-export -/// [mod@std::env] -// @has outer/fn.f.html -// @has - '//a[@href="https://doc.rust-lang.org/nightly/std/env/index.html"]' "std::env" -pub use inner::f; diff --git a/src/test/rustdoc/intra-link-reexport-additional-docs.rs b/src/test/rustdoc/intra-link-reexport-additional-docs.rs deleted file mode 100644 index 96f3580f305..00000000000 --- a/src/test/rustdoc/intra-link-reexport-additional-docs.rs +++ /dev/null @@ -1,23 +0,0 @@ -// aux-build:intra-link-reexport-additional-docs.rs -// build-aux-docs -#![crate_name = "foo"] -extern crate inner; - -// @has foo/struct.Inner.html '//a[@href="../foo/fn.with_code.html"]' 'crate::with_code' -/// [crate::with_code] -// @has - '//a[@href="../foo/fn.with_code.html"]' 'different text' -/// [different text][with_code] -// @has - '//a[@href="../foo/fn.me_too.html"]' 'me_too' -#[doc = "[me_too]"] -// @has - '//a[@href="../foo/fn.me_three.html"]' 'reference link' -/// This [reference link] -#[doc = "has an attr in the way"] -/// -/// [reference link]: me_three -// Should still resolve links from the original module in that scope -// @has - '//a[@href="../inner/fn.f.html"]' 'f()' -pub use inner::Inner; - -pub fn with_code() {} -pub fn me_too() {} -pub fn me_three() {} diff --git a/src/test/rustdoc/intra-link-self.rs b/src/test/rustdoc/intra-link-self.rs deleted file mode 100644 index 81545fec741..00000000000 --- a/src/test/rustdoc/intra-link-self.rs +++ /dev/null @@ -1,117 +0,0 @@ -#![crate_name = "foo"] - -// ignore-tidy-linelength - -// @has foo/index.html '//a/@href' '../foo/struct.Foo.html#method.new' -// @has foo/struct.Foo.html '//a/@href' '../foo/struct.Foo.html#method.new' - -/// Use [`new`] to create a new instance. -/// -/// [`new`]: Self::new -pub struct Foo; - -impl Foo { - pub fn new() -> Self { - unimplemented!() - } -} - -// @has foo/index.html '//a/@href' '../foo/struct.Bar.html#method.new2' -// @has foo/struct.Bar.html '//a/@href' '../foo/struct.Bar.html#method.new2' - -/// Use [`new2`] to create a new instance. -/// -/// [`new2`]: Self::new2 -pub struct Bar; - -impl Bar { - pub fn new2() -> Self { - unimplemented!() - } -} - -pub struct MyStruct { - // @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#structfield.struct_field' - - /// [`struct_field`] - /// - /// [`struct_field`]: Self::struct_field - pub struct_field: u8, -} - -pub enum MyEnum { - // @has foo/enum.MyEnum.html '//a/@href' '../foo/enum.MyEnum.html#variant.EnumVariant' - - /// [`EnumVariant`] - /// - /// [`EnumVariant`]: Self::EnumVariant - EnumVariant, -} - -pub union MyUnion { - // @has foo/union.MyUnion.html '//a/@href' '../foo/union.MyUnion.html#structfield.union_field' - - /// [`union_field`] - /// - /// [`union_field`]: Self::union_field - pub union_field: f32, -} - -pub trait MyTrait { - // @has foo/trait.MyTrait.html '//a/@href' '../foo/trait.MyTrait.html#associatedtype.AssoType' - - /// [`AssoType`] - /// - /// [`AssoType`]: Self::AssoType - type AssoType; - - // @has foo/trait.MyTrait.html '//a/@href' '../foo/trait.MyTrait.html#associatedconstant.ASSO_CONST' - - /// [`ASSO_CONST`] - /// - /// [`ASSO_CONST`]: Self::ASSO_CONST - const ASSO_CONST: i32 = 1; - - // @has foo/trait.MyTrait.html '//a/@href' '../foo/trait.MyTrait.html#method.asso_fn' - - /// [`asso_fn`] - /// - /// [`asso_fn`]: Self::asso_fn - fn asso_fn() {} -} - -impl MyStruct { - // @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#method.for_impl' - - /// [`for_impl`] - /// - /// [`for_impl`]: Self::for_impl - pub fn for_impl() { - unimplemented!() - } -} - -impl MyTrait for MyStruct { - // @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#associatedtype.AssoType' - - /// [`AssoType`] - /// - /// [`AssoType`]: Self::AssoType - type AssoType = u32; - - // @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#associatedconstant.ASSO_CONST' - - /// [`ASSO_CONST`] - /// - /// [`ASSO_CONST`]: Self::ASSO_CONST - const ASSO_CONST: i32 = 10; - - // @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#method.asso_fn' - - /// [`asso_fn`] - /// - /// [`asso_fn`]: Self::asso_fn - fn asso_fn() { - unimplemented!() - } -} diff --git a/src/test/rustdoc/intra-link-trait-impl.rs b/src/test/rustdoc/intra-link-trait-impl.rs deleted file mode 100644 index fab8406d525..00000000000 --- a/src/test/rustdoc/intra-link-trait-impl.rs +++ /dev/null @@ -1,35 +0,0 @@ -#![crate_name = "foo"] - -// ignore-tidy-linelength - -pub struct MyStruct; - -impl MyTrait for MyStruct { - -// @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#associatedtype.AssoType' - - /// [`AssoType`] - /// - /// [`AssoType`]: MyStruct::AssoType - type AssoType = u32; - -// @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#associatedconstant.ASSO_CONST' - - /// [`ASSO_CONST`] - /// - /// [`ASSO_CONST`]: MyStruct::ASSO_CONST - const ASSO_CONST: i32 = 10; - -// @has foo/struct.MyStruct.html '//a/@href' '../foo/struct.MyStruct.html#method.trait_fn' - - /// [`trait_fn`] - /// - /// [`trait_fn`]: MyStruct::trait_fn - fn trait_fn() { } -} - -pub trait MyTrait { - type AssoType; - const ASSO_CONST: i32 = 1; - fn trait_fn(); -} diff --git a/src/test/rustdoc/intra-link-trait-item.rs b/src/test/rustdoc/intra-link-trait-item.rs deleted file mode 100644 index 54270414c9d..00000000000 --- a/src/test/rustdoc/intra-link-trait-item.rs +++ /dev/null @@ -1,12 +0,0 @@ -// ignore-tidy-linelength -#![deny(broken_intra_doc_links)] - -/// Link to [S::assoc_fn()] -/// Link to [Default::default()] -// @has intra_link_trait_item/struct.S.html '//*[@href="../intra_link_trait_item/struct.S.html#method.assoc_fn"]' 'S::assoc_fn()' -// @has - '//*[@href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html#tymethod.default"]' 'Default::default()' -pub struct S; - -impl S { - pub fn assoc_fn() {} -} diff --git a/src/test/rustdoc/intra-links-anchors.rs b/src/test/rustdoc/intra-links-anchors.rs deleted file mode 100644 index f554e16b4f4..00000000000 --- a/src/test/rustdoc/intra-links-anchors.rs +++ /dev/null @@ -1,12 +0,0 @@ -/// I want... -/// -/// # Anchor! -pub struct Something; - -// @has intra_links_anchors/struct.SomeOtherType.html -// @has - '//a/@href' '../intra_links_anchors/struct.Something.html#Anchor!' - -/// I want... -/// -/// To link to [Something#Anchor!] -pub struct SomeOtherType; diff --git a/src/test/rustdoc/intra-links-external-traits.rs b/src/test/rustdoc/intra-links-external-traits.rs deleted file mode 100644 index de76f29476c..00000000000 --- a/src/test/rustdoc/intra-links-external-traits.rs +++ /dev/null @@ -1,12 +0,0 @@ -// aux-build:intra-links-external-traits.rs -// ignore-cross-compile - -#![crate_name = "outer"] -#![deny(broken_intra_doc_links)] - -// using a trait that has intra-doc links on it from another crate (whether re-exporting or just -// implementing it) used to give spurious resolution failure warnings - -extern crate intra_links_external_traits; - -pub use intra_links_external_traits::ThisTrait; diff --git a/src/test/rustdoc/intra-links.rs b/src/test/rustdoc/intra-links.rs deleted file mode 100644 index 751c10925c0..00000000000 --- a/src/test/rustdoc/intra-links.rs +++ /dev/null @@ -1,84 +0,0 @@ -// @has intra_links/index.html -// @has - '//a/@href' '../intra_links/struct.ThisType.html' -// @has - '//a/@href' '../intra_links/struct.ThisType.html#method.this_method' -// @has - '//a/@href' '../intra_links/enum.ThisEnum.html' -// @has - '//a/@href' '../intra_links/enum.ThisEnum.html#variant.ThisVariant' -// @has - '//a/@href' '../intra_links/trait.ThisTrait.html' -// @has - '//a/@href' '../intra_links/trait.ThisTrait.html#tymethod.this_associated_method' -// @has - '//a/@href' '../intra_links/trait.ThisTrait.html#associatedtype.ThisAssociatedType' -// @has - '//a/@href' '../intra_links/trait.ThisTrait.html#associatedconstant.THIS_ASSOCIATED_CONST' -// @has - '//a/@href' '../intra_links/trait.ThisTrait.html' -// @has - '//a/@href' '../intra_links/type.ThisAlias.html' -// @has - '//a/@href' '../intra_links/union.ThisUnion.html' -// @has - '//a/@href' '../intra_links/fn.this_function.html' -// @has - '//a/@href' '../intra_links/constant.THIS_CONST.html' -// @has - '//a/@href' '../intra_links/static.THIS_STATIC.html' -// @has - '//a/@href' '../intra_links/macro.this_macro.html' -// @has - '//a/@href' '../intra_links/trait.SoAmbiguous.html' -// @has - '//a/@href' '../intra_links/fn.SoAmbiguous.html' -//! In this crate we would like to link to: -//! -//! * [`ThisType`](ThisType) -//! * [`ThisType::this_method`](ThisType::this_method) -//! * [`ThisEnum`](ThisEnum) -//! * [`ThisEnum::ThisVariant`](ThisEnum::ThisVariant) -//! * [`ThisEnum::ThisVariantCtor`](ThisEnum::ThisVariantCtor) -//! * [`ThisTrait`](ThisTrait) -//! * [`ThisTrait::this_associated_method`](ThisTrait::this_associated_method) -//! * [`ThisTrait::ThisAssociatedType`](ThisTrait::ThisAssociatedType) -//! * [`ThisTrait::THIS_ASSOCIATED_CONST`](ThisTrait::THIS_ASSOCIATED_CONST) -//! * [`ThisAlias`](ThisAlias) -//! * [`ThisUnion`](ThisUnion) -//! * [`this_function`](this_function()) -//! * [`THIS_CONST`](const@THIS_CONST) -//! * [`THIS_STATIC`](static@THIS_STATIC) -//! * [`this_macro`](this_macro!) -//! -//! In addition, there's some specifics we want to look at. There's [a trait called -//! SoAmbiguous][ambig-trait], but there's also [a function called SoAmbiguous][ambig-fn] too! -//! Whatever shall we do? -//! -//! [ambig-trait]: trait@SoAmbiguous -//! [ambig-fn]: SoAmbiguous() - -#[macro_export] -macro_rules! this_macro { - () => {}; -} - -// @has intra_links/struct.ThisType.html '//a/@href' '../intra_links/macro.this_macro.html' -/// another link to [`this_macro!()`] -pub struct ThisType; - -impl ThisType { - pub fn this_method() {} -} -pub enum ThisEnum { ThisVariant, ThisVariantCtor(u32), } -pub trait ThisTrait { - type ThisAssociatedType; - const THIS_ASSOCIATED_CONST: u8; - fn this_associated_method(); -} -pub type ThisAlias = Result<(), ()>; -pub union ThisUnion { this_field: usize, } - -pub fn this_function() {} -pub const THIS_CONST: usize = 5usize; -pub static THIS_STATIC: usize = 5usize; - -pub trait SoAmbiguous {} - -#[allow(nonstandard_style)] -pub fn SoAmbiguous() {} - - -// @has intra_links/struct.SomeOtherType.html '//a/@href' '../intra_links/struct.ThisType.html' -// @has - '//a/@href' '../intra_links/struct.ThisType.html#method.this_method' -// @has - '//a/@href' '../intra_links/enum.ThisEnum.html' -// @has - '//a/@href' '../intra_links/enum.ThisEnum.html#variant.ThisVariant' -/// Shortcut links for: -/// * [`ThisType`] -/// * [`ThisType::this_method`] -/// * [ThisEnum] -/// * [ThisEnum::ThisVariant] -pub struct SomeOtherType; diff --git a/src/test/rustdoc/through-proc-macro.rs b/src/test/rustdoc/through-proc-macro.rs deleted file mode 100644 index 613410871f0..00000000000 --- a/src/test/rustdoc/through-proc-macro.rs +++ /dev/null @@ -1,12 +0,0 @@ -// aux-build:through-proc-macro-aux.rs -// build-aux-docs -#![warn(broken_intra_doc_links)] -extern crate some_macros; - -#[some_macros::second] -pub enum Boom { - /// [Oooops] - Bam, -} - -fn main() {} -- cgit 1.4.1-3-g733a5 From 872acb0c3589450a10f6fec97cd1a781e2d17794 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 28 Nov 2020 21:10:37 -0500 Subject: Move `src/test/rustdoc-ui` intra-doc tests into a subdirectory This also changes the builder to allow using `x.py test src/test/rustdoc-ui/intra-doc`; before, it would panic that no paths were found. --- src/bootstrap/test.rs | 33 +--- src/test/rustdoc-ui/.gitattributes | 1 - src/test/rustdoc-ui/auxiliary/intra-doc-broken.rs | 4 - src/test/rustdoc-ui/intra-doc-alias-ice.rs | 6 - src/test/rustdoc-ui/intra-doc-alias-ice.stderr | 14 -- src/test/rustdoc-ui/intra-doc-broken-reexport.rs | 8 - src/test/rustdoc-ui/intra-doc/.gitattributes | 1 + src/test/rustdoc-ui/intra-doc/alias-ice.rs | 6 + src/test/rustdoc-ui/intra-doc/alias-ice.stderr | 14 ++ src/test/rustdoc-ui/intra-doc/ambiguity.rs | 40 +++++ src/test/rustdoc-ui/intra-doc/ambiguity.stderr | 101 ++++++++++++ src/test/rustdoc-ui/intra-doc/anchors.rs | 45 ++++++ src/test/rustdoc-ui/intra-doc/anchors.stderr | 32 ++++ .../intra-doc/auxiliary/intra-doc-broken.rs | 4 + src/test/rustdoc-ui/intra-doc/broken-reexport.rs | 8 + .../rustdoc-ui/intra-doc/disambiguator-mismatch.rs | 68 ++++++++ .../intra-doc/disambiguator-mismatch.stderr | 95 +++++++++++ src/test/rustdoc-ui/intra-doc/double-anchor.rs | 7 + src/test/rustdoc-ui/intra-doc/double-anchor.stderr | 10 ++ src/test/rustdoc-ui/intra-doc/errors.rs | 105 +++++++++++++ src/test/rustdoc-ui/intra-doc/errors.stderr | 143 +++++++++++++++++ .../rustdoc-ui/intra-doc/malformed-generics.rs | 19 +++ .../rustdoc-ui/intra-doc/malformed-generics.stderr | 102 ++++++++++++ src/test/rustdoc-ui/intra-doc/prim-conflict.rs | 30 ++++ src/test/rustdoc-ui/intra-doc/prim-conflict.stderr | 53 +++++++ .../rustdoc-ui/intra-doc/private.private.stderr | 11 ++ .../rustdoc-ui/intra-doc/private.public.stderr | 11 ++ src/test/rustdoc-ui/intra-doc/private.rs | 9 ++ src/test/rustdoc-ui/intra-doc/span-ice-55723.rs | 13 ++ .../rustdoc-ui/intra-doc/span-ice-55723.stderr | 15 ++ src/test/rustdoc-ui/intra-doc/warning-crlf.rs | 26 +++ src/test/rustdoc-ui/intra-doc/warning-crlf.stderr | 35 +++++ src/test/rustdoc-ui/intra-doc/warning.rs | 84 ++++++++++ src/test/rustdoc-ui/intra-doc/warning.stderr | 175 +++++++++++++++++++++ src/test/rustdoc-ui/intra-link-double-anchor.rs | 7 - .../rustdoc-ui/intra-link-double-anchor.stderr | 10 -- src/test/rustdoc-ui/intra-link-errors.rs | 105 ------------- src/test/rustdoc-ui/intra-link-errors.stderr | 143 ----------------- .../rustdoc-ui/intra-link-malformed-generics.rs | 19 --- .../intra-link-malformed-generics.stderr | 102 ------------ src/test/rustdoc-ui/intra-link-prim-conflict.rs | 30 ---- .../rustdoc-ui/intra-link-prim-conflict.stderr | 53 ------- src/test/rustdoc-ui/intra-link-span-ice-55723.rs | 13 -- .../rustdoc-ui/intra-link-span-ice-55723.stderr | 15 -- src/test/rustdoc-ui/intra-links-ambiguity.rs | 40 ----- src/test/rustdoc-ui/intra-links-ambiguity.stderr | 101 ------------ src/test/rustdoc-ui/intra-links-anchors.rs | 45 ------ src/test/rustdoc-ui/intra-links-anchors.stderr | 32 ---- .../intra-links-disambiguator-mismatch.rs | 68 -------- .../intra-links-disambiguator-mismatch.stderr | 95 ----------- .../rustdoc-ui/intra-links-private.private.stderr | 11 -- .../rustdoc-ui/intra-links-private.public.stderr | 11 -- src/test/rustdoc-ui/intra-links-private.rs | 9 -- src/test/rustdoc-ui/intra-links-warning-crlf.rs | 26 --- .../rustdoc-ui/intra-links-warning-crlf.stderr | 35 ----- src/test/rustdoc-ui/intra-links-warning.rs | 84 ---------- src/test/rustdoc-ui/intra-links-warning.stderr | 175 --------------------- 57 files changed, 1263 insertions(+), 1294 deletions(-) delete mode 100644 src/test/rustdoc-ui/.gitattributes delete mode 100644 src/test/rustdoc-ui/auxiliary/intra-doc-broken.rs delete mode 100644 src/test/rustdoc-ui/intra-doc-alias-ice.rs delete mode 100644 src/test/rustdoc-ui/intra-doc-alias-ice.stderr delete mode 100644 src/test/rustdoc-ui/intra-doc-broken-reexport.rs create mode 100644 src/test/rustdoc-ui/intra-doc/.gitattributes create mode 100644 src/test/rustdoc-ui/intra-doc/alias-ice.rs create mode 100644 src/test/rustdoc-ui/intra-doc/alias-ice.stderr create mode 100644 src/test/rustdoc-ui/intra-doc/ambiguity.rs create mode 100644 src/test/rustdoc-ui/intra-doc/ambiguity.stderr create mode 100644 src/test/rustdoc-ui/intra-doc/anchors.rs create mode 100644 src/test/rustdoc-ui/intra-doc/anchors.stderr create mode 100644 src/test/rustdoc-ui/intra-doc/auxiliary/intra-doc-broken.rs create mode 100644 src/test/rustdoc-ui/intra-doc/broken-reexport.rs create mode 100644 src/test/rustdoc-ui/intra-doc/disambiguator-mismatch.rs create mode 100644 src/test/rustdoc-ui/intra-doc/disambiguator-mismatch.stderr create mode 100644 src/test/rustdoc-ui/intra-doc/double-anchor.rs create mode 100644 src/test/rustdoc-ui/intra-doc/double-anchor.stderr create mode 100644 src/test/rustdoc-ui/intra-doc/errors.rs create mode 100644 src/test/rustdoc-ui/intra-doc/errors.stderr create mode 100644 src/test/rustdoc-ui/intra-doc/malformed-generics.rs create mode 100644 src/test/rustdoc-ui/intra-doc/malformed-generics.stderr create mode 100644 src/test/rustdoc-ui/intra-doc/prim-conflict.rs create mode 100644 src/test/rustdoc-ui/intra-doc/prim-conflict.stderr create mode 100644 src/test/rustdoc-ui/intra-doc/private.private.stderr create mode 100644 src/test/rustdoc-ui/intra-doc/private.public.stderr create mode 100644 src/test/rustdoc-ui/intra-doc/private.rs create mode 100644 src/test/rustdoc-ui/intra-doc/span-ice-55723.rs create mode 100644 src/test/rustdoc-ui/intra-doc/span-ice-55723.stderr create mode 100644 src/test/rustdoc-ui/intra-doc/warning-crlf.rs create mode 100644 src/test/rustdoc-ui/intra-doc/warning-crlf.stderr create mode 100644 src/test/rustdoc-ui/intra-doc/warning.rs create mode 100644 src/test/rustdoc-ui/intra-doc/warning.stderr delete mode 100644 src/test/rustdoc-ui/intra-link-double-anchor.rs delete mode 100644 src/test/rustdoc-ui/intra-link-double-anchor.stderr delete mode 100644 src/test/rustdoc-ui/intra-link-errors.rs delete mode 100644 src/test/rustdoc-ui/intra-link-errors.stderr delete mode 100644 src/test/rustdoc-ui/intra-link-malformed-generics.rs delete mode 100644 src/test/rustdoc-ui/intra-link-malformed-generics.stderr delete mode 100644 src/test/rustdoc-ui/intra-link-prim-conflict.rs delete mode 100644 src/test/rustdoc-ui/intra-link-prim-conflict.stderr delete mode 100644 src/test/rustdoc-ui/intra-link-span-ice-55723.rs delete mode 100644 src/test/rustdoc-ui/intra-link-span-ice-55723.stderr delete mode 100644 src/test/rustdoc-ui/intra-links-ambiguity.rs delete mode 100644 src/test/rustdoc-ui/intra-links-ambiguity.stderr delete mode 100644 src/test/rustdoc-ui/intra-links-anchors.rs delete mode 100644 src/test/rustdoc-ui/intra-links-anchors.stderr delete mode 100644 src/test/rustdoc-ui/intra-links-disambiguator-mismatch.rs delete mode 100644 src/test/rustdoc-ui/intra-links-disambiguator-mismatch.stderr delete mode 100644 src/test/rustdoc-ui/intra-links-private.private.stderr delete mode 100644 src/test/rustdoc-ui/intra-links-private.public.stderr delete mode 100644 src/test/rustdoc-ui/intra-links-private.rs delete mode 100644 src/test/rustdoc-ui/intra-links-warning-crlf.rs delete mode 100644 src/test/rustdoc-ui/intra-links-warning-crlf.stderr delete mode 100644 src/test/rustdoc-ui/intra-links-warning.rs delete mode 100644 src/test/rustdoc-ui/intra-links-warning.stderr diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index e087e2b8ff1..dad36640dbf 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -688,38 +688,6 @@ impl Step for RustdocJSNotStd { } } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct RustdocUi { - pub target: TargetSelection, - pub compiler: Compiler, -} - -impl Step for RustdocUi { - type Output = (); - const DEFAULT: bool = true; - const ONLY_HOSTS: bool = true; - - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.path("src/test/rustdoc-ui") - } - - fn make_run(run: RunConfig<'_>) { - let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple()); - run.builder.ensure(RustdocUi { target: run.target, compiler }); - } - - fn run(self, builder: &Builder<'_>) { - builder.ensure(Compiletest { - compiler: self.compiler, - target: self.target, - mode: "ui", - suite: "rustdoc-ui", - path: "src/test/rustdoc-ui", - compare_mode: None, - }) - } -} - #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Tidy; @@ -934,6 +902,7 @@ default_test!(Debuginfo { path: "src/test/debuginfo", mode: "debuginfo", suite: host_test!(UiFullDeps { path: "src/test/ui-fulldeps", mode: "ui", suite: "ui-fulldeps" }); host_test!(Rustdoc { path: "src/test/rustdoc", mode: "rustdoc", suite: "rustdoc" }); +host_test!(RustdocUi { path: "src/test/rustdoc-ui", mode: "ui", suite: "rustdoc-ui" }); host_test!(Pretty { path: "src/test/pretty", mode: "pretty", suite: "pretty" }); diff --git a/src/test/rustdoc-ui/.gitattributes b/src/test/rustdoc-ui/.gitattributes deleted file mode 100644 index 2bcabdffb3d..00000000000 --- a/src/test/rustdoc-ui/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -intra-links-warning-crlf.rs eol=crlf diff --git a/src/test/rustdoc-ui/auxiliary/intra-doc-broken.rs b/src/test/rustdoc-ui/auxiliary/intra-doc-broken.rs deleted file mode 100644 index 31a8310d472..00000000000 --- a/src/test/rustdoc-ui/auxiliary/intra-doc-broken.rs +++ /dev/null @@ -1,4 +0,0 @@ -#![crate_name = "intra_doc_broken"] - -/// [not_found] -pub fn foo() {} diff --git a/src/test/rustdoc-ui/intra-doc-alias-ice.rs b/src/test/rustdoc-ui/intra-doc-alias-ice.rs deleted file mode 100644 index c053e378e71..00000000000 --- a/src/test/rustdoc-ui/intra-doc-alias-ice.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![deny(broken_intra_doc_links)] - -pub type TypeAlias = usize; - -/// [broken cross-reference](TypeAlias::hoge) //~ ERROR -pub fn some_public_item() {} diff --git a/src/test/rustdoc-ui/intra-doc-alias-ice.stderr b/src/test/rustdoc-ui/intra-doc-alias-ice.stderr deleted file mode 100644 index 771fc2204f5..00000000000 --- a/src/test/rustdoc-ui/intra-doc-alias-ice.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: unresolved link to `TypeAlias::hoge` - --> $DIR/intra-doc-alias-ice.rs:5:30 - | -LL | /// [broken cross-reference](TypeAlias::hoge) - | ^^^^^^^^^^^^^^^ the type alias `TypeAlias` has no associated item named `hoge` - | -note: the lint level is defined here - --> $DIR/intra-doc-alias-ice.rs:1:9 - | -LL | #![deny(broken_intra_doc_links)] - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/rustdoc-ui/intra-doc-broken-reexport.rs b/src/test/rustdoc-ui/intra-doc-broken-reexport.rs deleted file mode 100644 index ef261359ebd..00000000000 --- a/src/test/rustdoc-ui/intra-doc-broken-reexport.rs +++ /dev/null @@ -1,8 +0,0 @@ -// aux-build:intra-doc-broken.rs -// check-pass - -#![deny(broken_intra_doc_links)] - -extern crate intra_doc_broken; - -pub use intra_doc_broken::foo; diff --git a/src/test/rustdoc-ui/intra-doc/.gitattributes b/src/test/rustdoc-ui/intra-doc/.gitattributes new file mode 100644 index 00000000000..6c125fac52f --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/.gitattributes @@ -0,0 +1 @@ +warning-crlf.rs eol=crlf diff --git a/src/test/rustdoc-ui/intra-doc/alias-ice.rs b/src/test/rustdoc-ui/intra-doc/alias-ice.rs new file mode 100644 index 00000000000..c053e378e71 --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/alias-ice.rs @@ -0,0 +1,6 @@ +#![deny(broken_intra_doc_links)] + +pub type TypeAlias = usize; + +/// [broken cross-reference](TypeAlias::hoge) //~ ERROR +pub fn some_public_item() {} diff --git a/src/test/rustdoc-ui/intra-doc/alias-ice.stderr b/src/test/rustdoc-ui/intra-doc/alias-ice.stderr new file mode 100644 index 00000000000..3db5fad4cfb --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/alias-ice.stderr @@ -0,0 +1,14 @@ +error: unresolved link to `TypeAlias::hoge` + --> $DIR/alias-ice.rs:5:30 + | +LL | /// [broken cross-reference](TypeAlias::hoge) + | ^^^^^^^^^^^^^^^ the type alias `TypeAlias` has no associated item named `hoge` + | +note: the lint level is defined here + --> $DIR/alias-ice.rs:1:9 + | +LL | #![deny(broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/rustdoc-ui/intra-doc/ambiguity.rs b/src/test/rustdoc-ui/intra-doc/ambiguity.rs new file mode 100644 index 00000000000..f63435337cf --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/ambiguity.rs @@ -0,0 +1,40 @@ +#![deny(broken_intra_doc_links)] +#![allow(non_camel_case_types)] +#![allow(non_upper_case_globals)] + +pub fn ambiguous() {} + +pub struct ambiguous {} + +#[macro_export] +macro_rules! multi_conflict { () => {} } + +#[allow(non_camel_case_types)] +pub struct multi_conflict {} + +pub fn multi_conflict() {} + +pub mod type_and_value {} + +pub const type_and_value: i32 = 0; + +pub mod foo { + pub enum bar {} + + pub fn bar() {} +} + +/// [`ambiguous`] is ambiguous. //~ERROR `ambiguous` +/// +/// [ambiguous] is ambiguous. //~ERROR ambiguous +/// +/// [`multi_conflict`] is a three-way conflict. //~ERROR `multi_conflict` +/// +/// Ambiguous [type_and_value]. //~ERROR type_and_value +/// +/// Ambiguous non-implied shortcut link [`foo::bar`]. //~ERROR `foo::bar` +pub struct Docs {} + +/// [true] //~ ERROR `true` is both a module and a builtin type +/// [primitive@true] +pub mod r#true {} diff --git a/src/test/rustdoc-ui/intra-doc/ambiguity.stderr b/src/test/rustdoc-ui/intra-doc/ambiguity.stderr new file mode 100644 index 00000000000..7e967dc88bc --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/ambiguity.stderr @@ -0,0 +1,101 @@ +error: `true` is both a module and a builtin type + --> $DIR/ambiguity.rs:38:6 + | +LL | /// [true] + | ^^^^ ambiguous link + | +note: the lint level is defined here + --> $DIR/ambiguity.rs:1:9 + | +LL | #![deny(broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^ +help: to link to the module, prefix with `mod@` + | +LL | /// [mod@true] + | ^^^^^^^^ +help: to link to the builtin type, prefix with `prim@` + | +LL | /// [prim@true] + | ^^^^^^^^^ + +error: `ambiguous` is both a struct and a function + --> $DIR/ambiguity.rs:27:6 + | +LL | /// [`ambiguous`] is ambiguous. + | ^^^^^^^^^^^ ambiguous link + | +help: to link to the struct, prefix with `struct@` + | +LL | /// [`struct@ambiguous`] is ambiguous. + | ^^^^^^^^^^^^^^^^^^ +help: to link to the function, add parentheses + | +LL | /// [`ambiguous()`] is ambiguous. + | ^^^^^^^^^^^^^ + +error: `ambiguous` is both a struct and a function + --> $DIR/ambiguity.rs:29:6 + | +LL | /// [ambiguous] is ambiguous. + | ^^^^^^^^^ ambiguous link + | +help: to link to the struct, prefix with `struct@` + | +LL | /// [struct@ambiguous] is ambiguous. + | ^^^^^^^^^^^^^^^^ +help: to link to the function, add parentheses + | +LL | /// [ambiguous()] is ambiguous. + | ^^^^^^^^^^^ + +error: `multi_conflict` is a struct, a function, and a macro + --> $DIR/ambiguity.rs:31:6 + | +LL | /// [`multi_conflict`] is a three-way conflict. + | ^^^^^^^^^^^^^^^^ ambiguous link + | +help: to link to the struct, prefix with `struct@` + | +LL | /// [`struct@multi_conflict`] is a three-way conflict. + | ^^^^^^^^^^^^^^^^^^^^^^^ +help: to link to the function, add parentheses + | +LL | /// [`multi_conflict()`] is a three-way conflict. + | ^^^^^^^^^^^^^^^^^^ +help: to link to the macro, add an exclamation mark + | +LL | /// [`multi_conflict!`] is a three-way conflict. + | ^^^^^^^^^^^^^^^^^ + +error: `type_and_value` is both a module and a constant + --> $DIR/ambiguity.rs:33:16 + | +LL | /// Ambiguous [type_and_value]. + | ^^^^^^^^^^^^^^ ambiguous link + | +help: to link to the module, prefix with `mod@` + | +LL | /// Ambiguous [mod@type_and_value]. + | ^^^^^^^^^^^^^^^^^^ +help: to link to the constant, prefix with `const@` + | +LL | /// Ambiguous [const@type_and_value]. + | ^^^^^^^^^^^^^^^^^^^^ + +error: `foo::bar` is both an enum and a function + --> $DIR/ambiguity.rs:35:42 + | +LL | /// Ambiguous non-implied shortcut link [`foo::bar`]. + | ^^^^^^^^^^ ambiguous link + | +help: to link to the enum, prefix with `enum@` + | +LL | /// Ambiguous non-implied shortcut link [`enum@foo::bar`]. + | ^^^^^^^^^^^^^^^ +help: to link to the function, add parentheses + | +LL | /// Ambiguous non-implied shortcut link [`foo::bar()`]. + | ^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + diff --git a/src/test/rustdoc-ui/intra-doc/anchors.rs b/src/test/rustdoc-ui/intra-doc/anchors.rs new file mode 100644 index 00000000000..ccefd2e6fab --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/anchors.rs @@ -0,0 +1,45 @@ +#![deny(broken_intra_doc_links)] + +// A few tests on anchors. + +/// Hello people. +/// +/// You can anchors? Here's one! +/// +/// # hola +/// +/// Isn't it amazing? +pub struct Foo { + pub f: u8, +} + +pub enum Enum { + A, + B, +} + +/// Have you heard about stuff? +/// +/// Like [Foo#hola]. +/// +/// Or maybe [Foo::f#hola]. +//~^ ERROR `Foo::f#hola` contains an anchor +pub fn foo() {} + +/// Empty. +/// +/// Another anchor error: [hello#people#!]. +//~^ ERROR `hello#people#!` contains multiple anchors +pub fn bar() {} + +/// Empty? +/// +/// Damn enum's variants: [Enum::A#whatever]. +//~^ ERROR `Enum::A#whatever` contains an anchor +pub fn enum_link() {} + +/// Primitives? +/// +/// [u32#hello] +//~^ ERROR `u32#hello` contains an anchor +pub fn x() {} diff --git a/src/test/rustdoc-ui/intra-doc/anchors.stderr b/src/test/rustdoc-ui/intra-doc/anchors.stderr new file mode 100644 index 00000000000..5b272d960d5 --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/anchors.stderr @@ -0,0 +1,32 @@ +error: `Foo::f#hola` contains an anchor, but links to fields are already anchored + --> $DIR/anchors.rs:25:15 + | +LL | /// Or maybe [Foo::f#hola]. + | ^^^^^^^^^^^ contains invalid anchor + | +note: the lint level is defined here + --> $DIR/anchors.rs:1:9 + | +LL | #![deny(broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: `hello#people#!` contains multiple anchors + --> $DIR/anchors.rs:31:28 + | +LL | /// Another anchor error: [hello#people#!]. + | ^^^^^^^^^^^^^^ contains invalid anchor + +error: `Enum::A#whatever` contains an anchor, but links to variants are already anchored + --> $DIR/anchors.rs:37:28 + | +LL | /// Damn enum's variants: [Enum::A#whatever]. + | ^^^^^^^^^^^^^^^^ contains invalid anchor + +error: `u32#hello` contains an anchor, but links to builtin types are already anchored + --> $DIR/anchors.rs:43:6 + | +LL | /// [u32#hello] + | ^^^^^^^^^ contains invalid anchor + +error: aborting due to 4 previous errors + diff --git a/src/test/rustdoc-ui/intra-doc/auxiliary/intra-doc-broken.rs b/src/test/rustdoc-ui/intra-doc/auxiliary/intra-doc-broken.rs new file mode 100644 index 00000000000..31a8310d472 --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/auxiliary/intra-doc-broken.rs @@ -0,0 +1,4 @@ +#![crate_name = "intra_doc_broken"] + +/// [not_found] +pub fn foo() {} diff --git a/src/test/rustdoc-ui/intra-doc/broken-reexport.rs b/src/test/rustdoc-ui/intra-doc/broken-reexport.rs new file mode 100644 index 00000000000..ef261359ebd --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/broken-reexport.rs @@ -0,0 +1,8 @@ +// aux-build:intra-doc-broken.rs +// check-pass + +#![deny(broken_intra_doc_links)] + +extern crate intra_doc_broken; + +pub use intra_doc_broken::foo; diff --git a/src/test/rustdoc-ui/intra-doc/disambiguator-mismatch.rs b/src/test/rustdoc-ui/intra-doc/disambiguator-mismatch.rs new file mode 100644 index 00000000000..b9c8e033b1b --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/disambiguator-mismatch.rs @@ -0,0 +1,68 @@ +#![deny(broken_intra_doc_links)] +//~^ NOTE lint level is defined +pub enum S {} + +macro_rules! m { + () => {}; +} + +static s: usize = 0; +const c: usize = 0; + +trait T {} + +/// Link to [struct@S] +//~^ ERROR incompatible link kind for `S` +//~| NOTE this link resolved +//~| HELP prefix with `enum@` + +/// Link to [mod@S] +//~^ ERROR incompatible link kind for `S` +//~| NOTE this link resolved +//~| HELP prefix with `enum@` + +/// Link to [union@S] +//~^ ERROR incompatible link kind for `S` +//~| NOTE this link resolved +//~| HELP prefix with `enum@` + +/// Link to [trait@S] +//~^ ERROR incompatible link kind for `S` +//~| NOTE this link resolved +//~| HELP prefix with `enum@` + +/// Link to [struct@T] +//~^ ERROR incompatible link kind for `T` +//~| NOTE this link resolved +//~| HELP prefix with `trait@` + +/// Link to [derive@m] +//~^ ERROR incompatible link kind for `m` +//~| NOTE this link resolved +//~| HELP add an exclamation mark + +/// Link to [const@s] +//~^ ERROR incompatible link kind for `s` +//~| NOTE this link resolved +//~| HELP prefix with `static@` + +/// Link to [static@c] +//~^ ERROR incompatible link kind for `c` +//~| NOTE this link resolved +//~| HELP prefix with `const@` + +/// Link to [fn@c] +//~^ ERROR incompatible link kind for `c` +//~| NOTE this link resolved +//~| HELP prefix with `const@` + +/// Link to [c()] +//~^ ERROR incompatible link kind for `c` +//~| NOTE this link resolved +//~| HELP prefix with `const@` + +/// Link to [const@f] +//~^ ERROR incompatible link kind for `f` +//~| NOTE this link resolved +//~| HELP add parentheses +pub fn f() {} diff --git a/src/test/rustdoc-ui/intra-doc/disambiguator-mismatch.stderr b/src/test/rustdoc-ui/intra-doc/disambiguator-mismatch.stderr new file mode 100644 index 00000000000..2f5f3daa297 --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/disambiguator-mismatch.stderr @@ -0,0 +1,95 @@ +error: incompatible link kind for `S` + --> $DIR/disambiguator-mismatch.rs:14:14 + | +LL | /// Link to [struct@S] + | ^^^^^^^^ help: to link to the enum, prefix with `enum@`: `enum@S` + | +note: the lint level is defined here + --> $DIR/disambiguator-mismatch.rs:1:9 + | +LL | #![deny(broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^ + = note: this link resolved to an enum, which is not a struct + +error: incompatible link kind for `S` + --> $DIR/disambiguator-mismatch.rs:19:14 + | +LL | /// Link to [mod@S] + | ^^^^^ help: to link to the enum, prefix with `enum@`: `enum@S` + | + = note: this link resolved to an enum, which is not a module + +error: incompatible link kind for `S` + --> $DIR/disambiguator-mismatch.rs:24:14 + | +LL | /// Link to [union@S] + | ^^^^^^^ help: to link to the enum, prefix with `enum@`: `enum@S` + | + = note: this link resolved to an enum, which is not a union + +error: incompatible link kind for `S` + --> $DIR/disambiguator-mismatch.rs:29:14 + | +LL | /// Link to [trait@S] + | ^^^^^^^ help: to link to the enum, prefix with `enum@`: `enum@S` + | + = note: this link resolved to an enum, which is not a trait + +error: incompatible link kind for `T` + --> $DIR/disambiguator-mismatch.rs:34:14 + | +LL | /// Link to [struct@T] + | ^^^^^^^^ help: to link to the trait, prefix with `trait@`: `trait@T` + | + = note: this link resolved to a trait, which is not a struct + +error: incompatible link kind for `m` + --> $DIR/disambiguator-mismatch.rs:39:14 + | +LL | /// Link to [derive@m] + | ^^^^^^^^ help: to link to the macro, add an exclamation mark: `m!` + | + = note: this link resolved to a macro, which is not a derive macro + +error: incompatible link kind for `s` + --> $DIR/disambiguator-mismatch.rs:44:14 + | +LL | /// Link to [const@s] + | ^^^^^^^ help: to link to the static, prefix with `static@`: `static@s` + | + = note: this link resolved to a static, which is not a constant + +error: incompatible link kind for `c` + --> $DIR/disambiguator-mismatch.rs:49:14 + | +LL | /// Link to [static@c] + | ^^^^^^^^ help: to link to the constant, prefix with `const@`: `const@c` + | + = note: this link resolved to a constant, which is not a static + +error: incompatible link kind for `c` + --> $DIR/disambiguator-mismatch.rs:54:14 + | +LL | /// Link to [fn@c] + | ^^^^ help: to link to the constant, prefix with `const@`: `const@c` + | + = note: this link resolved to a constant, which is not a function + +error: incompatible link kind for `c` + --> $DIR/disambiguator-mismatch.rs:59:14 + | +LL | /// Link to [c()] + | ^^^ help: to link to the constant, prefix with `const@`: `const@c` + | + = note: this link resolved to a constant, which is not a function + +error: incompatible link kind for `f` + --> $DIR/disambiguator-mismatch.rs:64:14 + | +LL | /// Link to [const@f] + | ^^^^^^^ help: to link to the function, add parentheses: `f()` + | + = note: this link resolved to a function, which is not a constant + +error: aborting due to 11 previous errors + diff --git a/src/test/rustdoc-ui/intra-doc/double-anchor.rs b/src/test/rustdoc-ui/intra-doc/double-anchor.rs new file mode 100644 index 00000000000..a01211c4f32 --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/double-anchor.rs @@ -0,0 +1,7 @@ +// check-pass + +// regression test for #73264 +// should only give one error +/// docs [label][with#anchor#error] +//~^ WARNING multiple anchors +pub struct S; diff --git a/src/test/rustdoc-ui/intra-doc/double-anchor.stderr b/src/test/rustdoc-ui/intra-doc/double-anchor.stderr new file mode 100644 index 00000000000..1cd9231eded --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/double-anchor.stderr @@ -0,0 +1,10 @@ +warning: `with#anchor#error` contains multiple anchors + --> $DIR/double-anchor.rs:5:18 + | +LL | /// docs [label][with#anchor#error] + | ^^^^^^^^^^^^^^^^^ contains invalid anchor + | + = note: `#[warn(broken_intra_doc_links)]` on by default + +warning: 1 warning emitted + diff --git a/src/test/rustdoc-ui/intra-doc/errors.rs b/src/test/rustdoc-ui/intra-doc/errors.rs new file mode 100644 index 00000000000..81e42643ae8 --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/errors.rs @@ -0,0 +1,105 @@ +#![deny(broken_intra_doc_links)] +//~^ NOTE lint level is defined + +// FIXME: this should say that it was skipped (maybe an allowed by default lint?) +/// [invalid intra-doc syntax!!] + +/// [path::to::nonexistent::module] +//~^ ERROR unresolved link +//~| NOTE no item named `path` in scope + +/// [path::to::nonexistent::macro!] +//~^ ERROR unresolved link +//~| NOTE no item named `path` in scope + +/// [type@path::to::nonexistent::type] +//~^ ERROR unresolved link +//~| NOTE no item named `path` in scope + +/// [std::io::not::here] +//~^ ERROR unresolved link +//~| NOTE no item named `not` in module `io` + +/// [type@std::io::not::here] +//~^ ERROR unresolved link +//~| NOTE no item named `not` in module `io` + +/// [std::io::Error::x] +//~^ ERROR unresolved link +//~| NOTE the struct `Error` has no field + +/// [std::io::ErrorKind::x] +//~^ ERROR unresolved link +//~| NOTE the enum `ErrorKind` has no variant + +/// [f::A] +//~^ ERROR unresolved link +//~| NOTE `f` is a function, not a module + +/// [f::A!] +//~^ ERROR unresolved link +//~| NOTE `f` is a function, not a module + +/// [S::A] +//~^ ERROR unresolved link +//~| NOTE struct `S` has no field or associated item + +/// [S::fmt] +//~^ ERROR unresolved link +//~| NOTE struct `S` has no field or associated item + +/// [E::D] +//~^ ERROR unresolved link +//~| NOTE enum `E` has no variant or associated item + +/// [u8::not_found] +//~^ ERROR unresolved link +//~| NOTE the builtin type `u8` has no associated item named `not_found` + +/// [std::primitive::u8::not_found] +//~^ ERROR unresolved link +//~| NOTE the builtin type `u8` has no associated item named `not_found` + +/// [type@Vec::into_iter] +//~^ ERROR unresolved link +//~| HELP to link to the associated function, add parentheses +//~| NOTE this link resolves to the associated function `into_iter` + +/// [S!] +//~^ ERROR unresolved link +//~| HELP to link to the struct, prefix with `struct@` +//~| NOTE this link resolves to the struct `S` +pub fn f() {} +#[derive(Debug)] +pub struct S; + +pub enum E { A, B, C } + +/// [type@S::h] +//~^ ERROR unresolved link +//~| HELP to link to the associated function +//~| NOTE not in the type namespace +impl S { + pub fn h() {} +} + +/// [type@T::g] +//~^ ERROR unresolved link +//~| HELP to link to the associated function +//~| NOTE not in the type namespace + +/// [T::h!] +//~^ ERROR unresolved link +//~| NOTE `T` has no macro named `h` +pub trait T { + fn g() {} +} + +/// [m()] +//~^ ERROR unresolved link +//~| HELP to link to the macro +//~| NOTE not in the value namespace +#[macro_export] +macro_rules! m { + () => {}; +} diff --git a/src/test/rustdoc-ui/intra-doc/errors.stderr b/src/test/rustdoc-ui/intra-doc/errors.stderr new file mode 100644 index 00000000000..21c806108e3 --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/errors.stderr @@ -0,0 +1,143 @@ +error: unresolved link to `path::to::nonexistent::module` + --> $DIR/errors.rs:7:6 + | +LL | /// [path::to::nonexistent::module] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `path` in scope + | +note: the lint level is defined here + --> $DIR/errors.rs:1:9 + | +LL | #![deny(broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: unresolved link to `path::to::nonexistent::macro` + --> $DIR/errors.rs:11:6 + | +LL | /// [path::to::nonexistent::macro!] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `path` in scope + +error: unresolved link to `path::to::nonexistent::type` + --> $DIR/errors.rs:15:6 + | +LL | /// [type@path::to::nonexistent::type] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `path` in scope + +error: unresolved link to `std::io::not::here` + --> $DIR/errors.rs:19:6 + | +LL | /// [std::io::not::here] + | ^^^^^^^^^^^^^^^^^^ no item named `not` in module `io` + +error: unresolved link to `std::io::not::here` + --> $DIR/errors.rs:23:6 + | +LL | /// [type@std::io::not::here] + | ^^^^^^^^^^^^^^^^^^^^^^^ no item named `not` in module `io` + +error: unresolved link to `std::io::Error::x` + --> $DIR/errors.rs:27:6 + | +LL | /// [std::io::Error::x] + | ^^^^^^^^^^^^^^^^^ the struct `Error` has no field or associated item named `x` + +error: unresolved link to `std::io::ErrorKind::x` + --> $DIR/errors.rs:31:6 + | +LL | /// [std::io::ErrorKind::x] + | ^^^^^^^^^^^^^^^^^^^^^ the enum `ErrorKind` has no variant or associated item named `x` + +error: unresolved link to `f::A` + --> $DIR/errors.rs:35:6 + | +LL | /// [f::A] + | ^^^^ `f` is a function, not a module or type, and cannot have associated items + +error: unresolved link to `f::A` + --> $DIR/errors.rs:39:6 + | +LL | /// [f::A!] + | ^^^^^ `f` is a function, not a module or type, and cannot have associated items + +error: unresolved link to `S::A` + --> $DIR/errors.rs:43:6 + | +LL | /// [S::A] + | ^^^^ the struct `S` has no field or associated item named `A` + +error: unresolved link to `S::fmt` + --> $DIR/errors.rs:47:6 + | +LL | /// [S::fmt] + | ^^^^^^ the struct `S` has no field or associated item named `fmt` + +error: unresolved link to `E::D` + --> $DIR/errors.rs:51:6 + | +LL | /// [E::D] + | ^^^^ the enum `E` has no variant or associated item named `D` + +error: unresolved link to `u8::not_found` + --> $DIR/errors.rs:55:6 + | +LL | /// [u8::not_found] + | ^^^^^^^^^^^^^ the builtin type `u8` has no associated item named `not_found` + +error: unresolved link to `std::primitive::u8::not_found` + --> $DIR/errors.rs:59:6 + | +LL | /// [std::primitive::u8::not_found] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the builtin type `u8` has no associated item named `not_found` + +error: unresolved link to `Vec::into_iter` + --> $DIR/errors.rs:63:6 + | +LL | /// [type@Vec::into_iter] + | ^^^^^^^^^^^^^^^^^^^ + | | + | this link resolves to the associated function `into_iter`, which is not in the type namespace + | help: to link to the associated function, add parentheses: `Vec::into_iter()` + +error: unresolved link to `S` + --> $DIR/errors.rs:68:6 + | +LL | /// [S!] + | ^^ + | | + | this link resolves to the struct `S`, which is not in the macro namespace + | help: to link to the struct, prefix with `struct@`: `struct@S` + +error: unresolved link to `S::h` + --> $DIR/errors.rs:78:6 + | +LL | /// [type@S::h] + | ^^^^^^^^^ + | | + | this link resolves to the associated function `h`, which is not in the type namespace + | help: to link to the associated function, add parentheses: `S::h()` + +error: unresolved link to `T::g` + --> $DIR/errors.rs:86:6 + | +LL | /// [type@T::g] + | ^^^^^^^^^ + | | + | this link resolves to the associated function `g`, which is not in the type namespace + | help: to link to the associated function, add parentheses: `T::g()` + +error: unresolved link to `T::h` + --> $DIR/errors.rs:91:6 + | +LL | /// [T::h!] + | ^^^^^ the trait `T` has no macro named `h` + +error: unresolved link to `m` + --> $DIR/errors.rs:98:6 + | +LL | /// [m()] + | ^^^ + | | + | this link resolves to the macro `m`, which is not in the value namespace + | help: to link to the macro, add an exclamation mark: `m!` + +error: aborting due to 20 previous errors + diff --git a/src/test/rustdoc-ui/intra-doc/malformed-generics.rs b/src/test/rustdoc-ui/intra-doc/malformed-generics.rs new file mode 100644 index 00000000000..9c54092146f --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/malformed-generics.rs @@ -0,0 +1,19 @@ +#![deny(broken_intra_doc_links)] + +//! [Vec<] //~ ERROR +//! [Vec] //~ ERROR +//! [Vec>>] //~ ERROR +//! [Vec>>] //~ ERROR +//! [] //~ ERROR +//! [] //~ ERROR +//! [Vec::new()] //~ ERROR +//! [Vec<>] //~ ERROR +//! [Vec<>] //~ ERROR +//! [Vec<<>>] //~ ERROR + +// FIXME(#74563) support UFCS +//! [::into_iter] //~ ERROR +//! [ as IntoIterator>::iter] //~ ERROR diff --git a/src/test/rustdoc-ui/intra-doc/malformed-generics.stderr b/src/test/rustdoc-ui/intra-doc/malformed-generics.stderr new file mode 100644 index 00000000000..2e1b22807bc --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/malformed-generics.stderr @@ -0,0 +1,102 @@ +error: unresolved link to `Vec<` + --> $DIR/malformed-generics.rs:3:6 + | +LL | //! [Vec<] + | ^^^^ unbalanced angle brackets + | +note: the lint level is defined here + --> $DIR/malformed-generics.rs:1:9 + | +LL | #![deny(broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: unresolved link to `Vec $DIR/malformed-generics.rs:4:6 + | +LL | //! [Vec` + --> $DIR/malformed-generics.rs:5:6 + | +LL | //! [Vec] + | ^^^^^^^^^^ unbalanced angle brackets + +error: unresolved link to `Vec>>` + --> $DIR/malformed-generics.rs:6:6 + | +LL | //! [Vec>>] + | ^^^^^^^^^^^^ unbalanced angle brackets + +error: unresolved link to `Vec>>` + --> $DIR/malformed-generics.rs:7:6 + | +LL | //! [Vec>>] + | ^^^^^^^^ unbalanced angle brackets + +error: unresolved link to ` $DIR/malformed-generics.rs:8:6 + | +LL | //! [ $DIR/malformed-generics.rs:9:6 + | +LL | //! [Vec::<] + | ^^^^^^ unbalanced angle brackets + +error: unresolved link to `` + --> $DIR/malformed-generics.rs:10:6 + | +LL | //! [] + | ^^^ missing type for generic parameters + +error: unresolved link to `` + --> $DIR/malformed-generics.rs:11:6 + | +LL | //! [] + | ^^^^^^^^^^^^^^^^ missing type for generic parameters + +error: unresolved link to `Vec::new` + --> $DIR/malformed-generics.rs:12:6 + | +LL | //! [Vec::new()] + | ^^^^^^^^^^^^^ has invalid path separator + +error: unresolved link to `Vec<>` + --> $DIR/malformed-generics.rs:13:6 + | +LL | //! [Vec<>] + | ^^^^^^^^ too many angle brackets + +error: unresolved link to `Vec<>` + --> $DIR/malformed-generics.rs:14:6 + | +LL | //! [Vec<>] + | ^^^^^ empty angle brackets + +error: unresolved link to `Vec<<>>` + --> $DIR/malformed-generics.rs:15:6 + | +LL | //! [Vec<<>>] + | ^^^^^^^ too many angle brackets + +error: unresolved link to `::into_iter` + --> $DIR/malformed-generics.rs:18:6 + | +LL | //! [::into_iter] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fully-qualified syntax is unsupported + | + = note: see https://github.com/rust-lang/rust/issues/74563 for more information + +error: unresolved link to ` as IntoIterator>::iter` + --> $DIR/malformed-generics.rs:19:6 + | +LL | //! [ as IntoIterator>::iter] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fully-qualified syntax is unsupported + | + = note: see https://github.com/rust-lang/rust/issues/74563 for more information + +error: aborting due to 15 previous errors + diff --git a/src/test/rustdoc-ui/intra-doc/prim-conflict.rs b/src/test/rustdoc-ui/intra-doc/prim-conflict.rs new file mode 100644 index 00000000000..85738ceae8e --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/prim-conflict.rs @@ -0,0 +1,30 @@ +#![deny(broken_intra_doc_links)] +//~^ NOTE lint level is defined + +/// [char] +//~^ ERROR both a module and a builtin type +//~| NOTE ambiguous link +//~| HELP to link to the module +//~| HELP to link to the builtin type + +/// [type@char] +//~^ ERROR both a module and a builtin type +//~| NOTE ambiguous link +//~| HELP to link to the module +//~| HELP to link to the builtin type + +/// [mod@char] // ok +/// [prim@char] // ok + +/// [struct@char] +//~^ ERROR incompatible link +//~| HELP prefix with `mod@` +//~| NOTE resolved to a module +pub mod char {} + +pub mod inner { + //! [struct@char] + //~^ ERROR incompatible link + //~| HELP prefix with `prim@` + //~| NOTE resolved to a builtin type +} diff --git a/src/test/rustdoc-ui/intra-doc/prim-conflict.stderr b/src/test/rustdoc-ui/intra-doc/prim-conflict.stderr new file mode 100644 index 00000000000..01275f8d9af --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/prim-conflict.stderr @@ -0,0 +1,53 @@ +error: `char` is both a module and a builtin type + --> $DIR/prim-conflict.rs:4:6 + | +LL | /// [char] + | ^^^^ ambiguous link + | +note: the lint level is defined here + --> $DIR/prim-conflict.rs:1:9 + | +LL | #![deny(broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^ +help: to link to the module, prefix with `mod@` + | +LL | /// [mod@char] + | ^^^^^^^^ +help: to link to the builtin type, prefix with `prim@` + | +LL | /// [prim@char] + | ^^^^^^^^^ + +error: `char` is both a module and a builtin type + --> $DIR/prim-conflict.rs:10:6 + | +LL | /// [type@char] + | ^^^^^^^^^ ambiguous link + | +help: to link to the module, prefix with `mod@` + | +LL | /// [mod@char] + | ^^^^^^^^ +help: to link to the builtin type, prefix with `prim@` + | +LL | /// [prim@char] + | ^^^^^^^^^ + +error: incompatible link kind for `char` + --> $DIR/prim-conflict.rs:19:6 + | +LL | /// [struct@char] + | ^^^^^^^^^^^ help: to link to the module, prefix with `mod@`: `mod@char` + | + = note: this link resolved to a module, which is not a struct + +error: incompatible link kind for `char` + --> $DIR/prim-conflict.rs:26:10 + | +LL | //! [struct@char] + | ^^^^^^^^^^^ help: to link to the builtin type, prefix with `prim@`: `prim@char` + | + = note: this link resolved to a builtin type, which is not a struct + +error: aborting due to 4 previous errors + diff --git a/src/test/rustdoc-ui/intra-doc/private.private.stderr b/src/test/rustdoc-ui/intra-doc/private.private.stderr new file mode 100644 index 00000000000..6e11ec3e87b --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/private.private.stderr @@ -0,0 +1,11 @@ +warning: public documentation for `DocMe` links to private item `DontDocMe` + --> $DIR/private.rs:5:11 + | +LL | /// docs [DontDocMe] + | ^^^^^^^^^ this item is private + | + = note: `#[warn(private_intra_doc_links)]` on by default + = note: this link resolves only because you passed `--document-private-items`, but will break without + +warning: 1 warning emitted + diff --git a/src/test/rustdoc-ui/intra-doc/private.public.stderr b/src/test/rustdoc-ui/intra-doc/private.public.stderr new file mode 100644 index 00000000000..3a6a4b66452 --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/private.public.stderr @@ -0,0 +1,11 @@ +warning: public documentation for `DocMe` links to private item `DontDocMe` + --> $DIR/private.rs:5:11 + | +LL | /// docs [DontDocMe] + | ^^^^^^^^^ this item is private + | + = note: `#[warn(private_intra_doc_links)]` on by default + = note: this link will resolve properly if you pass `--document-private-items` + +warning: 1 warning emitted + diff --git a/src/test/rustdoc-ui/intra-doc/private.rs b/src/test/rustdoc-ui/intra-doc/private.rs new file mode 100644 index 00000000000..613236d75d2 --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/private.rs @@ -0,0 +1,9 @@ +// check-pass +// revisions: public private +// [private]compile-flags: --document-private-items + +/// docs [DontDocMe] +//~^ WARNING public documentation for `DocMe` links to private item `DontDocMe` +// FIXME: for [private] we should also make sure the link was actually generated +pub struct DocMe; +struct DontDocMe; diff --git a/src/test/rustdoc-ui/intra-doc/span-ice-55723.rs b/src/test/rustdoc-ui/intra-doc/span-ice-55723.rs new file mode 100644 index 00000000000..7764a6df6ee --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/span-ice-55723.rs @@ -0,0 +1,13 @@ +#![deny(broken_intra_doc_links)] + +// An error in calculating spans while reporting intra-doc link resolution errors caused rustdoc to +// attempt to slice in the middle of a multibyte character. See +// https://github.com/rust-lang/rust/issues/55723 + +/// ## For example: +/// +/// (arr[i]) +//~^ ERROR `i` +pub fn test_ice() { + unimplemented!(); +} diff --git a/src/test/rustdoc-ui/intra-doc/span-ice-55723.stderr b/src/test/rustdoc-ui/intra-doc/span-ice-55723.stderr new file mode 100644 index 00000000000..10ca14e850f --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/span-ice-55723.stderr @@ -0,0 +1,15 @@ +error: unresolved link to `i` + --> $DIR/span-ice-55723.rs:9:10 + | +LL | /// (arr[i]) + | ^ no item named `i` in scope + | +note: the lint level is defined here + --> $DIR/span-ice-55723.rs:1:9 + | +LL | #![deny(broken_intra_doc_links)] + | ^^^^^^^^^^^^^^^^^^^^^^ + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +error: aborting due to previous error + diff --git a/src/test/rustdoc-ui/intra-doc/warning-crlf.rs b/src/test/rustdoc-ui/intra-doc/warning-crlf.rs new file mode 100644 index 00000000000..a19c33b53be --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/warning-crlf.rs @@ -0,0 +1,26 @@ +// ignore-tidy-cr +// check-pass + +// This file checks the spans of intra-link warnings in a file with CRLF line endings. The +// .gitattributes file in this directory should enforce it. + +/// [error] +pub struct A; +//~^^ WARNING `error` + +/// +/// docs [error1] +//~^ WARNING `error1` + +/// docs [error2] +/// +pub struct B; +//~^^^ WARNING `error2` + +/** + * This is a multi-line comment. + * + * It also has an [error]. + */ +pub struct C; +//~^^^ WARNING `error` diff --git a/src/test/rustdoc-ui/intra-doc/warning-crlf.stderr b/src/test/rustdoc-ui/intra-doc/warning-crlf.stderr new file mode 100644 index 00000000000..01e42820037 --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/warning-crlf.stderr @@ -0,0 +1,35 @@ +warning: unresolved link to `error` + --> $DIR/warning-crlf.rs:7:6 + | +LL | /// [error] + | ^^^^^ no item named `error` in scope + | + = note: `#[warn(broken_intra_doc_links)]` on by default + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `error1` + --> $DIR/warning-crlf.rs:12:11 + | +LL | /// docs [error1] + | ^^^^^^ no item named `error1` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `error2` + --> $DIR/warning-crlf.rs:15:11 + | +LL | /// docs [error2] + | ^^^^^^ no item named `error2` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `error` + --> $DIR/warning-crlf.rs:23:20 + | +LL | * It also has an [error]. + | ^^^^^ no item named `error` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: 4 warnings emitted + diff --git a/src/test/rustdoc-ui/intra-doc/warning.rs b/src/test/rustdoc-ui/intra-doc/warning.rs new file mode 100644 index 00000000000..eab1f034804 --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/warning.rs @@ -0,0 +1,84 @@ +// check-pass + + //! Test with [Foo::baz], [Bar::foo], ... +//~^ WARNING `Foo::baz` +//~| WARNING `Bar::foo` + //! , [Uniooon::X] and [Qux::Z]. +//~^ WARNING `Uniooon::X` +//~| WARNING `Qux::Z` + //! + //! , [Uniooon::X] and [Qux::Z]. +//~^ WARNING `Uniooon::X` +//~| WARNING `Qux::Z` + + /// [Qux:Y] +//~^ WARNING `Qux:Y` +pub struct Foo { + pub bar: usize, +} + +/// Foo +/// bar [BarA] bar //~ WARNING `BarA` +/// baz +pub fn a() {} + +/** + * Foo + * bar [BarB] bar //~ WARNING `BarB` + * baz + */ +pub fn b() {} + +/** Foo + +bar [BarC] bar //~ WARNING `BarC` +baz + + let bar_c_1 = 0; + let bar_c_2 = 0; + let g = [bar_c_1]; + let h = g[bar_c_2]; + +*/ +pub fn c() {} + +#[doc = "Foo\nbar [BarD] bar\nbaz"] //~ WARNING `BarD` +pub fn d() {} + +macro_rules! f { + ($f:expr) => { + #[doc = $f] //~ WARNING `BarF` + pub fn f() {} + } +} +f!("Foo\nbar [BarF] bar\nbaz"); + +/** # for example, + * + * time to introduce a link [error]*/ //~ WARNING `error` +pub struct A; + +/** + * # for example, + * + * time to introduce a link [error] //~ WARNING `error` + */ +pub struct B; + +#[doc = "single line [error]"] //~ WARNING `error` +pub struct C; + +#[doc = "single line with \"escaping\" [error]"] //~ WARNING `error` +pub struct D; + +/// Item docs. //~ WARNING `error` +#[doc="Hello there!"] +/// [error] +pub struct E; + +/// +/// docs [error1] //~ WARNING `error1` + +/// docs [error2] //~ WARNING `error2` +/// +pub struct F; diff --git a/src/test/rustdoc-ui/intra-doc/warning.stderr b/src/test/rustdoc-ui/intra-doc/warning.stderr new file mode 100644 index 00000000000..430d18165a0 --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/warning.stderr @@ -0,0 +1,175 @@ +warning: unresolved link to `Foo::baz` + --> $DIR/warning.rs:3:23 + | +LL | //! Test with [Foo::baz], [Bar::foo], ... + | ^^^^^^^^ the struct `Foo` has no field or associated item named `baz` + | + = note: `#[warn(broken_intra_doc_links)]` on by default + +warning: unresolved link to `Bar::foo` + --> $DIR/warning.rs:3:35 + | +LL | //! Test with [Foo::baz], [Bar::foo], ... + | ^^^^^^^^ no item named `Bar` in scope + +warning: unresolved link to `Uniooon::X` + --> $DIR/warning.rs:6:13 + | +LL | //! , [Uniooon::X] and [Qux::Z]. + | ^^^^^^^^^^ no item named `Uniooon` in scope + +warning: unresolved link to `Qux::Z` + --> $DIR/warning.rs:6:30 + | +LL | //! , [Uniooon::X] and [Qux::Z]. + | ^^^^^^ no item named `Qux` in scope + +warning: unresolved link to `Uniooon::X` + --> $DIR/warning.rs:10:14 + | +LL | //! , [Uniooon::X] and [Qux::Z]. + | ^^^^^^^^^^ no item named `Uniooon` in scope + +warning: unresolved link to `Qux::Z` + --> $DIR/warning.rs:10:31 + | +LL | //! , [Uniooon::X] and [Qux::Z]. + | ^^^^^^ no item named `Qux` in scope + +warning: unresolved link to `Qux:Y` + --> $DIR/warning.rs:14:13 + | +LL | /// [Qux:Y] + | ^^^^^ no item named `Qux:Y` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `BarA` + --> $DIR/warning.rs:21:10 + | +LL | /// bar [BarA] bar + | ^^^^ no item named `BarA` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `BarB` + --> $DIR/warning.rs:27:9 + | +LL | * bar [BarB] bar + | ^^^^ no item named `BarB` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `BarC` + --> $DIR/warning.rs:34:6 + | +LL | bar [BarC] bar + | ^^^^ no item named `BarC` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `BarD` + --> $DIR/warning.rs:45:1 + | +LL | #[doc = "Foo\nbar [BarD] bar\nbaz"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the link appears in this line: + + bar [BarD] bar + ^^^^ + = note: no item named `BarD` in scope + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `BarF` + --> $DIR/warning.rs:50:9 + | +LL | #[doc = $f] + | ^^^^^^^^^^^ +... +LL | f!("Foo\nbar [BarF] bar\nbaz"); + | ------------------------------- in this macro invocation + | + = note: the link appears in this line: + + bar [BarF] bar + ^^^^ + = note: no item named `BarF` in scope + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +warning: unresolved link to `error` + --> $DIR/warning.rs:58:30 + | +LL | * time to introduce a link [error]*/ + | ^^^^^ no item named `error` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `error` + --> $DIR/warning.rs:64:30 + | +LL | * time to introduce a link [error] + | ^^^^^ no item named `error` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `error` + --> $DIR/warning.rs:68:1 + | +LL | #[doc = "single line [error]"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the link appears in this line: + + single line [error] + ^^^^^ + = note: no item named `error` in scope + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `error` + --> $DIR/warning.rs:71:1 + | +LL | #[doc = "single line with \"escaping\" [error]"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the link appears in this line: + + single line with "escaping" [error] + ^^^^^ + = note: no item named `error` in scope + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `error` + --> $DIR/warning.rs:74:1 + | +LL | / /// Item docs. +LL | | #[doc="Hello there!"] +LL | | /// [error] + | |___________^ + | + = note: the link appears in this line: + + [error] + ^^^^^ + = note: no item named `error` in scope + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `error1` + --> $DIR/warning.rs:80:11 + | +LL | /// docs [error1] + | ^^^^^^ no item named `error1` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: unresolved link to `error2` + --> $DIR/warning.rs:82:11 + | +LL | /// docs [error2] + | ^^^^^^ no item named `error2` in scope + | + = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` + +warning: 19 warnings emitted + diff --git a/src/test/rustdoc-ui/intra-link-double-anchor.rs b/src/test/rustdoc-ui/intra-link-double-anchor.rs deleted file mode 100644 index a01211c4f32..00000000000 --- a/src/test/rustdoc-ui/intra-link-double-anchor.rs +++ /dev/null @@ -1,7 +0,0 @@ -// check-pass - -// regression test for #73264 -// should only give one error -/// docs [label][with#anchor#error] -//~^ WARNING multiple anchors -pub struct S; diff --git a/src/test/rustdoc-ui/intra-link-double-anchor.stderr b/src/test/rustdoc-ui/intra-link-double-anchor.stderr deleted file mode 100644 index 3282ec8b793..00000000000 --- a/src/test/rustdoc-ui/intra-link-double-anchor.stderr +++ /dev/null @@ -1,10 +0,0 @@ -warning: `with#anchor#error` contains multiple anchors - --> $DIR/intra-link-double-anchor.rs:5:18 - | -LL | /// docs [label][with#anchor#error] - | ^^^^^^^^^^^^^^^^^ contains invalid anchor - | - = note: `#[warn(broken_intra_doc_links)]` on by default - -warning: 1 warning emitted - diff --git a/src/test/rustdoc-ui/intra-link-errors.rs b/src/test/rustdoc-ui/intra-link-errors.rs deleted file mode 100644 index 81e42643ae8..00000000000 --- a/src/test/rustdoc-ui/intra-link-errors.rs +++ /dev/null @@ -1,105 +0,0 @@ -#![deny(broken_intra_doc_links)] -//~^ NOTE lint level is defined - -// FIXME: this should say that it was skipped (maybe an allowed by default lint?) -/// [invalid intra-doc syntax!!] - -/// [path::to::nonexistent::module] -//~^ ERROR unresolved link -//~| NOTE no item named `path` in scope - -/// [path::to::nonexistent::macro!] -//~^ ERROR unresolved link -//~| NOTE no item named `path` in scope - -/// [type@path::to::nonexistent::type] -//~^ ERROR unresolved link -//~| NOTE no item named `path` in scope - -/// [std::io::not::here] -//~^ ERROR unresolved link -//~| NOTE no item named `not` in module `io` - -/// [type@std::io::not::here] -//~^ ERROR unresolved link -//~| NOTE no item named `not` in module `io` - -/// [std::io::Error::x] -//~^ ERROR unresolved link -//~| NOTE the struct `Error` has no field - -/// [std::io::ErrorKind::x] -//~^ ERROR unresolved link -//~| NOTE the enum `ErrorKind` has no variant - -/// [f::A] -//~^ ERROR unresolved link -//~| NOTE `f` is a function, not a module - -/// [f::A!] -//~^ ERROR unresolved link -//~| NOTE `f` is a function, not a module - -/// [S::A] -//~^ ERROR unresolved link -//~| NOTE struct `S` has no field or associated item - -/// [S::fmt] -//~^ ERROR unresolved link -//~| NOTE struct `S` has no field or associated item - -/// [E::D] -//~^ ERROR unresolved link -//~| NOTE enum `E` has no variant or associated item - -/// [u8::not_found] -//~^ ERROR unresolved link -//~| NOTE the builtin type `u8` has no associated item named `not_found` - -/// [std::primitive::u8::not_found] -//~^ ERROR unresolved link -//~| NOTE the builtin type `u8` has no associated item named `not_found` - -/// [type@Vec::into_iter] -//~^ ERROR unresolved link -//~| HELP to link to the associated function, add parentheses -//~| NOTE this link resolves to the associated function `into_iter` - -/// [S!] -//~^ ERROR unresolved link -//~| HELP to link to the struct, prefix with `struct@` -//~| NOTE this link resolves to the struct `S` -pub fn f() {} -#[derive(Debug)] -pub struct S; - -pub enum E { A, B, C } - -/// [type@S::h] -//~^ ERROR unresolved link -//~| HELP to link to the associated function -//~| NOTE not in the type namespace -impl S { - pub fn h() {} -} - -/// [type@T::g] -//~^ ERROR unresolved link -//~| HELP to link to the associated function -//~| NOTE not in the type namespace - -/// [T::h!] -//~^ ERROR unresolved link -//~| NOTE `T` has no macro named `h` -pub trait T { - fn g() {} -} - -/// [m()] -//~^ ERROR unresolved link -//~| HELP to link to the macro -//~| NOTE not in the value namespace -#[macro_export] -macro_rules! m { - () => {}; -} diff --git a/src/test/rustdoc-ui/intra-link-errors.stderr b/src/test/rustdoc-ui/intra-link-errors.stderr deleted file mode 100644 index be98cac94ec..00000000000 --- a/src/test/rustdoc-ui/intra-link-errors.stderr +++ /dev/null @@ -1,143 +0,0 @@ -error: unresolved link to `path::to::nonexistent::module` - --> $DIR/intra-link-errors.rs:7:6 - | -LL | /// [path::to::nonexistent::module] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `path` in scope - | -note: the lint level is defined here - --> $DIR/intra-link-errors.rs:1:9 - | -LL | #![deny(broken_intra_doc_links)] - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: unresolved link to `path::to::nonexistent::macro` - --> $DIR/intra-link-errors.rs:11:6 - | -LL | /// [path::to::nonexistent::macro!] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `path` in scope - -error: unresolved link to `path::to::nonexistent::type` - --> $DIR/intra-link-errors.rs:15:6 - | -LL | /// [type@path::to::nonexistent::type] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `path` in scope - -error: unresolved link to `std::io::not::here` - --> $DIR/intra-link-errors.rs:19:6 - | -LL | /// [std::io::not::here] - | ^^^^^^^^^^^^^^^^^^ no item named `not` in module `io` - -error: unresolved link to `std::io::not::here` - --> $DIR/intra-link-errors.rs:23:6 - | -LL | /// [type@std::io::not::here] - | ^^^^^^^^^^^^^^^^^^^^^^^ no item named `not` in module `io` - -error: unresolved link to `std::io::Error::x` - --> $DIR/intra-link-errors.rs:27:6 - | -LL | /// [std::io::Error::x] - | ^^^^^^^^^^^^^^^^^ the struct `Error` has no field or associated item named `x` - -error: unresolved link to `std::io::ErrorKind::x` - --> $DIR/intra-link-errors.rs:31:6 - | -LL | /// [std::io::ErrorKind::x] - | ^^^^^^^^^^^^^^^^^^^^^ the enum `ErrorKind` has no variant or associated item named `x` - -error: unresolved link to `f::A` - --> $DIR/intra-link-errors.rs:35:6 - | -LL | /// [f::A] - | ^^^^ `f` is a function, not a module or type, and cannot have associated items - -error: unresolved link to `f::A` - --> $DIR/intra-link-errors.rs:39:6 - | -LL | /// [f::A!] - | ^^^^^ `f` is a function, not a module or type, and cannot have associated items - -error: unresolved link to `S::A` - --> $DIR/intra-link-errors.rs:43:6 - | -LL | /// [S::A] - | ^^^^ the struct `S` has no field or associated item named `A` - -error: unresolved link to `S::fmt` - --> $DIR/intra-link-errors.rs:47:6 - | -LL | /// [S::fmt] - | ^^^^^^ the struct `S` has no field or associated item named `fmt` - -error: unresolved link to `E::D` - --> $DIR/intra-link-errors.rs:51:6 - | -LL | /// [E::D] - | ^^^^ the enum `E` has no variant or associated item named `D` - -error: unresolved link to `u8::not_found` - --> $DIR/intra-link-errors.rs:55:6 - | -LL | /// [u8::not_found] - | ^^^^^^^^^^^^^ the builtin type `u8` has no associated item named `not_found` - -error: unresolved link to `std::primitive::u8::not_found` - --> $DIR/intra-link-errors.rs:59:6 - | -LL | /// [std::primitive::u8::not_found] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the builtin type `u8` has no associated item named `not_found` - -error: unresolved link to `Vec::into_iter` - --> $DIR/intra-link-errors.rs:63:6 - | -LL | /// [type@Vec::into_iter] - | ^^^^^^^^^^^^^^^^^^^ - | | - | this link resolves to the associated function `into_iter`, which is not in the type namespace - | help: to link to the associated function, add parentheses: `Vec::into_iter()` - -error: unresolved link to `S` - --> $DIR/intra-link-errors.rs:68:6 - | -LL | /// [S!] - | ^^ - | | - | this link resolves to the struct `S`, which is not in the macro namespace - | help: to link to the struct, prefix with `struct@`: `struct@S` - -error: unresolved link to `S::h` - --> $DIR/intra-link-errors.rs:78:6 - | -LL | /// [type@S::h] - | ^^^^^^^^^ - | | - | this link resolves to the associated function `h`, which is not in the type namespace - | help: to link to the associated function, add parentheses: `S::h()` - -error: unresolved link to `T::g` - --> $DIR/intra-link-errors.rs:86:6 - | -LL | /// [type@T::g] - | ^^^^^^^^^ - | | - | this link resolves to the associated function `g`, which is not in the type namespace - | help: to link to the associated function, add parentheses: `T::g()` - -error: unresolved link to `T::h` - --> $DIR/intra-link-errors.rs:91:6 - | -LL | /// [T::h!] - | ^^^^^ the trait `T` has no macro named `h` - -error: unresolved link to `m` - --> $DIR/intra-link-errors.rs:98:6 - | -LL | /// [m()] - | ^^^ - | | - | this link resolves to the macro `m`, which is not in the value namespace - | help: to link to the macro, add an exclamation mark: `m!` - -error: aborting due to 20 previous errors - diff --git a/src/test/rustdoc-ui/intra-link-malformed-generics.rs b/src/test/rustdoc-ui/intra-link-malformed-generics.rs deleted file mode 100644 index 9c54092146f..00000000000 --- a/src/test/rustdoc-ui/intra-link-malformed-generics.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![deny(broken_intra_doc_links)] - -//! [Vec<] //~ ERROR -//! [Vec] //~ ERROR -//! [Vec>>] //~ ERROR -//! [Vec>>] //~ ERROR -//! [] //~ ERROR -//! [] //~ ERROR -//! [Vec::new()] //~ ERROR -//! [Vec<>] //~ ERROR -//! [Vec<>] //~ ERROR -//! [Vec<<>>] //~ ERROR - -// FIXME(#74563) support UFCS -//! [::into_iter] //~ ERROR -//! [ as IntoIterator>::iter] //~ ERROR diff --git a/src/test/rustdoc-ui/intra-link-malformed-generics.stderr b/src/test/rustdoc-ui/intra-link-malformed-generics.stderr deleted file mode 100644 index fe5d4cd1bbf..00000000000 --- a/src/test/rustdoc-ui/intra-link-malformed-generics.stderr +++ /dev/null @@ -1,102 +0,0 @@ -error: unresolved link to `Vec<` - --> $DIR/intra-link-malformed-generics.rs:3:6 - | -LL | //! [Vec<] - | ^^^^ unbalanced angle brackets - | -note: the lint level is defined here - --> $DIR/intra-link-malformed-generics.rs:1:9 - | -LL | #![deny(broken_intra_doc_links)] - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: unresolved link to `Vec $DIR/intra-link-malformed-generics.rs:4:6 - | -LL | //! [Vec` - --> $DIR/intra-link-malformed-generics.rs:5:6 - | -LL | //! [Vec] - | ^^^^^^^^^^ unbalanced angle brackets - -error: unresolved link to `Vec>>` - --> $DIR/intra-link-malformed-generics.rs:6:6 - | -LL | //! [Vec>>] - | ^^^^^^^^^^^^ unbalanced angle brackets - -error: unresolved link to `Vec>>` - --> $DIR/intra-link-malformed-generics.rs:7:6 - | -LL | //! [Vec>>] - | ^^^^^^^^ unbalanced angle brackets - -error: unresolved link to ` $DIR/intra-link-malformed-generics.rs:8:6 - | -LL | //! [ $DIR/intra-link-malformed-generics.rs:9:6 - | -LL | //! [Vec::<] - | ^^^^^^ unbalanced angle brackets - -error: unresolved link to `` - --> $DIR/intra-link-malformed-generics.rs:10:6 - | -LL | //! [] - | ^^^ missing type for generic parameters - -error: unresolved link to `` - --> $DIR/intra-link-malformed-generics.rs:11:6 - | -LL | //! [] - | ^^^^^^^^^^^^^^^^ missing type for generic parameters - -error: unresolved link to `Vec::new` - --> $DIR/intra-link-malformed-generics.rs:12:6 - | -LL | //! [Vec::new()] - | ^^^^^^^^^^^^^ has invalid path separator - -error: unresolved link to `Vec<>` - --> $DIR/intra-link-malformed-generics.rs:13:6 - | -LL | //! [Vec<>] - | ^^^^^^^^ too many angle brackets - -error: unresolved link to `Vec<>` - --> $DIR/intra-link-malformed-generics.rs:14:6 - | -LL | //! [Vec<>] - | ^^^^^ empty angle brackets - -error: unresolved link to `Vec<<>>` - --> $DIR/intra-link-malformed-generics.rs:15:6 - | -LL | //! [Vec<<>>] - | ^^^^^^^ too many angle brackets - -error: unresolved link to `::into_iter` - --> $DIR/intra-link-malformed-generics.rs:18:6 - | -LL | //! [::into_iter] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fully-qualified syntax is unsupported - | - = note: see https://github.com/rust-lang/rust/issues/74563 for more information - -error: unresolved link to ` as IntoIterator>::iter` - --> $DIR/intra-link-malformed-generics.rs:19:6 - | -LL | //! [ as IntoIterator>::iter] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fully-qualified syntax is unsupported - | - = note: see https://github.com/rust-lang/rust/issues/74563 for more information - -error: aborting due to 15 previous errors - diff --git a/src/test/rustdoc-ui/intra-link-prim-conflict.rs b/src/test/rustdoc-ui/intra-link-prim-conflict.rs deleted file mode 100644 index 85738ceae8e..00000000000 --- a/src/test/rustdoc-ui/intra-link-prim-conflict.rs +++ /dev/null @@ -1,30 +0,0 @@ -#![deny(broken_intra_doc_links)] -//~^ NOTE lint level is defined - -/// [char] -//~^ ERROR both a module and a builtin type -//~| NOTE ambiguous link -//~| HELP to link to the module -//~| HELP to link to the builtin type - -/// [type@char] -//~^ ERROR both a module and a builtin type -//~| NOTE ambiguous link -//~| HELP to link to the module -//~| HELP to link to the builtin type - -/// [mod@char] // ok -/// [prim@char] // ok - -/// [struct@char] -//~^ ERROR incompatible link -//~| HELP prefix with `mod@` -//~| NOTE resolved to a module -pub mod char {} - -pub mod inner { - //! [struct@char] - //~^ ERROR incompatible link - //~| HELP prefix with `prim@` - //~| NOTE resolved to a builtin type -} diff --git a/src/test/rustdoc-ui/intra-link-prim-conflict.stderr b/src/test/rustdoc-ui/intra-link-prim-conflict.stderr deleted file mode 100644 index 43587a80021..00000000000 --- a/src/test/rustdoc-ui/intra-link-prim-conflict.stderr +++ /dev/null @@ -1,53 +0,0 @@ -error: `char` is both a module and a builtin type - --> $DIR/intra-link-prim-conflict.rs:4:6 - | -LL | /// [char] - | ^^^^ ambiguous link - | -note: the lint level is defined here - --> $DIR/intra-link-prim-conflict.rs:1:9 - | -LL | #![deny(broken_intra_doc_links)] - | ^^^^^^^^^^^^^^^^^^^^^^ -help: to link to the module, prefix with `mod@` - | -LL | /// [mod@char] - | ^^^^^^^^ -help: to link to the builtin type, prefix with `prim@` - | -LL | /// [prim@char] - | ^^^^^^^^^ - -error: `char` is both a module and a builtin type - --> $DIR/intra-link-prim-conflict.rs:10:6 - | -LL | /// [type@char] - | ^^^^^^^^^ ambiguous link - | -help: to link to the module, prefix with `mod@` - | -LL | /// [mod@char] - | ^^^^^^^^ -help: to link to the builtin type, prefix with `prim@` - | -LL | /// [prim@char] - | ^^^^^^^^^ - -error: incompatible link kind for `char` - --> $DIR/intra-link-prim-conflict.rs:19:6 - | -LL | /// [struct@char] - | ^^^^^^^^^^^ help: to link to the module, prefix with `mod@`: `mod@char` - | - = note: this link resolved to a module, which is not a struct - -error: incompatible link kind for `char` - --> $DIR/intra-link-prim-conflict.rs:26:10 - | -LL | //! [struct@char] - | ^^^^^^^^^^^ help: to link to the builtin type, prefix with `prim@`: `prim@char` - | - = note: this link resolved to a builtin type, which is not a struct - -error: aborting due to 4 previous errors - diff --git a/src/test/rustdoc-ui/intra-link-span-ice-55723.rs b/src/test/rustdoc-ui/intra-link-span-ice-55723.rs deleted file mode 100644 index 7764a6df6ee..00000000000 --- a/src/test/rustdoc-ui/intra-link-span-ice-55723.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![deny(broken_intra_doc_links)] - -// An error in calculating spans while reporting intra-doc link resolution errors caused rustdoc to -// attempt to slice in the middle of a multibyte character. See -// https://github.com/rust-lang/rust/issues/55723 - -/// ## For example: -/// -/// (arr[i]) -//~^ ERROR `i` -pub fn test_ice() { - unimplemented!(); -} diff --git a/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr b/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr deleted file mode 100644 index d8afa9e7efd..00000000000 --- a/src/test/rustdoc-ui/intra-link-span-ice-55723.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: unresolved link to `i` - --> $DIR/intra-link-span-ice-55723.rs:9:10 - | -LL | /// (arr[i]) - | ^ no item named `i` in scope - | -note: the lint level is defined here - --> $DIR/intra-link-span-ice-55723.rs:1:9 - | -LL | #![deny(broken_intra_doc_links)] - | ^^^^^^^^^^^^^^^^^^^^^^ - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - -error: aborting due to previous error - diff --git a/src/test/rustdoc-ui/intra-links-ambiguity.rs b/src/test/rustdoc-ui/intra-links-ambiguity.rs deleted file mode 100644 index f63435337cf..00000000000 --- a/src/test/rustdoc-ui/intra-links-ambiguity.rs +++ /dev/null @@ -1,40 +0,0 @@ -#![deny(broken_intra_doc_links)] -#![allow(non_camel_case_types)] -#![allow(non_upper_case_globals)] - -pub fn ambiguous() {} - -pub struct ambiguous {} - -#[macro_export] -macro_rules! multi_conflict { () => {} } - -#[allow(non_camel_case_types)] -pub struct multi_conflict {} - -pub fn multi_conflict() {} - -pub mod type_and_value {} - -pub const type_and_value: i32 = 0; - -pub mod foo { - pub enum bar {} - - pub fn bar() {} -} - -/// [`ambiguous`] is ambiguous. //~ERROR `ambiguous` -/// -/// [ambiguous] is ambiguous. //~ERROR ambiguous -/// -/// [`multi_conflict`] is a three-way conflict. //~ERROR `multi_conflict` -/// -/// Ambiguous [type_and_value]. //~ERROR type_and_value -/// -/// Ambiguous non-implied shortcut link [`foo::bar`]. //~ERROR `foo::bar` -pub struct Docs {} - -/// [true] //~ ERROR `true` is both a module and a builtin type -/// [primitive@true] -pub mod r#true {} diff --git a/src/test/rustdoc-ui/intra-links-ambiguity.stderr b/src/test/rustdoc-ui/intra-links-ambiguity.stderr deleted file mode 100644 index 936055da01c..00000000000 --- a/src/test/rustdoc-ui/intra-links-ambiguity.stderr +++ /dev/null @@ -1,101 +0,0 @@ -error: `true` is both a module and a builtin type - --> $DIR/intra-links-ambiguity.rs:38:6 - | -LL | /// [true] - | ^^^^ ambiguous link - | -note: the lint level is defined here - --> $DIR/intra-links-ambiguity.rs:1:9 - | -LL | #![deny(broken_intra_doc_links)] - | ^^^^^^^^^^^^^^^^^^^^^^ -help: to link to the module, prefix with `mod@` - | -LL | /// [mod@true] - | ^^^^^^^^ -help: to link to the builtin type, prefix with `prim@` - | -LL | /// [prim@true] - | ^^^^^^^^^ - -error: `ambiguous` is both a struct and a function - --> $DIR/intra-links-ambiguity.rs:27:6 - | -LL | /// [`ambiguous`] is ambiguous. - | ^^^^^^^^^^^ ambiguous link - | -help: to link to the struct, prefix with `struct@` - | -LL | /// [`struct@ambiguous`] is ambiguous. - | ^^^^^^^^^^^^^^^^^^ -help: to link to the function, add parentheses - | -LL | /// [`ambiguous()`] is ambiguous. - | ^^^^^^^^^^^^^ - -error: `ambiguous` is both a struct and a function - --> $DIR/intra-links-ambiguity.rs:29:6 - | -LL | /// [ambiguous] is ambiguous. - | ^^^^^^^^^ ambiguous link - | -help: to link to the struct, prefix with `struct@` - | -LL | /// [struct@ambiguous] is ambiguous. - | ^^^^^^^^^^^^^^^^ -help: to link to the function, add parentheses - | -LL | /// [ambiguous()] is ambiguous. - | ^^^^^^^^^^^ - -error: `multi_conflict` is a struct, a function, and a macro - --> $DIR/intra-links-ambiguity.rs:31:6 - | -LL | /// [`multi_conflict`] is a three-way conflict. - | ^^^^^^^^^^^^^^^^ ambiguous link - | -help: to link to the struct, prefix with `struct@` - | -LL | /// [`struct@multi_conflict`] is a three-way conflict. - | ^^^^^^^^^^^^^^^^^^^^^^^ -help: to link to the function, add parentheses - | -LL | /// [`multi_conflict()`] is a three-way conflict. - | ^^^^^^^^^^^^^^^^^^ -help: to link to the macro, add an exclamation mark - | -LL | /// [`multi_conflict!`] is a three-way conflict. - | ^^^^^^^^^^^^^^^^^ - -error: `type_and_value` is both a module and a constant - --> $DIR/intra-links-ambiguity.rs:33:16 - | -LL | /// Ambiguous [type_and_value]. - | ^^^^^^^^^^^^^^ ambiguous link - | -help: to link to the module, prefix with `mod@` - | -LL | /// Ambiguous [mod@type_and_value]. - | ^^^^^^^^^^^^^^^^^^ -help: to link to the constant, prefix with `const@` - | -LL | /// Ambiguous [const@type_and_value]. - | ^^^^^^^^^^^^^^^^^^^^ - -error: `foo::bar` is both an enum and a function - --> $DIR/intra-links-ambiguity.rs:35:42 - | -LL | /// Ambiguous non-implied shortcut link [`foo::bar`]. - | ^^^^^^^^^^ ambiguous link - | -help: to link to the enum, prefix with `enum@` - | -LL | /// Ambiguous non-implied shortcut link [`enum@foo::bar`]. - | ^^^^^^^^^^^^^^^ -help: to link to the function, add parentheses - | -LL | /// Ambiguous non-implied shortcut link [`foo::bar()`]. - | ^^^^^^^^^^^^ - -error: aborting due to 6 previous errors - diff --git a/src/test/rustdoc-ui/intra-links-anchors.rs b/src/test/rustdoc-ui/intra-links-anchors.rs deleted file mode 100644 index ccefd2e6fab..00000000000 --- a/src/test/rustdoc-ui/intra-links-anchors.rs +++ /dev/null @@ -1,45 +0,0 @@ -#![deny(broken_intra_doc_links)] - -// A few tests on anchors. - -/// Hello people. -/// -/// You can anchors? Here's one! -/// -/// # hola -/// -/// Isn't it amazing? -pub struct Foo { - pub f: u8, -} - -pub enum Enum { - A, - B, -} - -/// Have you heard about stuff? -/// -/// Like [Foo#hola]. -/// -/// Or maybe [Foo::f#hola]. -//~^ ERROR `Foo::f#hola` contains an anchor -pub fn foo() {} - -/// Empty. -/// -/// Another anchor error: [hello#people#!]. -//~^ ERROR `hello#people#!` contains multiple anchors -pub fn bar() {} - -/// Empty? -/// -/// Damn enum's variants: [Enum::A#whatever]. -//~^ ERROR `Enum::A#whatever` contains an anchor -pub fn enum_link() {} - -/// Primitives? -/// -/// [u32#hello] -//~^ ERROR `u32#hello` contains an anchor -pub fn x() {} diff --git a/src/test/rustdoc-ui/intra-links-anchors.stderr b/src/test/rustdoc-ui/intra-links-anchors.stderr deleted file mode 100644 index 1825a4ad1fa..00000000000 --- a/src/test/rustdoc-ui/intra-links-anchors.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error: `Foo::f#hola` contains an anchor, but links to fields are already anchored - --> $DIR/intra-links-anchors.rs:25:15 - | -LL | /// Or maybe [Foo::f#hola]. - | ^^^^^^^^^^^ contains invalid anchor - | -note: the lint level is defined here - --> $DIR/intra-links-anchors.rs:1:9 - | -LL | #![deny(broken_intra_doc_links)] - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: `hello#people#!` contains multiple anchors - --> $DIR/intra-links-anchors.rs:31:28 - | -LL | /// Another anchor error: [hello#people#!]. - | ^^^^^^^^^^^^^^ contains invalid anchor - -error: `Enum::A#whatever` contains an anchor, but links to variants are already anchored - --> $DIR/intra-links-anchors.rs:37:28 - | -LL | /// Damn enum's variants: [Enum::A#whatever]. - | ^^^^^^^^^^^^^^^^ contains invalid anchor - -error: `u32#hello` contains an anchor, but links to builtin types are already anchored - --> $DIR/intra-links-anchors.rs:43:6 - | -LL | /// [u32#hello] - | ^^^^^^^^^ contains invalid anchor - -error: aborting due to 4 previous errors - diff --git a/src/test/rustdoc-ui/intra-links-disambiguator-mismatch.rs b/src/test/rustdoc-ui/intra-links-disambiguator-mismatch.rs deleted file mode 100644 index b9c8e033b1b..00000000000 --- a/src/test/rustdoc-ui/intra-links-disambiguator-mismatch.rs +++ /dev/null @@ -1,68 +0,0 @@ -#![deny(broken_intra_doc_links)] -//~^ NOTE lint level is defined -pub enum S {} - -macro_rules! m { - () => {}; -} - -static s: usize = 0; -const c: usize = 0; - -trait T {} - -/// Link to [struct@S] -//~^ ERROR incompatible link kind for `S` -//~| NOTE this link resolved -//~| HELP prefix with `enum@` - -/// Link to [mod@S] -//~^ ERROR incompatible link kind for `S` -//~| NOTE this link resolved -//~| HELP prefix with `enum@` - -/// Link to [union@S] -//~^ ERROR incompatible link kind for `S` -//~| NOTE this link resolved -//~| HELP prefix with `enum@` - -/// Link to [trait@S] -//~^ ERROR incompatible link kind for `S` -//~| NOTE this link resolved -//~| HELP prefix with `enum@` - -/// Link to [struct@T] -//~^ ERROR incompatible link kind for `T` -//~| NOTE this link resolved -//~| HELP prefix with `trait@` - -/// Link to [derive@m] -//~^ ERROR incompatible link kind for `m` -//~| NOTE this link resolved -//~| HELP add an exclamation mark - -/// Link to [const@s] -//~^ ERROR incompatible link kind for `s` -//~| NOTE this link resolved -//~| HELP prefix with `static@` - -/// Link to [static@c] -//~^ ERROR incompatible link kind for `c` -//~| NOTE this link resolved -//~| HELP prefix with `const@` - -/// Link to [fn@c] -//~^ ERROR incompatible link kind for `c` -//~| NOTE this link resolved -//~| HELP prefix with `const@` - -/// Link to [c()] -//~^ ERROR incompatible link kind for `c` -//~| NOTE this link resolved -//~| HELP prefix with `const@` - -/// Link to [const@f] -//~^ ERROR incompatible link kind for `f` -//~| NOTE this link resolved -//~| HELP add parentheses -pub fn f() {} diff --git a/src/test/rustdoc-ui/intra-links-disambiguator-mismatch.stderr b/src/test/rustdoc-ui/intra-links-disambiguator-mismatch.stderr deleted file mode 100644 index 2e732baf6e0..00000000000 --- a/src/test/rustdoc-ui/intra-links-disambiguator-mismatch.stderr +++ /dev/null @@ -1,95 +0,0 @@ -error: incompatible link kind for `S` - --> $DIR/intra-links-disambiguator-mismatch.rs:14:14 - | -LL | /// Link to [struct@S] - | ^^^^^^^^ help: to link to the enum, prefix with `enum@`: `enum@S` - | -note: the lint level is defined here - --> $DIR/intra-links-disambiguator-mismatch.rs:1:9 - | -LL | #![deny(broken_intra_doc_links)] - | ^^^^^^^^^^^^^^^^^^^^^^ - = note: this link resolved to an enum, which is not a struct - -error: incompatible link kind for `S` - --> $DIR/intra-links-disambiguator-mismatch.rs:19:14 - | -LL | /// Link to [mod@S] - | ^^^^^ help: to link to the enum, prefix with `enum@`: `enum@S` - | - = note: this link resolved to an enum, which is not a module - -error: incompatible link kind for `S` - --> $DIR/intra-links-disambiguator-mismatch.rs:24:14 - | -LL | /// Link to [union@S] - | ^^^^^^^ help: to link to the enum, prefix with `enum@`: `enum@S` - | - = note: this link resolved to an enum, which is not a union - -error: incompatible link kind for `S` - --> $DIR/intra-links-disambiguator-mismatch.rs:29:14 - | -LL | /// Link to [trait@S] - | ^^^^^^^ help: to link to the enum, prefix with `enum@`: `enum@S` - | - = note: this link resolved to an enum, which is not a trait - -error: incompatible link kind for `T` - --> $DIR/intra-links-disambiguator-mismatch.rs:34:14 - | -LL | /// Link to [struct@T] - | ^^^^^^^^ help: to link to the trait, prefix with `trait@`: `trait@T` - | - = note: this link resolved to a trait, which is not a struct - -error: incompatible link kind for `m` - --> $DIR/intra-links-disambiguator-mismatch.rs:39:14 - | -LL | /// Link to [derive@m] - | ^^^^^^^^ help: to link to the macro, add an exclamation mark: `m!` - | - = note: this link resolved to a macro, which is not a derive macro - -error: incompatible link kind for `s` - --> $DIR/intra-links-disambiguator-mismatch.rs:44:14 - | -LL | /// Link to [const@s] - | ^^^^^^^ help: to link to the static, prefix with `static@`: `static@s` - | - = note: this link resolved to a static, which is not a constant - -error: incompatible link kind for `c` - --> $DIR/intra-links-disambiguator-mismatch.rs:49:14 - | -LL | /// Link to [static@c] - | ^^^^^^^^ help: to link to the constant, prefix with `const@`: `const@c` - | - = note: this link resolved to a constant, which is not a static - -error: incompatible link kind for `c` - --> $DIR/intra-links-disambiguator-mismatch.rs:54:14 - | -LL | /// Link to [fn@c] - | ^^^^ help: to link to the constant, prefix with `const@`: `const@c` - | - = note: this link resolved to a constant, which is not a function - -error: incompatible link kind for `c` - --> $DIR/intra-links-disambiguator-mismatch.rs:59:14 - | -LL | /// Link to [c()] - | ^^^ help: to link to the constant, prefix with `const@`: `const@c` - | - = note: this link resolved to a constant, which is not a function - -error: incompatible link kind for `f` - --> $DIR/intra-links-disambiguator-mismatch.rs:64:14 - | -LL | /// Link to [const@f] - | ^^^^^^^ help: to link to the function, add parentheses: `f()` - | - = note: this link resolved to a function, which is not a constant - -error: aborting due to 11 previous errors - diff --git a/src/test/rustdoc-ui/intra-links-private.private.stderr b/src/test/rustdoc-ui/intra-links-private.private.stderr deleted file mode 100644 index eeef24b4797..00000000000 --- a/src/test/rustdoc-ui/intra-links-private.private.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: public documentation for `DocMe` links to private item `DontDocMe` - --> $DIR/intra-links-private.rs:5:11 - | -LL | /// docs [DontDocMe] - | ^^^^^^^^^ this item is private - | - = note: `#[warn(private_intra_doc_links)]` on by default - = note: this link resolves only because you passed `--document-private-items`, but will break without - -warning: 1 warning emitted - diff --git a/src/test/rustdoc-ui/intra-links-private.public.stderr b/src/test/rustdoc-ui/intra-links-private.public.stderr deleted file mode 100644 index 3f7b17586f1..00000000000 --- a/src/test/rustdoc-ui/intra-links-private.public.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: public documentation for `DocMe` links to private item `DontDocMe` - --> $DIR/intra-links-private.rs:5:11 - | -LL | /// docs [DontDocMe] - | ^^^^^^^^^ this item is private - | - = note: `#[warn(private_intra_doc_links)]` on by default - = note: this link will resolve properly if you pass `--document-private-items` - -warning: 1 warning emitted - diff --git a/src/test/rustdoc-ui/intra-links-private.rs b/src/test/rustdoc-ui/intra-links-private.rs deleted file mode 100644 index 613236d75d2..00000000000 --- a/src/test/rustdoc-ui/intra-links-private.rs +++ /dev/null @@ -1,9 +0,0 @@ -// check-pass -// revisions: public private -// [private]compile-flags: --document-private-items - -/// docs [DontDocMe] -//~^ WARNING public documentation for `DocMe` links to private item `DontDocMe` -// FIXME: for [private] we should also make sure the link was actually generated -pub struct DocMe; -struct DontDocMe; diff --git a/src/test/rustdoc-ui/intra-links-warning-crlf.rs b/src/test/rustdoc-ui/intra-links-warning-crlf.rs deleted file mode 100644 index a19c33b53be..00000000000 --- a/src/test/rustdoc-ui/intra-links-warning-crlf.rs +++ /dev/null @@ -1,26 +0,0 @@ -// ignore-tidy-cr -// check-pass - -// This file checks the spans of intra-link warnings in a file with CRLF line endings. The -// .gitattributes file in this directory should enforce it. - -/// [error] -pub struct A; -//~^^ WARNING `error` - -/// -/// docs [error1] -//~^ WARNING `error1` - -/// docs [error2] -/// -pub struct B; -//~^^^ WARNING `error2` - -/** - * This is a multi-line comment. - * - * It also has an [error]. - */ -pub struct C; -//~^^^ WARNING `error` diff --git a/src/test/rustdoc-ui/intra-links-warning-crlf.stderr b/src/test/rustdoc-ui/intra-links-warning-crlf.stderr deleted file mode 100644 index 67c48378fd2..00000000000 --- a/src/test/rustdoc-ui/intra-links-warning-crlf.stderr +++ /dev/null @@ -1,35 +0,0 @@ -warning: unresolved link to `error` - --> $DIR/intra-links-warning-crlf.rs:7:6 - | -LL | /// [error] - | ^^^^^ no item named `error` in scope - | - = note: `#[warn(broken_intra_doc_links)]` on by default - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - -warning: unresolved link to `error1` - --> $DIR/intra-links-warning-crlf.rs:12:11 - | -LL | /// docs [error1] - | ^^^^^^ no item named `error1` in scope - | - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - -warning: unresolved link to `error2` - --> $DIR/intra-links-warning-crlf.rs:15:11 - | -LL | /// docs [error2] - | ^^^^^^ no item named `error2` in scope - | - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - -warning: unresolved link to `error` - --> $DIR/intra-links-warning-crlf.rs:23:20 - | -LL | * It also has an [error]. - | ^^^^^ no item named `error` in scope - | - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - -warning: 4 warnings emitted - diff --git a/src/test/rustdoc-ui/intra-links-warning.rs b/src/test/rustdoc-ui/intra-links-warning.rs deleted file mode 100644 index eab1f034804..00000000000 --- a/src/test/rustdoc-ui/intra-links-warning.rs +++ /dev/null @@ -1,84 +0,0 @@ -// check-pass - - //! Test with [Foo::baz], [Bar::foo], ... -//~^ WARNING `Foo::baz` -//~| WARNING `Bar::foo` - //! , [Uniooon::X] and [Qux::Z]. -//~^ WARNING `Uniooon::X` -//~| WARNING `Qux::Z` - //! - //! , [Uniooon::X] and [Qux::Z]. -//~^ WARNING `Uniooon::X` -//~| WARNING `Qux::Z` - - /// [Qux:Y] -//~^ WARNING `Qux:Y` -pub struct Foo { - pub bar: usize, -} - -/// Foo -/// bar [BarA] bar //~ WARNING `BarA` -/// baz -pub fn a() {} - -/** - * Foo - * bar [BarB] bar //~ WARNING `BarB` - * baz - */ -pub fn b() {} - -/** Foo - -bar [BarC] bar //~ WARNING `BarC` -baz - - let bar_c_1 = 0; - let bar_c_2 = 0; - let g = [bar_c_1]; - let h = g[bar_c_2]; - -*/ -pub fn c() {} - -#[doc = "Foo\nbar [BarD] bar\nbaz"] //~ WARNING `BarD` -pub fn d() {} - -macro_rules! f { - ($f:expr) => { - #[doc = $f] //~ WARNING `BarF` - pub fn f() {} - } -} -f!("Foo\nbar [BarF] bar\nbaz"); - -/** # for example, - * - * time to introduce a link [error]*/ //~ WARNING `error` -pub struct A; - -/** - * # for example, - * - * time to introduce a link [error] //~ WARNING `error` - */ -pub struct B; - -#[doc = "single line [error]"] //~ WARNING `error` -pub struct C; - -#[doc = "single line with \"escaping\" [error]"] //~ WARNING `error` -pub struct D; - -/// Item docs. //~ WARNING `error` -#[doc="Hello there!"] -/// [error] -pub struct E; - -/// -/// docs [error1] //~ WARNING `error1` - -/// docs [error2] //~ WARNING `error2` -/// -pub struct F; diff --git a/src/test/rustdoc-ui/intra-links-warning.stderr b/src/test/rustdoc-ui/intra-links-warning.stderr deleted file mode 100644 index 0b074e9d53e..00000000000 --- a/src/test/rustdoc-ui/intra-links-warning.stderr +++ /dev/null @@ -1,175 +0,0 @@ -warning: unresolved link to `Foo::baz` - --> $DIR/intra-links-warning.rs:3:23 - | -LL | //! Test with [Foo::baz], [Bar::foo], ... - | ^^^^^^^^ the struct `Foo` has no field or associated item named `baz` - | - = note: `#[warn(broken_intra_doc_links)]` on by default - -warning: unresolved link to `Bar::foo` - --> $DIR/intra-links-warning.rs:3:35 - | -LL | //! Test with [Foo::baz], [Bar::foo], ... - | ^^^^^^^^ no item named `Bar` in scope - -warning: unresolved link to `Uniooon::X` - --> $DIR/intra-links-warning.rs:6:13 - | -LL | //! , [Uniooon::X] and [Qux::Z]. - | ^^^^^^^^^^ no item named `Uniooon` in scope - -warning: unresolved link to `Qux::Z` - --> $DIR/intra-links-warning.rs:6:30 - | -LL | //! , [Uniooon::X] and [Qux::Z]. - | ^^^^^^ no item named `Qux` in scope - -warning: unresolved link to `Uniooon::X` - --> $DIR/intra-links-warning.rs:10:14 - | -LL | //! , [Uniooon::X] and [Qux::Z]. - | ^^^^^^^^^^ no item named `Uniooon` in scope - -warning: unresolved link to `Qux::Z` - --> $DIR/intra-links-warning.rs:10:31 - | -LL | //! , [Uniooon::X] and [Qux::Z]. - | ^^^^^^ no item named `Qux` in scope - -warning: unresolved link to `Qux:Y` - --> $DIR/intra-links-warning.rs:14:13 - | -LL | /// [Qux:Y] - | ^^^^^ no item named `Qux:Y` in scope - | - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - -warning: unresolved link to `BarA` - --> $DIR/intra-links-warning.rs:21:10 - | -LL | /// bar [BarA] bar - | ^^^^ no item named `BarA` in scope - | - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - -warning: unresolved link to `BarB` - --> $DIR/intra-links-warning.rs:27:9 - | -LL | * bar [BarB] bar - | ^^^^ no item named `BarB` in scope - | - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - -warning: unresolved link to `BarC` - --> $DIR/intra-links-warning.rs:34:6 - | -LL | bar [BarC] bar - | ^^^^ no item named `BarC` in scope - | - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - -warning: unresolved link to `BarD` - --> $DIR/intra-links-warning.rs:45:1 - | -LL | #[doc = "Foo\nbar [BarD] bar\nbaz"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the link appears in this line: - - bar [BarD] bar - ^^^^ - = note: no item named `BarD` in scope - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - -warning: unresolved link to `BarF` - --> $DIR/intra-links-warning.rs:50:9 - | -LL | #[doc = $f] - | ^^^^^^^^^^^ -... -LL | f!("Foo\nbar [BarF] bar\nbaz"); - | ------------------------------- in this macro invocation - | - = note: the link appears in this line: - - bar [BarF] bar - ^^^^ - = note: no item named `BarF` in scope - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -warning: unresolved link to `error` - --> $DIR/intra-links-warning.rs:58:30 - | -LL | * time to introduce a link [error]*/ - | ^^^^^ no item named `error` in scope - | - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - -warning: unresolved link to `error` - --> $DIR/intra-links-warning.rs:64:30 - | -LL | * time to introduce a link [error] - | ^^^^^ no item named `error` in scope - | - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - -warning: unresolved link to `error` - --> $DIR/intra-links-warning.rs:68:1 - | -LL | #[doc = "single line [error]"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the link appears in this line: - - single line [error] - ^^^^^ - = note: no item named `error` in scope - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - -warning: unresolved link to `error` - --> $DIR/intra-links-warning.rs:71:1 - | -LL | #[doc = "single line with \"escaping\" [error]"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the link appears in this line: - - single line with "escaping" [error] - ^^^^^ - = note: no item named `error` in scope - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - -warning: unresolved link to `error` - --> $DIR/intra-links-warning.rs:74:1 - | -LL | / /// Item docs. -LL | | #[doc="Hello there!"] -LL | | /// [error] - | |___________^ - | - = note: the link appears in this line: - - [error] - ^^^^^ - = note: no item named `error` in scope - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - -warning: unresolved link to `error1` - --> $DIR/intra-links-warning.rs:80:11 - | -LL | /// docs [error1] - | ^^^^^^ no item named `error1` in scope - | - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - -warning: unresolved link to `error2` - --> $DIR/intra-links-warning.rs:82:11 - | -LL | /// docs [error2] - | ^^^^^^ no item named `error2` in scope - | - = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` - -warning: 19 warnings emitted - -- cgit 1.4.1-3-g733a5