about summary refs log tree commit diff
path: root/src/test/rustdoc-ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/rustdoc-ui')
-rw-r--r--src/test/rustdoc-ui/auxiliary/issue-61592.rs3
-rw-r--r--src/test/rustdoc-ui/doc-alias-crate-level.rs2
-rw-r--r--src/test/rustdoc-ui/doc-alias-crate-level.stderr4
-rw-r--r--src/test/rustdoc-ui/doc-alias-same-name.rs4
-rw-r--r--src/test/rustdoc-ui/doc-alias-same-name.stderr8
-rw-r--r--src/test/rustdoc-ui/error-in-impl-trait/const-generics.rs1
-rw-r--r--src/test/rustdoc-ui/ignore-block-help.rs7
-rw-r--r--src/test/rustdoc-ui/ignore-block-help.stderr17
-rw-r--r--src/test/rustdoc-ui/intra-doc/incompatible-primitive-disambiguator.rs3
-rw-r--r--src/test/rustdoc-ui/intra-doc/incompatible-primitive-disambiguator.stderr15
-rw-r--r--src/test/rustdoc-ui/intra-doc/non-path-primitives.rs34
-rw-r--r--src/test/rustdoc-ui/intra-doc/non-path-primitives.stderr69
-rw-r--r--src/test/rustdoc-ui/invalid-syntax.stderr6
-rw-r--r--src/test/rustdoc-ui/issue-61592-2.rs10
-rw-r--r--src/test/rustdoc-ui/issue-61592-2.stderr12
-rw-r--r--src/test/rustdoc-ui/issue-61592.rs8
-rw-r--r--src/test/rustdoc-ui/issue-61592.stderr11
-rw-r--r--src/test/rustdoc-ui/reference-link-reports-error-once.rs20
-rw-r--r--src/test/rustdoc-ui/reference-link-reports-error-once.stderr63
-rw-r--r--src/test/rustdoc-ui/reference-links.rs6
-rw-r--r--src/test/rustdoc-ui/reference-links.stderr14
21 files changed, 310 insertions, 7 deletions
diff --git a/src/test/rustdoc-ui/auxiliary/issue-61592.rs b/src/test/rustdoc-ui/auxiliary/issue-61592.rs
new file mode 100644
index 00000000000..57a365b3f38
--- /dev/null
+++ b/src/test/rustdoc-ui/auxiliary/issue-61592.rs
@@ -0,0 +1,3 @@
+#![crate_name = "foo"]
+
+pub trait Foo {}
diff --git a/src/test/rustdoc-ui/doc-alias-crate-level.rs b/src/test/rustdoc-ui/doc-alias-crate-level.rs
index 309d0bc4d43..70618ac01df 100644
--- a/src/test/rustdoc-ui/doc-alias-crate-level.rs
+++ b/src/test/rustdoc-ui/doc-alias-crate-level.rs
@@ -1,5 +1,3 @@
-#![feature(doc_alias)]
-
 #![doc(alias = "crate-level-not-working")] //~ ERROR
 
 #[doc(alias = "shouldn't work!")] //~ ERROR
diff --git a/src/test/rustdoc-ui/doc-alias-crate-level.stderr b/src/test/rustdoc-ui/doc-alias-crate-level.stderr
index a58e91c5aa7..9e746cba05f 100644
--- a/src/test/rustdoc-ui/doc-alias-crate-level.stderr
+++ b/src/test/rustdoc-ui/doc-alias-crate-level.stderr
@@ -1,11 +1,11 @@
 error: '\'' character isn't allowed in `#[doc(alias = "...")]`
-  --> $DIR/doc-alias-crate-level.rs:5:15
+  --> $DIR/doc-alias-crate-level.rs:3:15
    |
 LL | #[doc(alias = "shouldn't work!")]
    |               ^^^^^^^^^^^^^^^^^
 
 error: `#![doc(alias = "...")]` isn't allowed as a crate level attribute
-  --> $DIR/doc-alias-crate-level.rs:3:8
+  --> $DIR/doc-alias-crate-level.rs:1:8
    |
 LL | #![doc(alias = "crate-level-not-working")]
    |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/src/test/rustdoc-ui/doc-alias-same-name.rs b/src/test/rustdoc-ui/doc-alias-same-name.rs
new file mode 100644
index 00000000000..da97c267618
--- /dev/null
+++ b/src/test/rustdoc-ui/doc-alias-same-name.rs
@@ -0,0 +1,4 @@
+#![crate_type = "lib"]
+
+#[doc(alias = "Foo")] //~ ERROR
+pub struct Foo;
diff --git a/src/test/rustdoc-ui/doc-alias-same-name.stderr b/src/test/rustdoc-ui/doc-alias-same-name.stderr
new file mode 100644
index 00000000000..5ba09a2eae1
--- /dev/null
+++ b/src/test/rustdoc-ui/doc-alias-same-name.stderr
@@ -0,0 +1,8 @@
+error: `#[doc(alias = "...")]` is the same as the item's name
+  --> $DIR/doc-alias-same-name.rs:3:7
+   |
+LL | #[doc(alias = "Foo")]
+   |       ^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/rustdoc-ui/error-in-impl-trait/const-generics.rs b/src/test/rustdoc-ui/error-in-impl-trait/const-generics.rs
index 97760cbf8fb..ed62f0208aa 100644
--- a/src/test/rustdoc-ui/error-in-impl-trait/const-generics.rs
+++ b/src/test/rustdoc-ui/error-in-impl-trait/const-generics.rs
@@ -1,6 +1,5 @@
 // check-pass
 // edition:2018
-#![feature(min_const_generics)]
 trait ValidTrait {}
 
 /// This has docs
diff --git a/src/test/rustdoc-ui/ignore-block-help.rs b/src/test/rustdoc-ui/ignore-block-help.rs
new file mode 100644
index 00000000000..c22dddd11df
--- /dev/null
+++ b/src/test/rustdoc-ui/ignore-block-help.rs
@@ -0,0 +1,7 @@
+// check-pass
+
+/// ```ignore (to-prevent-tidy-error)
+/// let heart = '❤️';
+/// ```
+//~^^^ WARN
+pub struct X;
diff --git a/src/test/rustdoc-ui/ignore-block-help.stderr b/src/test/rustdoc-ui/ignore-block-help.stderr
new file mode 100644
index 00000000000..d45cd92d2d1
--- /dev/null
+++ b/src/test/rustdoc-ui/ignore-block-help.stderr
@@ -0,0 +1,17 @@
+warning: could not parse code block as Rust code
+  --> $DIR/ignore-block-help.rs:3:5
+   |
+LL |   /// ```ignore (to-prevent-tidy-error)
+   |  _____^
+LL | | /// let heart = '❤️';
+LL | | /// ```
+   | |_______^
+   |
+   = note: error from rustc: character literal may only contain one codepoint
+help: `ignore` code blocks require valid Rust code for syntax highlighting. Mark blocks that do not contain Rust code as text
+   |
+LL | /// ```text,ignore (to-prevent-tidy-error)
+   |     ^^^^^^^^
+
+warning: 1 warning emitted
+
diff --git a/src/test/rustdoc-ui/intra-doc/incompatible-primitive-disambiguator.rs b/src/test/rustdoc-ui/intra-doc/incompatible-primitive-disambiguator.rs
new file mode 100644
index 00000000000..0d1d5d1134b
--- /dev/null
+++ b/src/test/rustdoc-ui/intra-doc/incompatible-primitive-disambiguator.rs
@@ -0,0 +1,3 @@
+#![deny(broken_intra_doc_links)]
+//! [static@u8::MIN]
+//~^ ERROR incompatible link kind
diff --git a/src/test/rustdoc-ui/intra-doc/incompatible-primitive-disambiguator.stderr b/src/test/rustdoc-ui/intra-doc/incompatible-primitive-disambiguator.stderr
new file mode 100644
index 00000000000..ed1c10f9e0c
--- /dev/null
+++ b/src/test/rustdoc-ui/intra-doc/incompatible-primitive-disambiguator.stderr
@@ -0,0 +1,15 @@
+error: incompatible link kind for `u8::MIN`
+  --> $DIR/incompatible-primitive-disambiguator.rs:2:6
+   |
+LL | //! [static@u8::MIN]
+   |      ^^^^^^^^^^^^^^ help: to link to the associated constant, prefix with `const@`: `const@u8::MIN`
+   |
+note: the lint level is defined here
+  --> $DIR/incompatible-primitive-disambiguator.rs:1:9
+   |
+LL | #![deny(broken_intra_doc_links)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^
+   = note: this link resolved to an associated constant, which is not a static
+
+error: aborting due to previous error
+
diff --git a/src/test/rustdoc-ui/intra-doc/non-path-primitives.rs b/src/test/rustdoc-ui/intra-doc/non-path-primitives.rs
new file mode 100644
index 00000000000..114502b0ddf
--- /dev/null
+++ b/src/test/rustdoc-ui/intra-doc/non-path-primitives.rs
@@ -0,0 +1,34 @@
+#![deny(broken_intra_doc_links)]
+// These are links that could reasonably expected to work, but don't.
+
+// `[]` isn't supported because it had too many false positives.
+//! [X]([T]::not_here)
+//! [Y](&[]::not_here)
+//! [X]([]::not_here)
+//! [Y]([T;N]::not_here)
+
+// These don't work because markdown syntax doesn't allow it.
+//! [[T]::rotate_left] //~ ERROR unresolved link to `T`
+//! [&[]::not_here]
+//![Z]([T; N]::map) //~ ERROR unresolved link to `Z`
+//! [`[T; N]::map`]
+//! [[]::map]
+//! [Z][] //~ ERROR unresolved link to `Z`
+//!
+//! [Z]: [T; N]::map //~ ERROR unresolved link to `Z`
+
+// `()` isn't supported because it had too many false positives.
+//! [()::not_here]
+//! [X]((,)::not_here)
+//! [(,)::not_here]
+
+// FIXME: Associated items on some primitives aren't working, because the impls
+// are part of the compiler instead of being part of the source code.
+//! [unit::eq] //~ ERROR unresolved
+//! [tuple::eq] //~ ERROR unresolved
+//! [fn::eq] //~ ERROR unresolved
+//! [never::eq] //~ ERROR unresolved
+
+// FIXME(#78800): This breaks because it's a blanket impl
+// (I think? Might break for other reasons too.)
+//! [reference::deref] //~ ERROR unresolved
diff --git a/src/test/rustdoc-ui/intra-doc/non-path-primitives.stderr b/src/test/rustdoc-ui/intra-doc/non-path-primitives.stderr
new file mode 100644
index 00000000000..ea831e648f6
--- /dev/null
+++ b/src/test/rustdoc-ui/intra-doc/non-path-primitives.stderr
@@ -0,0 +1,69 @@
+error: unresolved link to `T`
+  --> $DIR/non-path-primitives.rs:11:7
+   |
+LL | //! [[T]::rotate_left]
+   |       ^ no item named `T` in scope
+   |
+note: the lint level is defined here
+  --> $DIR/non-path-primitives.rs:1:9
+   |
+LL | #![deny(broken_intra_doc_links)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^
+   = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
+
+error: unresolved link to `Z`
+  --> $DIR/non-path-primitives.rs:13:5
+   |
+LL | //![Z]([T; N]::map)
+   |     ^ no item named `Z` in scope
+   |
+   = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
+
+error: unresolved link to `Z`
+  --> $DIR/non-path-primitives.rs:16:6
+   |
+LL | //! [Z][]
+   |      ^ no item named `Z` in scope
+   |
+   = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
+
+error: unresolved link to `Z`
+  --> $DIR/non-path-primitives.rs:18:6
+   |
+LL | //! [Z]: [T; N]::map
+   |      ^ no item named `Z` in scope
+   |
+   = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
+
+error: unresolved link to `unit::eq`
+  --> $DIR/non-path-primitives.rs:27:6
+   |
+LL | //! [unit::eq]
+   |      ^^^^^^^^ the builtin type `unit` has no associated item named `eq`
+
+error: unresolved link to `tuple::eq`
+  --> $DIR/non-path-primitives.rs:28:6
+   |
+LL | //! [tuple::eq]
+   |      ^^^^^^^^^ the builtin type `tuple` has no associated item named `eq`
+
+error: unresolved link to `fn::eq`
+  --> $DIR/non-path-primitives.rs:29:6
+   |
+LL | //! [fn::eq]
+   |      ^^^^^^ the builtin type `fn` has no associated item named `eq`
+
+error: unresolved link to `never::eq`
+  --> $DIR/non-path-primitives.rs:30:6
+   |
+LL | //! [never::eq]
+   |      ^^^^^^^^^ the builtin type `never` has no associated item named `eq`
+
+error: unresolved link to `reference::deref`
+  --> $DIR/non-path-primitives.rs:34:6
+   |
+LL | //! [reference::deref]
+   |      ^^^^^^^^^^^^^^^^ the builtin type `reference` has no associated item named `deref`
+
+error: aborting due to 9 previous errors
+
diff --git a/src/test/rustdoc-ui/invalid-syntax.stderr b/src/test/rustdoc-ui/invalid-syntax.stderr
index 9a7a4d21013..75acdc5ab5f 100644
--- a/src/test/rustdoc-ui/invalid-syntax.stderr
+++ b/src/test/rustdoc-ui/invalid-syntax.stderr
@@ -127,8 +127,10 @@ LL | /// ```text
 warning: could not parse code block as Rust code
   --> $DIR/invalid-syntax.rs:92:9
    |
-LL | ///     \____/
-   |         ^^^^^^
+LL |   ///     \____/
+   |  _________^
+LL | | ///
+   | |_
    |
    = note: error from rustc: unknown start of token: \
 
diff --git a/src/test/rustdoc-ui/issue-61592-2.rs b/src/test/rustdoc-ui/issue-61592-2.rs
new file mode 100644
index 00000000000..5b4fc5ee700
--- /dev/null
+++ b/src/test/rustdoc-ui/issue-61592-2.rs
@@ -0,0 +1,10 @@
+// aux-build:issue-61592.rs
+
+extern crate foo;
+
+#[doc = "bar"]
+#[doc(inline)] //~ ERROR
+#[doc = "baz"]
+pub use foo::Foo as _;
+
+fn main() {}
diff --git a/src/test/rustdoc-ui/issue-61592-2.stderr b/src/test/rustdoc-ui/issue-61592-2.stderr
new file mode 100644
index 00000000000..1b7f8bb552c
--- /dev/null
+++ b/src/test/rustdoc-ui/issue-61592-2.stderr
@@ -0,0 +1,12 @@
+error[E0780]: anonymous imports cannot be inlined
+  --> $DIR/issue-61592-2.rs:6:7
+   |
+LL | #[doc(inline)]
+   |       ^^^^^^
+LL | #[doc = "baz"]
+LL | pub use foo::Foo as _;
+   | ---------------------- anonymous import
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0780`.
diff --git a/src/test/rustdoc-ui/issue-61592.rs b/src/test/rustdoc-ui/issue-61592.rs
new file mode 100644
index 00000000000..66772557f2c
--- /dev/null
+++ b/src/test/rustdoc-ui/issue-61592.rs
@@ -0,0 +1,8 @@
+// aux-build:issue-61592.rs
+
+extern crate foo;
+
+#[doc(inline)] //~ ERROR
+pub use foo::Foo as _;
+
+fn main() {}
diff --git a/src/test/rustdoc-ui/issue-61592.stderr b/src/test/rustdoc-ui/issue-61592.stderr
new file mode 100644
index 00000000000..9c9c9106f8a
--- /dev/null
+++ b/src/test/rustdoc-ui/issue-61592.stderr
@@ -0,0 +1,11 @@
+error[E0780]: anonymous imports cannot be inlined
+  --> $DIR/issue-61592.rs:5:7
+   |
+LL | #[doc(inline)]
+   |       ^^^^^^
+LL | pub use foo::Foo as _;
+   | ---------------------- anonymous import
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0780`.
diff --git a/src/test/rustdoc-ui/reference-link-reports-error-once.rs b/src/test/rustdoc-ui/reference-link-reports-error-once.rs
new file mode 100644
index 00000000000..7957ee373c4
--- /dev/null
+++ b/src/test/rustdoc-ui/reference-link-reports-error-once.rs
@@ -0,0 +1,20 @@
+#![deny(broken_intra_doc_links)]
+
+/// Links to [a] [link][a]
+/// And also a [third link][a]
+/// And also a [reference link][b]
+///
+/// Other links to the same target should still emit error: [ref] //~ERROR unresolved link to `ref`
+/// Duplicate [ref] //~ERROR unresolved link to `ref`
+///
+/// Other links to other targets should still emit error: [ref2] //~ERROR unresolved link to `ref2`
+/// Duplicate [ref2] //~ERROR unresolved link to `ref2`
+///
+/// [a]: ref
+//~^ ERROR unresolved link to `ref`
+/// [b]: ref2
+//~^ ERROR unresolved link to
+
+/// [ref][]
+//~^ ERROR unresolved link
+pub fn f() {}
diff --git a/src/test/rustdoc-ui/reference-link-reports-error-once.stderr b/src/test/rustdoc-ui/reference-link-reports-error-once.stderr
new file mode 100644
index 00000000000..218eb334a6f
--- /dev/null
+++ b/src/test/rustdoc-ui/reference-link-reports-error-once.stderr
@@ -0,0 +1,63 @@
+error: unresolved link to `ref`
+  --> $DIR/reference-link-reports-error-once.rs:13:10
+   |
+LL | /// [a]: ref
+   |          ^^^ no item named `ref` in scope
+   |
+note: the lint level is defined here
+  --> $DIR/reference-link-reports-error-once.rs:1:9
+   |
+LL | #![deny(broken_intra_doc_links)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^
+   = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
+
+error: unresolved link to `ref2`
+  --> $DIR/reference-link-reports-error-once.rs:15:10
+   |
+LL | /// [b]: ref2
+   |          ^^^^ no item named `ref2` in scope
+   |
+   = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
+
+error: unresolved link to `ref`
+  --> $DIR/reference-link-reports-error-once.rs:7:62
+   |
+LL | /// Other links to the same target should still emit error: [ref]
+   |                                                              ^^^ no item named `ref` in scope
+   |
+   = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
+
+error: unresolved link to `ref`
+  --> $DIR/reference-link-reports-error-once.rs:8:16
+   |
+LL | /// Duplicate [ref]
+   |                ^^^ no item named `ref` in scope
+   |
+   = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
+
+error: unresolved link to `ref2`
+  --> $DIR/reference-link-reports-error-once.rs:10:60
+   |
+LL | /// Other links to other targets should still emit error: [ref2]
+   |                                                            ^^^^ no item named `ref2` in scope
+   |
+   = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
+
+error: unresolved link to `ref2`
+  --> $DIR/reference-link-reports-error-once.rs:11:16
+   |
+LL | /// Duplicate [ref2]
+   |                ^^^^ no item named `ref2` in scope
+   |
+   = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
+
+error: unresolved link to `ref`
+  --> $DIR/reference-link-reports-error-once.rs:18:6
+   |
+LL | /// [ref][]
+   |      ^^^ no item named `ref` in scope
+   |
+   = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
+
+error: aborting due to 7 previous errors
+
diff --git a/src/test/rustdoc-ui/reference-links.rs b/src/test/rustdoc-ui/reference-links.rs
new file mode 100644
index 00000000000..6e00b9f0fa1
--- /dev/null
+++ b/src/test/rustdoc-ui/reference-links.rs
@@ -0,0 +1,6 @@
+// Test that errors point to the reference, not to the title text.
+#![deny(broken_intra_doc_links)]
+//! Links to [a] [link][a]
+//!
+//! [a]: std::process::Comman
+//~^ ERROR unresolved
diff --git a/src/test/rustdoc-ui/reference-links.stderr b/src/test/rustdoc-ui/reference-links.stderr
new file mode 100644
index 00000000000..3df89df21b4
--- /dev/null
+++ b/src/test/rustdoc-ui/reference-links.stderr
@@ -0,0 +1,14 @@
+error: unresolved link to `std::process::Comman`
+  --> $DIR/reference-links.rs:5:10
+   |
+LL | //! [a]: std::process::Comman
+   |          ^^^^^^^^^^^^^^^^^^^^ no item named `Comman` in module `process`
+   |
+note: the lint level is defined here
+  --> $DIR/reference-links.rs:2:9
+   |
+LL | #![deny(broken_intra_doc_links)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+