From 3f14f4b3cec811017079564e16a92a1dc9870f41 Mon Sep 17 00:00:00 2001 From: Jacob Pratt Date: Thu, 24 Jun 2021 04:16:11 -0400 Subject: 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]`. --- library/std/src/thread/local.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'library/std/src/thread') 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 LocalKey { 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)) } } -- cgit 1.4.1-3-g733a5