]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/error.rs
Rollup merge of #91938 - yaahc:error-reporter, r=m-ou-se
[rust.git] / library / std / src / error.rs
index 5514876c5d3b8c7127a7e550b791696fd4e583fd..643108b88bf79da58131bacff61a3a67e616285b 100644 (file)
@@ -478,6 +478,9 @@ fn description(&self) -> &str {
     }
 }
 
+#[stable(feature = "u8_from_char", since = "1.59.0")]
+impl Error for char::TryFromCharError {}
+
 #[unstable(feature = "map_try_insert", issue = "82766")]
 impl<'a, K: Debug + Ord, V: Debug> Error
     for crate::collections::btree_map::OccupiedError<'a, K, V>
@@ -603,21 +606,21 @@ impl Error for time::FromSecsError {}
 
 // Copied from `any.rs`.
 impl dyn Error + 'static {
-    /// Returns `true` if the boxed type is the same as `T`
+    /// Returns `true` if the inner type is the same as `T`.
     #[stable(feature = "error_downcast", since = "1.3.0")]
     #[inline]
     pub fn is<T: Error + 'static>(&self) -> bool {
         // Get `TypeId` of the type this function is instantiated with.
         let t = TypeId::of::<T>();
 
-        // Get `TypeId` of the type in the trait object.
-        let boxed = self.type_id(private::Internal);
+        // Get `TypeId` of the type in the trait object (`self`).
+        let concrete = self.type_id(private::Internal);
 
         // Compare both `TypeId`s on equality.
-        t == boxed
+        t == concrete
     }
 
-    /// Returns some reference to the boxed value if it is of type `T`, or
+    /// Returns some reference to the inner value if it is of type `T`, or
     /// `None` if it isn't.
     #[stable(feature = "error_downcast", since = "1.3.0")]
     #[inline]
@@ -629,7 +632,7 @@ pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T> {
         }
     }
 
-    /// Returns some mutable reference to the boxed value if it is of type `T`, or
+    /// Returns some mutable reference to the inner value if it is of type `T`, or
     /// `None` if it isn't.
     #[stable(feature = "error_downcast", since = "1.3.0")]
     #[inline]
@@ -1284,9 +1287,7 @@ fn fmt_multiline(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 
             for (ind, error) in cause.chain().enumerate() {
                 writeln!(f)?;
-                let mut indented = Indented {
-                    inner: f,
-                };
+                let mut indented = Indented { inner: f };
                 if multiple {
                     write!(indented, "{: >4}: {}", ind, error)?;
                 } else {
@@ -1310,8 +1311,7 @@ fn fmt_multiline(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
     }
 }
 
-impl Report<Box<dyn Error>>
-{
+impl Report<Box<dyn Error>> {
     fn backtrace(&self) -> Option<&Backtrace> {
         // have to grab the backtrace on the first error directly since that error may not be
         // 'static
@@ -1353,9 +1353,7 @@ fn fmt_multiline(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 
             for (ind, error) in cause.chain().enumerate() {
                 writeln!(f)?;
-                let mut indented = Indented {
-                    inner: f,
-                };
+                let mut indented = Indented { inner: f };
                 if multiple {
                     write!(indented, "{: >4}: {}", ind, error)?;
                 } else {
@@ -1411,8 +1409,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 }
 
 #[unstable(feature = "error_reporter", issue = "90172")]
-impl fmt::Display for Report<Box<dyn Error>>
-{
+impl fmt::Display for Report<Box<dyn Error>> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         if self.pretty { self.fmt_multiline(f) } else { self.fmt_singleline(f) }
     }