From a043acd0b2cb9cb510cdeb040c0ce881af376142 Mon Sep 17 00:00:00 2001 From: Frank Steffahn Date: Fri, 7 Jan 2022 00:39:48 +0100 Subject: [PATCH 1/2] change PhantomData type for BuildHasherDefault --- library/core/src/hash/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/hash/mod.rs b/library/core/src/hash/mod.rs index 3ff84cc9672..53de8b42c05 100644 --- a/library/core/src/hash/mod.rs +++ b/library/core/src/hash/mod.rs @@ -602,7 +602,7 @@ fn hash_one(&self, x: T) -> u64 /// [`HashSet`]: ../../std/collections/struct.HashSet.html /// [zero-sized]: https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts #[stable(since = "1.7.0", feature = "build_hasher")] -pub struct BuildHasherDefault(marker::PhantomData); +pub struct BuildHasherDefault(marker::PhantomData H>); #[stable(since = "1.9.0", feature = "core_impl_debug")] impl fmt::Debug for BuildHasherDefault { From 731bbae816e49cb404f402e8a5d392059e417ee5 Mon Sep 17 00:00:00 2001 From: Frank Steffahn Date: Fri, 7 Jan 2022 01:52:42 +0100 Subject: [PATCH 2/2] Also change PhantomData parameter of iter::Empty, and future::Pending --- library/core/src/future/pending.rs | 5 +---- library/core/src/iter/sources/empty.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/library/core/src/future/pending.rs b/library/core/src/future/pending.rs index 560dd25ecff..2877e66eca8 100644 --- a/library/core/src/future/pending.rs +++ b/library/core/src/future/pending.rs @@ -12,7 +12,7 @@ #[stable(feature = "future_readiness_fns", since = "1.48.0")] #[must_use = "futures do nothing unless you `.await` or poll them"] pub struct Pending { - _data: marker::PhantomData, + _data: marker::PhantomData T>, } /// Creates a future which never resolves, representing a computation that never @@ -43,9 +43,6 @@ fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll { } } -#[stable(feature = "future_readiness_fns", since = "1.48.0")] -impl Unpin for Pending {} - #[stable(feature = "future_readiness_fns", since = "1.48.0")] impl Debug for Pending { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/library/core/src/iter/sources/empty.rs b/library/core/src/iter/sources/empty.rs index 7abe01d17c9..98734c527f2 100644 --- a/library/core/src/iter/sources/empty.rs +++ b/library/core/src/iter/sources/empty.rs @@ -22,17 +22,17 @@ pub const fn empty() -> Empty { Empty(marker::PhantomData) } +// Newtype for use in `PhantomData` to avoid +// > error: const-stable function cannot use `#[feature(const_fn_fn_ptr_basics)]` +// in `const fn empty()` above. +struct FnReturning(fn() -> T); + /// An iterator that yields nothing. /// /// This `struct` is created by the [`empty()`] function. See its documentation for more. #[must_use = "iterators are lazy and do nothing unless consumed"] #[stable(feature = "iter_empty", since = "1.2.0")] -pub struct Empty(marker::PhantomData); - -#[stable(feature = "iter_empty_send_sync", since = "1.42.0")] -unsafe impl Send for Empty {} -#[stable(feature = "iter_empty_send_sync", since = "1.42.0")] -unsafe impl Sync for Empty {} +pub struct Empty(marker::PhantomData>); #[stable(feature = "core_impl_debug", since = "1.9.0")] impl fmt::Debug for Empty {