Skip to content

Commit 4614711

Browse files
committed
Auto merge of #97442 - hafeoz:master, r=GuillaumeGomez
Fix multiline attributes processing in doctest Fixes #97440. It seems like the call to `check_if_attr_is_complete` is not provided with the correct argument: the pending attribute should be passed, while the current line is actually being passed. This causes any attribute with more than 2 lines to fail and produces ICE when running through doctest.
2 parents f558990 + c3beb03 commit 4614711

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/librustdoc/doctest.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,9 @@ fn partition_source(s: &str, edition: Edition) -> (String, String, String) {
795795
// If not, then we append the new line into the pending attribute to check
796796
// if this time it's complete...
797797
mod_attr_pending.push_str(line);
798-
if !trimline.is_empty() && check_if_attr_is_complete(line, edition) {
798+
if !trimline.is_empty()
799+
&& check_if_attr_is_complete(&mod_attr_pending, edition)
800+
{
799801
// If it's complete, then we can clear the pending content.
800802
mod_attr_pending.clear();
801803
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Regression test for #97440: Multiline inner attribute triggers ICE during doctest
2+
// compile-flags:--test
3+
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR"
4+
// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
5+
// check-pass
6+
7+
//! ```rust
8+
//! #![deny(
9+
//! unused_parens,
10+
//! )]
11+
//! ```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
running 1 test
3+
test $DIR/doc-comment-multi-line-attr.rs - (line 7) ... ok
4+
5+
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
6+

0 commit comments

Comments
 (0)