Skip to content

Commit

Permalink
Remove unneeded handling of backlines in doctest attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Dec 16, 2024
1 parent 2383985 commit c367cc3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/librustdoc/doctest/make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,6 @@ fn handle_attr(mod_attr_pending: &mut String, source_info: &mut SourceInfo, edit
push_to.push('\n');
// If it's complete, then we can clear the pending content.
mod_attr_pending.clear();
} else if mod_attr_pending.ends_with('\\') {
mod_attr_pending.push('n');
} else {
mod_attr_pending.push_str("\n");
}
Expand Down
15 changes: 15 additions & 0 deletions tests/rustdoc-ui/doctest/comment-in-attr-134221-2.rs
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)]"#]
//! ```
31 changes: 31 additions & 0 deletions tests/rustdoc-ui/doctest/comment-in-attr-134221-2.stdout
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

0 comments on commit c367cc3

Please sign in to comment.