diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2021-06-24 04:16:11 -0400 |
|---|---|---|
| committer | Jacob Pratt <jacob@jhpratt.dev> | 2021-06-24 04:16:11 -0400 |
| commit | 3f14f4b3cec811017079564e16a92a1dc9870f41 (patch) | |
| tree | 6f8c9207dd0c8cefa35d69a7d15ce756772586ca /library/std/src/thread | |
| parent | 6a758ea7e48416b968955535094479dc2e7cc9e1 (diff) | |
| download | rust-3f14f4b3cec811017079564e16a92a1dc9870f41.tar.gz rust-3f14f4b3cec811017079564e16a92a1dc9870f41.zip | |
Use `#[non_exhaustive]` where appropriate
Due to the std/alloc split, it is not possible to make `alloc::collections::TryReserveError::AllocError` non-exhaustive without having an unstable, doc-hidden method to construct (which negates the benefits from `#[non_exhaustive]`.
Diffstat (limited to 'library/std/src/thread')
| -rw-r--r-- | library/std/src/thread/local.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/library/std/src/thread/local.rs b/library/std/src/thread/local.rs index e62f4440b36..c53290ec0c7 100644 --- a/library/std/src/thread/local.rs +++ b/library/std/src/thread/local.rs @@ -324,10 +324,9 @@ macro_rules! __thread_local_inner { /// An error returned by [`LocalKey::try_with`](struct.LocalKey.html#method.try_with). #[stable(feature = "thread_local_try_with", since = "1.26.0")] +#[non_exhaustive] #[derive(Clone, Copy, Eq, PartialEq)] -pub struct AccessError { - _private: (), -} +pub struct AccessError; #[stable(feature = "thread_local_try_with", since = "1.26.0")] impl fmt::Debug for AccessError { @@ -396,7 +395,7 @@ impl<T: 'static> LocalKey<T> { F: FnOnce(&T) -> R, { unsafe { - let thread_local = (self.inner)().ok_or(AccessError { _private: () })?; + let thread_local = (self.inner)().ok_or(AccessError)?; Ok(f(thread_local)) } } |
