diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-09-14 16:42:22 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-14 16:42:22 +0200 |
| commit | afc52916f658e7b5dc102ef7cd5b2784cd15c4e3 (patch) | |
| tree | 2cc0ee0da68aa5d26053b787ee42b11671fa490c /src/libstd/error.rs | |
| parent | 45baedb14b94ee26c70439e244b73ab3090a4d13 (diff) | |
| parent | 58a26c8fc0200c29bd753cf6fcfd80ee34a98920 (diff) | |
| download | rust-afc52916f658e7b5dc102ef7cd5b2784cd15c4e3.tar.gz rust-afc52916f658e7b5dc102ef7cd5b2784cd15c4e3.zip | |
Rollup merge of #64203 - alexreg:rush-pr-2, r=centril
A few cosmetic improvements to code & comments in liballoc and libcore Factored out from hacking on rustc for work on the REPL. r? @Centril
Diffstat (limited to 'src/libstd/error.rs')
| -rw-r--r-- | src/libstd/error.rs | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 998d59f90a2..4a1bb75d588 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -197,10 +197,10 @@ pub trait Error: Debug + Display { #[stable(feature = "error_source", since = "1.30.0")] fn source(&self) -> Option<&(dyn Error + 'static)> { None } - /// Gets the `TypeId` of `self` + /// Gets the `TypeId` of `self`. #[doc(hidden)] #[unstable(feature = "error_type_id", - reason = "this is memory unsafe to override in user code", + reason = "this is memory-unsafe to override in user code", issue = "60784")] fn type_id(&self, _: private::Internal) -> TypeId where Self: 'static { TypeId::of::<Self>() @@ -616,19 +616,19 @@ impl Error for char::ParseCharError { } } -// copied from any.rs +// Copied from `any.rs`. impl dyn Error + 'static { /// Returns `true` if the boxed 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 + // Get `TypeId` of the type this function is instantiated with. let t = TypeId::of::<T>(); - // Get TypeId of the type in the trait object + // Get `TypeId` of the type in the trait object. let boxed = self.type_id(private::Internal); - // Compare both TypeIds on equality + // Compare both `TypeId`s on equality. t == boxed } @@ -662,21 +662,21 @@ impl dyn Error + 'static { } impl dyn Error + 'static + Send { - /// Forwards to the method defined on the type `Any`. + /// Forwards to the method defined on the type `dyn Error`. #[stable(feature = "error_downcast", since = "1.3.0")] #[inline] pub fn is<T: Error + 'static>(&self) -> bool { <dyn Error + 'static>::is::<T>(self) } - /// Forwards to the method defined on the type `Any`. + /// Forwards to the method defined on the type `dyn Error`. #[stable(feature = "error_downcast", since = "1.3.0")] #[inline] pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T> { <dyn Error + 'static>::downcast_ref::<T>(self) } - /// Forwards to the method defined on the type `Any`. + /// Forwards to the method defined on the type `dyn Error`. #[stable(feature = "error_downcast", since = "1.3.0")] #[inline] pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T> { @@ -685,21 +685,21 @@ impl dyn Error + 'static + Send { } impl dyn Error + 'static + Send + Sync { - /// Forwards to the method defined on the type `Any`. + /// Forwards to the method defined on the type `dyn Error`. #[stable(feature = "error_downcast", since = "1.3.0")] #[inline] pub fn is<T: Error + 'static>(&self) -> bool { <dyn Error + 'static>::is::<T>(self) } - /// Forwards to the method defined on the type `Any`. + /// Forwards to the method defined on the type `dyn Error`. #[stable(feature = "error_downcast", since = "1.3.0")] #[inline] pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T> { <dyn Error + 'static>::downcast_ref::<T>(self) } - /// Forwards to the method defined on the type `Any`. + /// Forwards to the method defined on the type `dyn Error`. #[stable(feature = "error_downcast", since = "1.3.0")] #[inline] pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T> { @@ -710,7 +710,7 @@ impl dyn Error + 'static + Send + Sync { impl dyn Error { #[inline] #[stable(feature = "error_downcast", since = "1.3.0")] - /// Attempt to downcast the box to a concrete type. + /// Attempts to downcast the box to a concrete type. pub fn downcast<T: Error + 'static>(self: Box<Self>) -> Result<Box<T>, Box<dyn Error>> { if self.is::<T>() { unsafe { @@ -878,12 +878,12 @@ impl<'a> Iterator for ErrorIter<'a> { impl dyn Error + Send { #[inline] #[stable(feature = "error_downcast", since = "1.3.0")] - /// Attempt to downcast the box to a concrete type. + /// Attempts to downcast the box to a concrete type. pub fn downcast<T: Error + 'static>(self: Box<Self>) -> Result<Box<T>, Box<dyn Error + Send>> { let err: Box<dyn Error> = self; <dyn Error>::downcast(err).map_err(|s| unsafe { - // reapply the Send marker + // Reapply the `Send` marker. transmute::<Box<dyn Error>, Box<dyn Error + Send>>(s) }) } @@ -892,12 +892,12 @@ impl dyn Error + Send { impl dyn Error + Send + Sync { #[inline] #[stable(feature = "error_downcast", since = "1.3.0")] - /// Attempt to downcast the box to a concrete type. + /// Attempts to downcast the box to a concrete type. pub fn downcast<T: Error + 'static>(self: Box<Self>) -> Result<Box<T>, Box<Self>> { let err: Box<dyn Error> = self; <dyn Error>::downcast(err).map_err(|s| unsafe { - // reapply the Send+Sync marker + // Reapply the `Send + Sync` marker. transmute::<Box<dyn Error>, Box<dyn Error + Send + Sync>>(s) }) } |
