Skip to content

Commit

Permalink
Also change PhantomData parameter of iter::Empty, and future::Pending
Browse files Browse the repository at this point in the history
  • Loading branch information
steffahn committed Jan 7, 2022
1 parent a043acd commit 731bbae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
5 changes: 1 addition & 4 deletions library/core/src/future/pending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::task::{Context, Poll};
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct Pending<T> {
_data: marker::PhantomData<T>,
_data: marker::PhantomData<fn() -> T>,
}

/// Creates a future which never resolves, representing a computation that never
Expand Down Expand Up @@ -43,9 +43,6 @@ impl<T> Future for Pending<T> {
}
}

#[stable(feature = "future_readiness_fns", since = "1.48.0")]
impl<T> Unpin for Pending<T> {}

#[stable(feature = "future_readiness_fns", since = "1.48.0")]
impl<T> Debug for Pending<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down
12 changes: 6 additions & 6 deletions library/core/src/iter/sources/empty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ pub const fn empty<T>() -> Empty<T> {
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<T>()` above.
struct FnReturning<T>(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<T>(marker::PhantomData<T>);

#[stable(feature = "iter_empty_send_sync", since = "1.42.0")]
unsafe impl<T> Send for Empty<T> {}
#[stable(feature = "iter_empty_send_sync", since = "1.42.0")]
unsafe impl<T> Sync for Empty<T> {}
pub struct Empty<T>(marker::PhantomData<FnReturning<T>>);

#[stable(feature = "core_impl_debug", since = "1.9.0")]
impl<T> fmt::Debug for Empty<T> {
Expand Down

0 comments on commit 731bbae

Please sign in to comment.