-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustdoc: Fix handling of compile errors when running
rustdoc --test
* Call `abort_if_errors` so all errors actually stop rustdoc. * Don't panic with "compiler aborted in rustdoc!", instead just exit to avoid the ugly panic message. * Use rlib as the crate type when searching for doctests matching what is used for doc generation so `#[no_std]` crates don't create "no global memory allocator" errors.
- Loading branch information
Showing
9 changed files
with
69 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// compile-flags:--test | ||
|
||
/// ``` | ||
/// assert!(true) | ||
/// ``` | ||
pub fn f() {} | ||
|
||
pub fn f() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0428]: the name `f` is defined multiple times | ||
--> $DIR/test-compile-fail1.rs:8:1 | ||
| | ||
6 | pub fn f() {} | ||
| ---------- previous definition of the value `f` here | ||
7 | | ||
8 | pub fn f() {} | ||
| ^^^^^^^^^^ `f` redefined here | ||
| | ||
= note: `f` must be defined only once in the value namespace of this module | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0428`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// compile-flags:--test | ||
|
||
fail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error: expected one of `!` or `::`, found `<eof>` | ||
--> $DIR/test-compile-fail2.rs:3:1 | ||
| | ||
3 | fail | ||
| ^^^^ expected one of `!` or `::` | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// compile-flags:--test | ||
|
||
"fail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error: unterminated double quote string | ||
--> $DIR/test-compile-fail3.rs:3:1 | ||
| | ||
3 | "fail | ||
| ^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// compile-flags:--test | ||
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR" | ||
// build-pass | ||
|
||
#![no_std] | ||
|
||
extern crate alloc; | ||
|
||
/// ``` | ||
/// assert!(true) | ||
/// ``` | ||
pub fn f() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
running 1 test | ||
test $DIR/test-no_std.rs - f (line 9) ... ok | ||
|
||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out | ||
|