Skip to content

Commit 42b2318

Browse files
Update std doctests
1 parent 63efcd4 commit 42b2318

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

library/std/src/error.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ use crate::fmt::{self, Write};
123123
/// the `Debug` output means `Report` is an ideal starting place for formatting errors returned
124124
/// from `main`.
125125
///
126-
/// ```should_panic
126+
/// ```
127127
/// #![feature(error_reporter)]
128128
/// use std::error::Report;
129129
/// # use std::error::Error;
@@ -154,10 +154,14 @@ use crate::fmt::{self, Write};
154154
/// # Err(SuperError { source: SuperErrorSideKick })
155155
/// # }
156156
///
157-
/// fn main() -> Result<(), Report<SuperError>> {
157+
/// fn run() -> Result<(), Report<SuperError>> { {
158158
/// get_super_error()?;
159159
/// Ok(())
160160
/// }
161+
///
162+
/// fn main() {
163+
/// assert!(run().is_err());
164+
/// }
161165
/// ```
162166
///
163167
/// This example produces the following output:
@@ -170,7 +174,7 @@ use crate::fmt::{self, Write};
170174
/// output format. If you want to make sure your `Report`s are pretty printed and include backtrace
171175
/// you will need to manually convert and enable those flags.
172176
///
173-
/// ```should_panic
177+
/// ```
174178
/// #![feature(error_reporter)]
175179
/// use std::error::Report;
176180
/// # use std::error::Error;
@@ -201,12 +205,16 @@ use crate::fmt::{self, Write};
201205
/// # Err(SuperError { source: SuperErrorSideKick })
202206
/// # }
203207
///
204-
/// fn main() -> Result<(), Report<SuperError>> {
208+
/// fn run() -> Result<(), Report<SuperError>> {
205209
/// get_super_error()
206210
/// .map_err(Report::from)
207211
/// .map_err(|r| r.pretty(true).show_backtrace(true))?;
208212
/// Ok(())
209213
/// }
214+
///
215+
/// fn main() {
216+
/// assert!(run().is_err());
217+
/// }
210218
/// ```
211219
///
212220
/// This example produces the following output:

tests/rustdoc-ui/doctest/failed-doctest-should-panic-2021.stdout

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ test $DIR/failed-doctest-should-panic-2021.rs - Foo (line 10) ... FAILED
55
failures:
66

77
---- $DIR/failed-doctest-should-panic-2021.rs - Foo (line 10) stdout ----
8-
Test executable succeeded, but it's marked `should_panic`.
8+
Test didn't panic, but it's marked `should_panic`.
99

1010
failures:
1111
$DIR/failed-doctest-should-panic-2021.rs - Foo (line 10)

tests/rustdoc-ui/doctest/failed-doctest-should-panic.stdout

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11

22
running 1 test
3-
test $DIR/failed-doctest-should-panic.rs - Foo (line 10) - should panic ... FAILED
3+
test $DIR/failed-doctest-should-panic.rs - Foo (line 10) ... FAILED
44

55
failures:
66

77
---- $DIR/failed-doctest-should-panic.rs - Foo (line 10) stdout ----
8-
note: test did not panic as expected at $DIR/failed-doctest-should-panic.rs:10:0
8+
Test didn't panic, but it's marked `should_panic`.
9+
910

1011
failures:
1112
$DIR/failed-doctest-should-panic.rs - Foo (line 10)

tests/rustdoc-ui/doctest/wrong-ast-2024.stdout

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
running 1 test
3-
test $DIR/wrong-ast-2024.rs - three (line 18) - should panic ... ok
3+
test $DIR/wrong-ast-2024.rs - three (line 18) ... ok
44

55
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
66

0 commit comments

Comments
 (0)