Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update std doctests
  • Loading branch information
GuillaumeGomez committed Jul 7, 2025
commit 9d565a30818ff209fcfc3fc5a2a59dd1764df6c6
16 changes: 12 additions & 4 deletions library/std/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ use crate::fmt::{self, Write};
/// the `Debug` output means `Report` is an ideal starting place for formatting errors returned
/// from `main`.
///
/// ```should_panic
/// ```
/// #![feature(error_reporter)]
/// use std::error::Report;
/// # use std::error::Error;
Expand Down Expand Up @@ -154,10 +154,14 @@ use crate::fmt::{self, Write};
/// # Err(SuperError { source: SuperErrorSideKick })
/// # }
///
/// fn main() -> Result<(), Report<SuperError>> {
/// fn run() -> Result<(), Report<SuperError>> {
/// get_super_error()?;
/// Ok(())
/// }
///
/// fn main() {
/// assert!(run().is_err());
/// }
/// ```
///
/// This example produces the following output:
Expand All @@ -170,7 +174,7 @@ use crate::fmt::{self, Write};
/// output format. If you want to make sure your `Report`s are pretty printed and include backtrace
/// you will need to manually convert and enable those flags.
///
/// ```should_panic
/// ```
/// #![feature(error_reporter)]
/// use std::error::Report;
/// # use std::error::Error;
Expand Down Expand Up @@ -201,12 +205,16 @@ use crate::fmt::{self, Write};
/// # Err(SuperError { source: SuperErrorSideKick })
/// # }
///
/// fn main() -> Result<(), Report<SuperError>> {
/// fn run() -> Result<(), Report<SuperError>> {
/// get_super_error()
/// .map_err(Report::from)
/// .map_err(|r| r.pretty(true).show_backtrace(true))?;
/// Ok(())
/// }
///
/// fn main() {
/// assert!(run().is_err());
/// }
/// ```
///
/// This example produces the following output:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test $DIR/failed-doctest-should-panic-2021.rs - Foo (line 10) ... FAILED
failures:

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

failures:
$DIR/failed-doctest-should-panic-2021.rs - Foo (line 10)
Expand Down
5 changes: 3 additions & 2 deletions tests/rustdoc-ui/doctest/failed-doctest-should-panic.stdout
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

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

failures:

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


failures:
$DIR/failed-doctest-should-panic.rs - Foo (line 10)
Expand Down
2 changes: 1 addition & 1 deletion tests/rustdoc-ui/doctest/wrong-ast-2024.stdout
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

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

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

Expand Down
Loading