1
Fork 0

Add warning annotations to rustdoc-ui tests

This commit is contained in:
Tomasz Miąsko 2019-11-08 00:00:00 +00:00
parent 267fc6dcf6
commit 70b146c2cb
6 changed files with 67 additions and 46 deletions

View file

@ -1,19 +1,21 @@
// ignore-tidy-cr // ignore-tidy-cr
// build-pass
// build-pass (FIXME(62277): could be check-pass?)
// This file checks the spans of intra-link warnings in a file with CRLF line endings. The // 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. // .gitattributes file in this directory should enforce it.
/// [error] /// [error]
pub struct A; pub struct A;
//~^^ WARNING `[error]` cannot be resolved
/// ///
/// docs [error1] /// docs [error1]
//~^ WARNING `[error1]` cannot be resolved
/// docs [error2] /// docs [error2]
/// ///
pub struct B; pub struct B;
//~^^^ WARNING `[error2]` cannot be resolved
/** /**
* This is a multi-line comment. * This is a multi-line comment.
@ -21,3 +23,4 @@ pub struct B;
* It also has an [error]. * It also has an [error].
*/ */
pub struct C; pub struct C;
//~^^^ WARNING `[error]` cannot be resolved

View file

@ -1,5 +1,5 @@
warning: `[error]` cannot be resolved, ignoring it... warning: `[error]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning-crlf.rs:8:6 --> $DIR/intra-links-warning-crlf.rs:7:6
| |
LL | /// [error] LL | /// [error]
| ^^^^^ cannot be resolved, ignoring | ^^^^^ cannot be resolved, ignoring
@ -16,7 +16,7 @@ LL | /// docs [error1]
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
warning: `[error2]` cannot be resolved, ignoring it... warning: `[error2]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning-crlf.rs:14:11 --> $DIR/intra-links-warning-crlf.rs:15:11
| |
LL | /// docs [error2] LL | /// docs [error2]
| ^^^^^^ cannot be resolved, ignoring | ^^^^^^ cannot be resolved, ignoring
@ -24,7 +24,7 @@ LL | /// docs [error2]
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
warning: `[error]` cannot be resolved, ignoring it... warning: `[error]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning-crlf.rs:21:20 --> $DIR/intra-links-warning-crlf.rs:23:20
| |
LL | * It also has an [error]. LL | * It also has an [error].
| ^^^^^ cannot be resolved, ignoring | ^^^^^ cannot be resolved, ignoring

View file

@ -1,30 +1,37 @@
// build-pass (FIXME(62277): could be check-pass?) // build-pass
//! Test with [Foo::baz], [Bar::foo], ... //! Test with [Foo::baz], [Bar::foo], ...
//~^ WARNING `[Foo::baz]` cannot be resolved
//~| WARNING `[Bar::foo]` cannot be resolved
//! , [Uniooon::X] and [Qux::Z]. //! , [Uniooon::X] and [Qux::Z].
//~^ WARNING `[Uniooon::X]` cannot be resolved
//~| WARNING `[Qux::Z]` cannot be resolved
//! //!
//! , [Uniooon::X] and [Qux::Z]. //! , [Uniooon::X] and [Qux::Z].
//~^ WARNING `[Uniooon::X]` cannot be resolved
//~| WARNING `[Qux::Z]` cannot be resolved
/// [Qux:Y] /// [Qux:Y]
//~^ WARNING `[Qux:Y]` cannot be resolved
pub struct Foo { pub struct Foo {
pub bar: usize, pub bar: usize,
} }
/// Foo /// Foo
/// bar [BarA] bar /// bar [BarA] bar //~ WARNING `[BarA]` cannot be resolved
/// baz /// baz
pub fn a() {} pub fn a() {}
/** /**
* Foo * Foo
* bar [BarB] bar * bar [BarB] bar //~ WARNING `[BarB]` cannot be resolved
* baz * baz
*/ */
pub fn b() {} pub fn b() {}
/** Foo /** Foo
bar [BarC] bar bar [BarC] bar //~ WARNING `[BarC]` cannot be resolved
baz baz
let bar_c_1 = 0; let bar_c_1 = 0;
@ -35,12 +42,12 @@ baz
*/ */
pub fn c() {} pub fn c() {}
#[doc = "Foo\nbar [BarD] bar\nbaz"] #[doc = "Foo\nbar [BarD] bar\nbaz"] //~ WARNING `[BarD]` cannot be resolved
pub fn d() {} pub fn d() {}
macro_rules! f { macro_rules! f {
($f:expr) => { ($f:expr) => {
#[doc = $f] #[doc = $f] //~ WARNING `[BarF]` cannot be resolved
pub fn f() {} pub fn f() {}
} }
} }
@ -48,30 +55,30 @@ f!("Foo\nbar [BarF] bar\nbaz");
/** # for example, /** # for example,
* *
* time to introduce a link [error]*/ * time to introduce a link [error]*/ //~ WARNING `[error]` cannot be resolved
pub struct A; pub struct A;
/** /**
* # for example, * # for example,
* *
* time to introduce a link [error] * time to introduce a link [error] //~ WARNING `[error]` cannot be resolved
*/ */
pub struct B; pub struct B;
#[doc = "single line [error]"] #[doc = "single line [error]"] //~ WARNING `[error]` cannot be resolved
pub struct C; pub struct C;
#[doc = "single line with \"escaping\" [error]"] #[doc = "single line with \"escaping\" [error]"] //~ WARNING `[error]` cannot be resolved
pub struct D; pub struct D;
/// Item docs. /// Item docs. //~ WARNING `[error]` cannot be resolved
#[doc="Hello there!"] #[doc="Hello there!"]
/// [error] /// [error]
pub struct E; pub struct E;
/// ///
/// docs [error1] /// docs [error1] //~ WARNING `[error1]` cannot be resolved
/// docs [error2] /// docs [error2] //~ WARNING `[error2]` cannot be resolved
/// ///
pub struct F; pub struct F;

View file

@ -16,7 +16,7 @@ LL | //! Test with [Foo::baz], [Bar::foo], ...
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
warning: `[Uniooon::X]` cannot be resolved, ignoring it... warning: `[Uniooon::X]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:4:13 --> $DIR/intra-links-warning.rs:6:13
| |
LL | //! , [Uniooon::X] and [Qux::Z]. LL | //! , [Uniooon::X] and [Qux::Z].
| ^^^^^^^^^^ cannot be resolved, ignoring | ^^^^^^^^^^ cannot be resolved, ignoring
@ -24,7 +24,7 @@ LL | //! , [Uniooon::X] and [Qux::Z].
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
warning: `[Qux::Z]` cannot be resolved, ignoring it... warning: `[Qux::Z]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:4:30 --> $DIR/intra-links-warning.rs:6:30
| |
LL | //! , [Uniooon::X] and [Qux::Z]. LL | //! , [Uniooon::X] and [Qux::Z].
| ^^^^^^ cannot be resolved, ignoring | ^^^^^^ cannot be resolved, ignoring
@ -32,7 +32,7 @@ LL | //! , [Uniooon::X] and [Qux::Z].
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
warning: `[Uniooon::X]` cannot be resolved, ignoring it... warning: `[Uniooon::X]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:6:14 --> $DIR/intra-links-warning.rs:10:14
| |
LL | //! , [Uniooon::X] and [Qux::Z]. LL | //! , [Uniooon::X] and [Qux::Z].
| ^^^^^^^^^^ cannot be resolved, ignoring | ^^^^^^^^^^ cannot be resolved, ignoring
@ -40,7 +40,7 @@ LL | //! , [Uniooon::X] and [Qux::Z].
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
warning: `[Qux::Z]` cannot be resolved, ignoring it... warning: `[Qux::Z]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:6:31 --> $DIR/intra-links-warning.rs:10:31
| |
LL | //! , [Uniooon::X] and [Qux::Z]. LL | //! , [Uniooon::X] and [Qux::Z].
| ^^^^^^ cannot be resolved, ignoring | ^^^^^^ cannot be resolved, ignoring
@ -48,7 +48,7 @@ LL | //! , [Uniooon::X] and [Qux::Z].
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
warning: `[Qux:Y]` cannot be resolved, ignoring it... warning: `[Qux:Y]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:8:13 --> $DIR/intra-links-warning.rs:14:13
| |
LL | /// [Qux:Y] LL | /// [Qux:Y]
| ^^^^^ cannot be resolved, ignoring | ^^^^^ cannot be resolved, ignoring
@ -56,7 +56,7 @@ LL | /// [Qux:Y]
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
warning: `[error]` cannot be resolved, ignoring it... warning: `[error]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:51:30 --> $DIR/intra-links-warning.rs:58:30
| |
LL | * time to introduce a link [error]*/ LL | * time to introduce a link [error]*/
| ^^^^^ cannot be resolved, ignoring | ^^^^^ cannot be resolved, ignoring
@ -64,7 +64,7 @@ LL | * time to introduce a link [error]*/
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
warning: `[error]` cannot be resolved, ignoring it... warning: `[error]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:57:30 --> $DIR/intra-links-warning.rs:64:30
| |
LL | * time to introduce a link [error] LL | * time to introduce a link [error]
| ^^^^^ cannot be resolved, ignoring | ^^^^^ cannot be resolved, ignoring
@ -72,7 +72,7 @@ LL | * time to introduce a link [error]
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
warning: `[error]` cannot be resolved, ignoring it... warning: `[error]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:61:1 --> $DIR/intra-links-warning.rs:68:1
| |
LL | #[doc = "single line [error]"] LL | #[doc = "single line [error]"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -84,7 +84,7 @@ LL | #[doc = "single line [error]"]
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
warning: `[error]` cannot be resolved, ignoring it... warning: `[error]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:64:1 --> $DIR/intra-links-warning.rs:71:1
| |
LL | #[doc = "single line with \"escaping\" [error]"] LL | #[doc = "single line with \"escaping\" [error]"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -96,7 +96,7 @@ LL | #[doc = "single line with \"escaping\" [error]"]
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
warning: `[error]` cannot be resolved, ignoring it... warning: `[error]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:67:1 --> $DIR/intra-links-warning.rs:74:1
| |
LL | / /// Item docs. LL | / /// Item docs.
LL | | #[doc="Hello there!"] LL | | #[doc="Hello there!"]
@ -110,7 +110,7 @@ LL | | /// [error]
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
warning: `[error1]` cannot be resolved, ignoring it... warning: `[error1]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:73:11 --> $DIR/intra-links-warning.rs:80:11
| |
LL | /// docs [error1] LL | /// docs [error1]
| ^^^^^^ cannot be resolved, ignoring | ^^^^^^ cannot be resolved, ignoring
@ -118,7 +118,7 @@ LL | /// docs [error1]
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
warning: `[error2]` cannot be resolved, ignoring it... warning: `[error2]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:75:11 --> $DIR/intra-links-warning.rs:82:11
| |
LL | /// docs [error2] LL | /// docs [error2]
| ^^^^^^ cannot be resolved, ignoring | ^^^^^^ cannot be resolved, ignoring
@ -126,7 +126,7 @@ LL | /// docs [error2]
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
warning: `[BarA]` cannot be resolved, ignoring it... warning: `[BarA]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:14:10 --> $DIR/intra-links-warning.rs:21:10
| |
LL | /// bar [BarA] bar LL | /// bar [BarA] bar
| ^^^^ cannot be resolved, ignoring | ^^^^ cannot be resolved, ignoring
@ -134,7 +134,7 @@ LL | /// bar [BarA] bar
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
warning: `[BarB]` cannot be resolved, ignoring it... warning: `[BarB]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:20:9 --> $DIR/intra-links-warning.rs:27:9
| |
LL | * bar [BarB] bar LL | * bar [BarB] bar
| ^^^^ cannot be resolved, ignoring | ^^^^ cannot be resolved, ignoring
@ -142,7 +142,7 @@ LL | * bar [BarB] bar
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
warning: `[BarC]` cannot be resolved, ignoring it... warning: `[BarC]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:27:6 --> $DIR/intra-links-warning.rs:34:6
| |
LL | bar [BarC] bar LL | bar [BarC] bar
| ^^^^ cannot be resolved, ignoring | ^^^^ cannot be resolved, ignoring
@ -150,7 +150,7 @@ LL | bar [BarC] bar
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
warning: `[BarD]` cannot be resolved, ignoring it... warning: `[BarD]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:38:1 --> $DIR/intra-links-warning.rs:45:1
| |
LL | #[doc = "Foo\nbar [BarD] bar\nbaz"] LL | #[doc = "Foo\nbar [BarD] bar\nbaz"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -162,7 +162,7 @@ LL | #[doc = "Foo\nbar [BarD] bar\nbaz"]
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` = help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`
warning: `[BarF]` cannot be resolved, ignoring it... warning: `[BarF]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:43:9 --> $DIR/intra-links-warning.rs:50:9
| |
LL | #[doc = $f] LL | #[doc = $f]
| ^^^^^^^^^^^ | ^^^^^^^^^^^

View file

@ -1,9 +1,10 @@
// build-pass (FIXME(62277): could be check-pass?) // build-pass
/// ``` /// ```
/// \__________pkt->size___________/ \_result->size_/ \__pkt->size__/ /// \__________pkt->size___________/ \_result->size_/ \__pkt->size__/
/// ``` /// ```
pub fn foo() {} pub fn foo() {}
//~^^^^ WARNING could not parse code block as Rust code
/// ``` /// ```
/// | /// |
@ -11,6 +12,7 @@ pub fn foo() {}
/// | ^^^^^^ did you mean `baz::foobar`? /// | ^^^^^^ did you mean `baz::foobar`?
/// ``` /// ```
pub fn bar() {} pub fn bar() {}
//~^^^^^^ WARNING could not parse code block as Rust code
/// ``` /// ```
/// valid /// valid
@ -24,6 +26,7 @@ pub fn bar() {}
/// "invalid /// "invalid
/// ``` /// ```
pub fn valid_and_invalid() {} pub fn valid_and_invalid() {}
//~^^^^^^^^ WARNING could not parse code block as Rust code
/// This is a normal doc comment, but... /// This is a normal doc comment, but...
/// ///
@ -35,6 +38,7 @@ pub fn valid_and_invalid() {}
/// ///
/// Good thing we tested it! /// Good thing we tested it!
pub fn baz() {} pub fn baz() {}
//~^^^^^^ WARNING could not parse code block as Rust code
/// Indented block start /// Indented block start
/// ///
@ -43,6 +47,7 @@ pub fn baz() {}
/// ///
/// Indented block end /// Indented block end
pub fn quux() {} pub fn quux() {}
//~^^^^^ could not parse code block as Rust code
/// Unclosed fence /// Unclosed fence
/// ///
@ -54,26 +59,31 @@ pub fn xyzzy() {}
/// ///
/// ``` /// ```
pub fn blah() {} pub fn blah() {}
//~^^ WARNING could not parse code block as Rust code
/// ```edition2018 /// ```edition2018
/// \_ /// \_
/// ``` /// ```
pub fn blargh() {} pub fn blargh() {}
//~^^^^ WARNING could not parse code block as Rust code
#[doc = "```"] #[doc = "```"]
/// \_ /// \_
#[doc = "```"] #[doc = "```"]
pub fn crazy_attrs() {} pub fn crazy_attrs() {}
//~^^^^ WARNING doc comment contains an invalid Rust code block
/// ```rust /// ```rust
/// ``` /// ```
pub fn empty_rust() {} pub fn empty_rust() {}
//~^^^ WARNING Rust code block is empty
/// ``` /// ```
/// ///
/// ///
/// ``` /// ```
pub fn empty_rust_with_whitespace() {} pub fn empty_rust_with_whitespace() {}
//~^^^^^ WARNING Rust code block is empty
/// ``` /// ```
/// let x = 1; /// let x = 1;
@ -82,3 +92,4 @@ pub fn empty_rust_with_whitespace() {}
/// \____/ /// \____/
/// ///
pub fn indent_after_fenced() {} pub fn indent_after_fenced() {}
//~^^^ WARNING could not parse code block as Rust code

View file

@ -53,7 +53,7 @@ help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it
| ^ | ^
warning: could not parse code block as Rust code warning: could not parse code block as Rust code
--> $DIR/invalid-syntax.rs:8:5 --> $DIR/invalid-syntax.rs:9:5
| |
LL | /// ``` LL | /// ```
| _____^ | _____^
@ -75,7 +75,7 @@ error: unknown start of token: \
| ^ | ^
warning: could not parse code block as Rust code warning: could not parse code block as Rust code
--> $DIR/invalid-syntax.rs:19:5 --> $DIR/invalid-syntax.rs:21:5
| |
LL | /// ``` LL | /// ```
| _____^ | _____^
@ -95,7 +95,7 @@ error: unknown start of token: \
| ^ | ^
warning: could not parse code block as Rust code warning: could not parse code block as Rust code
--> $DIR/invalid-syntax.rs:32:5 --> $DIR/invalid-syntax.rs:35:5
| |
LL | /// ```rust LL | /// ```rust
| _____^ | _____^
@ -110,7 +110,7 @@ error: unknown start of token: \
| ^ | ^
warning: could not parse code block as Rust code warning: could not parse code block as Rust code
--> $DIR/invalid-syntax.rs:41:9 --> $DIR/invalid-syntax.rs:45:9
| |
LL | /// code with bad syntax LL | /// code with bad syntax
| _________^ | _________^
@ -151,7 +151,7 @@ help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it
| ^ | ^
warning: could not parse code block as Rust code warning: could not parse code block as Rust code
--> $DIR/invalid-syntax.rs:55:9 --> $DIR/invalid-syntax.rs:60:9
| |
LL | /// ``` LL | /// ```
| ^^^ | ^^^
@ -163,7 +163,7 @@ error: unknown start of token: \
| ^ | ^
warning: could not parse code block as Rust code warning: could not parse code block as Rust code
--> $DIR/invalid-syntax.rs:58:5 --> $DIR/invalid-syntax.rs:64:5
| |
LL | /// ```edition2018 LL | /// ```edition2018
| _____^ | _____^
@ -178,7 +178,7 @@ error: unknown start of token: \
| ^ | ^
warning: doc comment contains an invalid Rust code block warning: doc comment contains an invalid Rust code block
--> $DIR/invalid-syntax.rs:63:1 --> $DIR/invalid-syntax.rs:70:1
| |
LL | / #[doc = "```"] LL | / #[doc = "```"]
LL | | /// \_ LL | | /// \_
@ -188,7 +188,7 @@ LL | | #[doc = "```"]
= help: mark blocks that do not contain Rust code as text: ```text = help: mark blocks that do not contain Rust code as text: ```text
warning: Rust code block is empty warning: Rust code block is empty
--> $DIR/invalid-syntax.rs:68:5 --> $DIR/invalid-syntax.rs:76:5
| |
LL | /// ```rust LL | /// ```rust
| _____^ | _____^
@ -196,7 +196,7 @@ LL | | /// ```
| |_______^ | |_______^
warning: Rust code block is empty warning: Rust code block is empty
--> $DIR/invalid-syntax.rs:72:5 --> $DIR/invalid-syntax.rs:81:5
| |
LL | /// ``` LL | /// ```
| _____^ | _____^
@ -217,7 +217,7 @@ error: unknown start of token: \
| ^ | ^
warning: could not parse code block as Rust code warning: could not parse code block as Rust code
--> $DIR/invalid-syntax.rs:82:9 --> $DIR/invalid-syntax.rs:92:9
| |
LL | /// \____/ LL | /// \____/
| ^^^^^^ | ^^^^^^