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 | |
| 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')
| -rw-r--r-- | src/libstd/env.rs | 2 | ||||
| -rw-r--r-- | src/libstd/error.rs | 34 | ||||
| -rw-r--r-- | src/libstd/ffi/c_str.rs | 2 | ||||
| -rw-r--r-- | src/libstd/process.rs | 2 |
4 files changed, 20 insertions, 20 deletions
diff --git a/src/libstd/env.rs b/src/libstd/env.rs index eca93399e58..b8989369269 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -290,7 +290,7 @@ impl Error for VarError { /// /// Note that while concurrent access to environment variables is safe in Rust, /// some platforms only expose inherently unsafe non-threadsafe APIs for -/// inspecting the environment. As a result extra care needs to be taken when +/// inspecting the environment. As a result, extra care needs to be taken when /// auditing calls to unsafe external FFI functions to ensure that any external /// environment accesses are properly synchronized with accesses in Rust. /// 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) }) } diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index bb346fb4db5..d7f4cc5d1fd 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -615,7 +615,7 @@ impl CString { } // Turns this `CString` into an empty string to prevent -// memory unsafe code from working by accident. Inline +// memory-unsafe code from working by accident. Inline // to prevent LLVM from optimizing it away in debug builds. #[stable(feature = "cstring_drop", since = "1.13.0")] impl Drop for CString { diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 000f80f99e7..c50025ab7d1 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -1595,7 +1595,7 @@ pub fn id() -> u32 { /// A trait for implementing arbitrary return types in the `main` function. /// -/// The c-main function only supports to return integers as return type. +/// The C-main function only supports to return integers as return type. /// So, every type implementing the `Termination` trait has to be converted /// to an integer. /// |
