Skip to content

Commit a927c83

Browse files
authored
Rollup merge of rust-lang#65366 - faern:source-on-intostringerror, r=bluss
Implement Error::source on IntoStringError + Remove superfluous cause impls IntoStringError only implemented `Error::cause`, which is deprecated. This implemements `Error::source` instead. `Error::cause` will still work as before, thanks to the default implementation. I think this was the only/last `Error` impl in the standard library to have a cause, but not a source.
2 parents fad7ed0 + b8e7f76 commit a927c83

File tree

2 files changed

+1
-21
lines changed

2 files changed

+1
-21
lines changed

src/libstd/ffi/c_str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ impl Error for IntoStringError {
919919
"C string contained non-utf8 bytes"
920920
}
921921

922-
fn cause(&self) -> Option<&dyn Error> {
922+
fn source(&self) -> Option<&(dyn Error + 'static)> {
923923
Some(&self.error)
924924
}
925925
}

src/libstd/sync/mpsc/mod.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,10 +1581,6 @@ impl<T: Send> error::Error for SendError<T> {
15811581
fn description(&self) -> &str {
15821582
"sending on a closed channel"
15831583
}
1584-
1585-
fn cause(&self) -> Option<&dyn error::Error> {
1586-
None
1587-
}
15881584
}
15891585

15901586
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1624,10 +1620,6 @@ impl<T: Send> error::Error for TrySendError<T> {
16241620
}
16251621
}
16261622
}
1627-
1628-
fn cause(&self) -> Option<&dyn error::Error> {
1629-
None
1630-
}
16311623
}
16321624

16331625
#[stable(feature = "mpsc_error_conversions", since = "1.24.0")]
@@ -1652,10 +1644,6 @@ impl error::Error for RecvError {
16521644
fn description(&self) -> &str {
16531645
"receiving on a closed channel"
16541646
}
1655-
1656-
fn cause(&self) -> Option<&dyn error::Error> {
1657-
None
1658-
}
16591647
}
16601648

16611649
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1685,10 +1673,6 @@ impl error::Error for TryRecvError {
16851673
}
16861674
}
16871675
}
1688-
1689-
fn cause(&self) -> Option<&dyn error::Error> {
1690-
None
1691-
}
16921676
}
16931677

16941678
#[stable(feature = "mpsc_error_conversions", since = "1.24.0")]
@@ -1726,10 +1710,6 @@ impl error::Error for RecvTimeoutError {
17261710
}
17271711
}
17281712
}
1729-
1730-
fn cause(&self) -> Option<&dyn error::Error> {
1731-
None
1732-
}
17331713
}
17341714

17351715
#[stable(feature = "mpsc_error_conversions", since = "1.24.0")]

0 commit comments

Comments
 (0)