If there is a ; alone, we consider that the doctest needs to be put inside a function
(cherry picked from commit 3ef98a55ef)
This commit is contained in:
parent
692490898b
commit
c44a1d7c45
3 changed files with 4 additions and 29 deletions
|
|
@ -448,8 +448,6 @@ fn parse_source(source: &str, crate_name: &Option<&str>) -> Result<ParseSourceIn
|
|||
}
|
||||
}
|
||||
}
|
||||
// We do nothing in this case. Not marking it as `non_module_items` either.
|
||||
StmtKind::Empty => {}
|
||||
_ => {
|
||||
has_non_items = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@
|
|||
//@ compile-flags:--test
|
||||
//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR"
|
||||
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
|
||||
//@ failure-status: 101
|
||||
//@ check-pass
|
||||
|
||||
/// <https://github.com/rust-lang/rust/issues/91014>
|
||||
///
|
||||
/// ```rust
|
||||
/// struct S {}; // unexpected semicolon after struct def
|
||||
/// struct S {};
|
||||
///
|
||||
/// fn main() {
|
||||
/// assert_eq!(0, 1);
|
||||
|
|
|
|||
|
|
@ -1,29 +1,6 @@
|
|||
|
||||
running 1 test
|
||||
test $DIR/failed-doctest-extra-semicolon-on-item.rs - m (line 11) ... FAILED
|
||||
test $DIR/failed-doctest-extra-semicolon-on-item.rs - m (line 11) ... ok
|
||||
|
||||
failures:
|
||||
|
||||
---- $DIR/failed-doctest-extra-semicolon-on-item.rs - m (line 11) stdout ----
|
||||
error: expected item, found `;`
|
||||
--> $DIR/failed-doctest-extra-semicolon-on-item.rs:12:12
|
||||
|
|
||||
LL | struct S {}; // unexpected semicolon after struct def
|
||||
| ^
|
||||
|
|
||||
= help: braced struct declarations are not followed by a semicolon
|
||||
help: remove this semicolon
|
||||
|
|
||||
LL - struct S {}; // unexpected semicolon after struct def
|
||||
LL + struct S {} // unexpected semicolon after struct def
|
||||
|
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
Couldn't compile the test.
|
||||
|
||||
failures:
|
||||
$DIR/failed-doctest-extra-semicolon-on-item.rs - m (line 11)
|
||||
|
||||
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
|
||||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue