Add test for anchors

This commit is contained in:
Guillaume Gomez 2019-11-23 18:45:55 +01:00
parent 454d13badf
commit 433f2b030b
3 changed files with 89 additions and 0 deletions

View 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() {}

View 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

View 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;