about summary refs log tree commit diff
path: root/library/core/src
diff options
context:
space:
mode:
authorStepan Koltsov <stepan.koltsov@gmail.com>2025-09-24 20:02:34 +0100
committerStepan Koltsov <stepan.koltsov@gmail.com>2025-09-24 20:02:35 +0100
commita9554b4d5f2666b0bce66dfb8f70a41092c9265f (patch)
tree9eba02bfb583f2421e044ebff350e98fe0891341 /library/core/src
parent15283f6fe95e5b604273d13a428bab5fc0788f5a (diff)
downloadrust-a9554b4d5f2666b0bce66dfb8f70a41092c9265f.tar.gz
rust-a9554b4d5f2666b0bce66dfb8f70a41092c9265f.zip
Clarify Display for error should not include source
Diffstat (limited to 'library/core/src')
-rw-r--r--library/core/src/error.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/library/core/src/error.rs b/library/core/src/error.rs
index 92b3c83d1bf..9ca91ee009e 100644
--- a/library/core/src/error.rs
+++ b/library/core/src/error.rs
@@ -16,13 +16,19 @@ use crate::fmt::{self, Debug, Display, Formatter};
 /// assert_eq!(err.to_string(), "invalid digit found in string");
 /// ```
 ///
+/// # Error source
+///
 /// Errors may provide cause information. [`Error::source()`] is generally
 /// used when errors cross "abstraction boundaries". If one module must report
 /// an error that is caused by an error from a lower-level module, it can allow
-/// accessing that error via [`Error::source()`]. This makes it possible for the
+/// accessing that error via `Error::source()`. This makes it possible for the
 /// high-level module to provide its own errors while also revealing some of the
 /// implementation for debugging.
 ///
+/// In error types that wrap an underlying error, the underlying error
+/// should be either returned by the outer error's `Error::source()`, or rendered
+/// by the outer error's `Display` implementation, but not both.
+///
 /// # Example
 ///
 /// Implementing the `Error` trait only requires that `Debug` and `Display` are implemented too.