forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#134260 - GuillaumeGomez:doctest-attrs, r=no…
…triddle Correctly handle comments in attributes in doctests source code Fixes rust-lang#134221. The problem was that attributes are "inlined" (backlines are stripped), then when there is an inline comment inside it, the attribute is never considered valid (since unclosed). Fix was to simply put back backlines in case it's a multiline attribute. r? ```@notriddle```
- Loading branch information
Showing
5 changed files
with
165 additions
and
18 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,15 @@ | ||
//@ compile-flags:--test --test-args --test-threads=1 | ||
//@ failure-status: 101 | ||
//@ normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" | ||
//@ normalize-stdout-test: "finished in \d+\.\d+s" -> "finished in $$TIME" | ||
//@ normalize-stdout-test: ".rs:\d+:\d+" -> ".rs:$$LINE:$$COL" | ||
|
||
//! ``` | ||
#![doc = "#![all\ | ||
ow(unused)]"] | ||
//! ``` | ||
//! | ||
//! ``` | ||
#![doc = r#"#![all\ | ||
ow(unused)]"#] | ||
//! ``` |
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,31 @@ | ||
|
||
running 2 tests | ||
test $DIR/comment-in-attr-134221-2.rs - (line 11) ... FAILED | ||
test $DIR/comment-in-attr-134221-2.rs - (line 7) ... ok | ||
|
||
failures: | ||
|
||
---- $DIR/comment-in-attr-134221-2.rs - (line 11) stdout ---- | ||
error: unknown start of token: \ | ||
--> $DIR/comment-in-attr-134221-2.rs:$LINE:$COL | ||
| | ||
LL | #![all\ | ||
| ^ | ||
|
||
error: expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `ow` | ||
--> $DIR/comment-in-attr-134221-2.rs:$LINE:$COL | ||
| | ||
LL | #![all\ | ||
| - expected one of `(`, `::`, `=`, `[`, `]`, or `{` | ||
LL | ow(unused)] | ||
| ^^ unexpected token | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Couldn't compile the test. | ||
|
||
failures: | ||
$DIR/comment-in-attr-134221-2.rs - (line 11) | ||
|
||
test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME | ||
|
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,27 @@ | ||
// Regression test for <https://github.com/rust-lang/rust/issues/134221>. | ||
// It checks that even if there are comments in the attributes, the attributes | ||
// will still be generated correctly (and therefore fail in this test). | ||
|
||
//@ compile-flags:--test --test-args --test-threads=1 | ||
//@ failure-status: 101 | ||
//@ normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR" | ||
//@ normalize-stdout-test: "finished in \d+\.\d+s" -> "finished in $$TIME" | ||
//@ normalize-stdout-test: ".rs:\d+:\d+" -> ".rs:$$LINE:$$COL" | ||
|
||
/*! | ||
```rust | ||
#![feature( | ||
foo, // | ||
)] | ||
``` | ||
```rust | ||
#![feature( | ||
foo, | ||
)] | ||
``` | ||
```rust | ||
#![ | ||
``` | ||
*/ |
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,50 @@ | ||
|
||
running 3 tests | ||
test $DIR/comment-in-attr-134221.rs - (line 11) ... FAILED | ||
test $DIR/comment-in-attr-134221.rs - (line 17) ... FAILED | ||
test $DIR/comment-in-attr-134221.rs - (line 23) ... FAILED | ||
|
||
failures: | ||
|
||
---- $DIR/comment-in-attr-134221.rs - (line 11) stdout ---- | ||
error[E0635]: unknown feature `foo` | ||
--> $DIR/comment-in-attr-134221.rs:$LINE:$COL | ||
| | ||
LL | foo, // | ||
| ^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0635`. | ||
Couldn't compile the test. | ||
---- $DIR/comment-in-attr-134221.rs - (line 17) stdout ---- | ||
error[E0635]: unknown feature `foo` | ||
--> $DIR/comment-in-attr-134221.rs:$LINE:$COL | ||
| | ||
LL | foo, | ||
| ^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0635`. | ||
Couldn't compile the test. | ||
---- $DIR/comment-in-attr-134221.rs - (line 23) stdout ---- | ||
error: this file contains an unclosed delimiter | ||
--> $DIR/comment-in-attr-134221.rs:$LINE:$COL | ||
| | ||
LL | #![ | ||
| -^ | ||
| | | ||
| unclosed delimiter | ||
|
||
error: aborting due to 1 previous error | ||
|
||
Couldn't compile the test. | ||
|
||
failures: | ||
$DIR/comment-in-attr-134221.rs - (line 11) | ||
$DIR/comment-in-attr-134221.rs - (line 17) | ||
$DIR/comment-in-attr-134221.rs - (line 23) | ||
|
||
test result: FAILED. 0 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME | ||
|