Repository: serde-rs/json (language: rust)

Issue:
Same message duplicated between source() and Display of serde_json::Error
```rust
// [dependencies]
// anyhow = "1"
// serde = "1"
// serde_json = "1"

use serde::de::Deserialize;
use std::error::Error;
use std::fmt::{self, Display};
use std::io::{self, Read};

struct Reader;

#[derive(Debug)]
struct MyError;

impl Error for MyError {
    fn source(&self) -> Option<&(dyn Error + 'static)> {
        Some(&std::sync::mpsc::RecvTimeoutError::Timeout)
    }
}

impl Display for MyError {
    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
        formatter.write_str("bad read")
    }
}

impl Read for Reader {
    fn read(&mut self, _: &mut [u8]) -> io::Result<usize> {
        Err(io::Error::new(io::ErrorKind::TimedOut, MyError))
    }
}

fn main() -> anyhow::Result<()> {
    let reader = Reader;
    let mut de = serde_json::Deserializer::from_reader(reader);
    let _ = u8::deserialize(&mut de)?;
    Ok(())
}
```

```console
Error: bad read

Caused by:
    0: bad read
    1: timed out waiting on channel
```

In general, `std::error::Error` impls are not supposed to duplicate the same content between their `Display` and `source()` implementation.


Discussion / hints:

Fix patch:
diff --git a/src/error.rs b/src/error.rs
index 1875ef08b..0898baf90 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -319,7 +319,7 @@ impl serde::de::StdError for Error {
     #[cfg(feature = "std")]
     fn source(&self) -> Option<&(dyn error::Error + 'static)> {
         match &self.err.code {
-            ErrorCode::Io(err) => Some(err),
+            ErrorCode::Io(err) => err.source(),
             _ => None,
         }
     }


Test patch: