Skip to content

Commit

Permalink
Auto merge of #66213 - tmiasko:mandatory-error-warn, r=petrochenkov
Browse files Browse the repository at this point in the history
Make error and warning annotations mandatory in UI tests

This change makes error and warning annotations mandatory in UI tests.
The only exception are tests that use error patterns to match compiler
output and don't have any annotations.

Fixes #55596.
  • Loading branch information
bors committed Nov 11, 2019
2 parents 2a9be46 + 427952e commit 9248b01
Show file tree
Hide file tree
Showing 94 changed files with 464 additions and 416 deletions.
7 changes: 5 additions & 2 deletions src/test/rustdoc-ui/intra-links-warning-crlf.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
// ignore-tidy-cr

// build-pass (FIXME(62277): could be check-pass?)
// build-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]` cannot be resolved

///
/// docs [error1]
//~^ WARNING `[error1]` cannot be resolved

/// docs [error2]
///
pub struct B;
//~^^^ WARNING `[error2]` cannot be resolved

/**
* This is a multi-line comment.
*
* It also has an [error].
*/
pub struct C;
//~^^^ WARNING `[error]` cannot be resolved
6 changes: 3 additions & 3 deletions src/test/rustdoc-ui/intra-links-warning-crlf.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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]
| ^^^^^ cannot be resolved, ignoring
Expand All @@ -16,15 +16,15 @@ LL | /// docs [error1]
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

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]
| ^^^^^^ cannot be resolved, ignoring
|
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

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].
| ^^^^^ cannot be resolved, ignoring
Expand Down
33 changes: 20 additions & 13 deletions src/test/rustdoc-ui/intra-links-warning.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
// build-pass (FIXME(62277): could be check-pass?)
// build-pass

//! Test with [Foo::baz], [Bar::foo], ...
//~^ WARNING `[Foo::baz]` cannot be resolved
//~| WARNING `[Bar::foo]` cannot be resolved
//! , [Uniooon::X] and [Qux::Z].
//~^ WARNING `[Uniooon::X]` cannot be resolved
//~| WARNING `[Qux::Z]` cannot be resolved
//!
//! , [Uniooon::X] and [Qux::Z].
//~^ WARNING `[Uniooon::X]` cannot be resolved
//~| WARNING `[Qux::Z]` cannot be resolved

/// [Qux:Y]
//~^ WARNING `[Qux:Y]` cannot be resolved
pub struct Foo {
pub bar: usize,
}

/// Foo
/// bar [BarA] bar
/// bar [BarA] bar //~ WARNING `[BarA]` cannot be resolved
/// baz
pub fn a() {}

/**
* Foo
* bar [BarB] bar
* bar [BarB] bar //~ WARNING `[BarB]` cannot be resolved
* baz
*/
pub fn b() {}

/** Foo
bar [BarC] bar
bar [BarC] bar //~ WARNING `[BarC]` cannot be resolved
baz
let bar_c_1 = 0;
Expand All @@ -35,43 +42,43 @@ baz
*/
pub fn c() {}

#[doc = "Foo\nbar [BarD] bar\nbaz"]
#[doc = "Foo\nbar [BarD] bar\nbaz"] //~ WARNING `[BarD]` cannot be resolved
pub fn d() {}

macro_rules! f {
($f:expr) => {
#[doc = $f]
#[doc = $f] //~ WARNING `[BarF]` cannot be resolved
pub fn f() {}
}
}
f!("Foo\nbar [BarF] bar\nbaz");

/** # for example,
*
* time to introduce a link [error]*/
* time to introduce a link [error]*/ //~ WARNING `[error]` cannot be resolved
pub struct A;

/**
* # for example,
*
* time to introduce a link [error]
* time to introduce a link [error] //~ WARNING `[error]` cannot be resolved
*/
pub struct B;

#[doc = "single line [error]"]
#[doc = "single line [error]"] //~ WARNING `[error]` cannot be resolved
pub struct C;

#[doc = "single line with \"escaping\" [error]"]
#[doc = "single line with \"escaping\" [error]"] //~ WARNING `[error]` cannot be resolved
pub struct D;

/// Item docs.
/// Item docs. //~ WARNING `[error]` cannot be resolved
#[doc="Hello there!"]
/// [error]
pub struct E;

///
/// docs [error1]
/// docs [error1] //~ WARNING `[error1]` cannot be resolved
/// docs [error2]
/// docs [error2] //~ WARNING `[error2]` cannot be resolved
///
pub struct F;
34 changes: 17 additions & 17 deletions src/test/rustdoc-ui/intra-links-warning.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,63 +16,63 @@ LL | //! Test with [Foo::baz], [Bar::foo], ...
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

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].
| ^^^^^^^^^^ cannot be resolved, ignoring
|
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

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].
| ^^^^^^ cannot be resolved, ignoring
|
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

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].
| ^^^^^^^^^^ cannot be resolved, ignoring
|
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

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].
| ^^^^^^ cannot be resolved, ignoring
|
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

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]
| ^^^^^ cannot be resolved, ignoring
|
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

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]*/
| ^^^^^ cannot be resolved, ignoring
|
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

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]
| ^^^^^ cannot be resolved, ignoring
|
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

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]"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -84,7 +84,7 @@ LL | #[doc = "single line [error]"]
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

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]"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -96,7 +96,7 @@ LL | #[doc = "single line with \"escaping\" [error]"]
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

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 | | #[doc="Hello there!"]
Expand All @@ -110,47 +110,47 @@ LL | | /// [error]
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

warning: `[error1]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:73:11
--> $DIR/intra-links-warning.rs:80:11
|
LL | /// docs [error1]
| ^^^^^^ cannot be resolved, ignoring
|
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

warning: `[error2]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:75:11
--> $DIR/intra-links-warning.rs:82:11
|
LL | /// docs [error2]
| ^^^^^^ cannot be resolved, ignoring
|
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

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
| ^^^^ cannot be resolved, ignoring
|
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

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
| ^^^^ cannot be resolved, ignoring
|
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

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
| ^^^^ cannot be resolved, ignoring
|
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

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"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -162,7 +162,7 @@ LL | #[doc = "Foo\nbar [BarD] bar\nbaz"]
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]`

warning: `[BarF]` cannot be resolved, ignoring it...
--> $DIR/intra-links-warning.rs:43:9
--> $DIR/intra-links-warning.rs:50:9
|
LL | #[doc = $f]
| ^^^^^^^^^^^
Expand Down
13 changes: 12 additions & 1 deletion src/test/rustdoc-ui/invalid-syntax.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// build-pass (FIXME(62277): could be check-pass?)
// build-pass

/// ```
/// \__________pkt->size___________/ \_result->size_/ \__pkt->size__/
/// ```
pub fn foo() {}
//~^^^^ WARNING could not parse code block as Rust code

/// ```
/// |
/// LL | use foobar::Baz;
/// | ^^^^^^ did you mean `baz::foobar`?
/// ```
pub fn bar() {}
//~^^^^^^ WARNING could not parse code block as Rust code

/// ```
/// valid
Expand All @@ -24,6 +26,7 @@ pub fn bar() {}
/// "invalid
/// ```
pub fn valid_and_invalid() {}
//~^^^^^^^^ WARNING could not parse code block as Rust code

/// This is a normal doc comment, but...
///
Expand All @@ -35,6 +38,7 @@ pub fn valid_and_invalid() {}
///
/// Good thing we tested it!
pub fn baz() {}
//~^^^^^^ WARNING could not parse code block as Rust code

/// Indented block start
///
Expand All @@ -43,6 +47,7 @@ pub fn baz() {}
///
/// Indented block end
pub fn quux() {}
//~^^^^^ could not parse code block as Rust code

/// Unclosed fence
///
Expand All @@ -54,26 +59,31 @@ pub fn xyzzy() {}
///
/// ```
pub fn blah() {}
//~^^ WARNING could not parse code block as Rust code

/// ```edition2018
/// \_
/// ```
pub fn blargh() {}
//~^^^^ WARNING could not parse code block as Rust code

#[doc = "```"]
/// \_
#[doc = "```"]
pub fn crazy_attrs() {}
//~^^^^ WARNING doc comment contains an invalid Rust code block

/// ```rust
/// ```
pub fn empty_rust() {}
//~^^^ WARNING Rust code block is empty

/// ```
///
///
/// ```
pub fn empty_rust_with_whitespace() {}
//~^^^^^ WARNING Rust code block is empty

/// ```
/// let x = 1;
Expand All @@ -82,3 +92,4 @@ pub fn empty_rust_with_whitespace() {}
/// \____/
///
pub fn indent_after_fenced() {}
//~^^^ WARNING could not parse code block as Rust code
Loading

0 comments on commit 9248b01

Please sign in to comment.