mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
Add test for anchors
This commit is contained in:
parent
454d13badf
commit
433f2b030b
45
src/test/rustdoc-ui/intra-links-anchors.rs
Normal file
45
src/test/rustdoc-ui/intra-links-anchors.rs
Normal file
@ -0,0 +1,45 @@
|
||||
#![deny(intra_doc_link_resolution_failure)]
|
||||
|
||||
// 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]` has an anchor issue...
|
||||
pub fn foo() {}
|
||||
|
||||
/// Empty.
|
||||
///
|
||||
/// Another anchor error: [hello#people#!].
|
||||
//~^ ERROR `[hello#people#!]` has an anchor issue...
|
||||
pub fn bar() {}
|
||||
|
||||
/// Empty?
|
||||
///
|
||||
/// Damn enum's variants: [Enum::A#whatever].
|
||||
//~^ ERROR `[Enum::A#whatever]` has an anchor issue...
|
||||
pub fn enum_link() {}
|
||||
|
||||
/// Primitives?
|
||||
///
|
||||
/// [u32#hello]
|
||||
//~^ ERROR `[u32#hello]` has an anchor issue...
|
||||
pub fn x() {}
|
32
src/test/rustdoc-ui/intra-links-anchors.stderr
Normal file
32
src/test/rustdoc-ui/intra-links-anchors.stderr
Normal file
@ -0,0 +1,32 @@
|
||||
error: `[Foo::f#hola]` has an anchor issue...
|
||||
--> $DIR/intra-links-anchors.rs:25:15
|
||||
|
|
||||
LL | /// Or maybe [Foo::f#hola].
|
||||
| ^^^^^^^^^^^ struct fields cannot be followed by anchors
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/intra-links-anchors.rs:1:9
|
||||
|
|
||||
LL | #![deny(intra_doc_link_resolution_failure)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `[hello#people#!]` has an anchor issue...
|
||||
--> $DIR/intra-links-anchors.rs:31:28
|
||||
|
|
||||
LL | /// Another anchor error: [hello#people#!].
|
||||
| ^^^^^^^^^^^^^^ only one `#` is allowed in a link
|
||||
|
||||
error: `[Enum::A#whatever]` has an anchor issue...
|
||||
--> $DIR/intra-links-anchors.rs:37:28
|
||||
|
|
||||
LL | /// Damn enum's variants: [Enum::A#whatever].
|
||||
| ^^^^^^^^^^^^^^^^ variants cannot be followed by anchors
|
||||
|
||||
error: `[u32#hello]` has an anchor issue...
|
||||
--> $DIR/intra-links-anchors.rs:43:6
|
||||
|
|
||||
LL | /// [u32#hello]
|
||||
| ^^^^^^^^^ primitive types cannot be followed by anchors
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
12
src/test/rustdoc/intra-links-anchors.rs
Normal file
12
src/test/rustdoc/intra-links-anchors.rs
Normal file
@ -0,0 +1,12 @@
|
||||
/// 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;
|
Loading…
Reference in New Issue
Block a user