`description` has been documented as soft-deprecated since 1.27.0 (17 months ago). There is no longer any reason to call it or implement it. This commit: - adds #[rustc_deprecated(since = "1.41.0")] to Error::description; - moves description (and cause, which is also deprecated) below the source and backtrace methods in the Error trait; - reduces documentation of description and cause to take up much less vertical real estate in rustdocs, while preserving the example that shows how to render errors without needing to call description; - removes the description function of all *currently unstable* Error impls in the standard library; - marks #[allow(deprecated)] the description function of all *stable* Error impls in the standard library; - replaces miscellaneous uses of description in example code and the compiler.
26 lines
786 B
Rust
26 lines
786 B
Rust
/// Used as a return value to signify a fatal error occurred. (It is also
|
|
/// used as the argument to panic at the moment, but that will eventually
|
|
/// not be true.)
|
|
#[derive(Copy, Clone, Debug)]
|
|
#[must_use]
|
|
pub struct FatalError;
|
|
|
|
pub struct FatalErrorMarker;
|
|
|
|
// Don't implement Send on FatalError. This makes it impossible to panic!(FatalError).
|
|
// We don't want to invoke the panic handler and print a backtrace for fatal errors.
|
|
impl !Send for FatalError {}
|
|
|
|
impl FatalError {
|
|
pub fn raise(self) -> ! {
|
|
std::panic::resume_unwind(Box::new(FatalErrorMarker))
|
|
}
|
|
}
|
|
|
|
impl std::fmt::Display for FatalError {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
write!(f, "parser fatal error")
|
|
}
|
|
}
|
|
|
|
impl std::error::Error for FatalError {}
|