Skip to content

Commit 3e72d63

Browse files
authored
Unrolled build for #146679
Rollup merge of #146679 - stepancheg:error-display-source, r=dtolnay Clarify Display for error should not include source Fixes #145561. r? `@Noratrieb`
2 parents bbcbc78 + a9554b4 commit 3e72d63

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

library/core/src/error.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,19 @@ use crate::fmt::{self, Debug, Display, Formatter};
1616
/// assert_eq!(err.to_string(), "invalid digit found in string");
1717
/// ```
1818
///
19+
/// # Error source
20+
///
1921
/// Errors may provide cause information. [`Error::source()`] is generally
2022
/// used when errors cross "abstraction boundaries". If one module must report
2123
/// an error that is caused by an error from a lower-level module, it can allow
22-
/// accessing that error via [`Error::source()`]. This makes it possible for the
24+
/// accessing that error via `Error::source()`. This makes it possible for the
2325
/// high-level module to provide its own errors while also revealing some of the
2426
/// implementation for debugging.
2527
///
28+
/// In error types that wrap an underlying error, the underlying error
29+
/// should be either returned by the outer error's `Error::source()`, or rendered
30+
/// by the outer error's `Display` implementation, but not both.
31+
///
2632
/// # Example
2733
///
2834
/// Implementing the `Error` trait only requires that `Debug` and `Display` are implemented too.

0 commit comments

Comments
 (0)