mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Rollup merge of #92630 - steffahn:lift_bounds_on_BuildHasherDefault, r=yaahc
Change PhantomData type for `BuildHasherDefault` (and more) Changes `PhantomData<H>` to `PhantomData<fn() -> H>` for `BuildHasherDefault`. This preserves the covariance of `H`, while it lifts the currently inferred unnecessary bounds like [`H: Send` for `BuildHasherDefault<H>: Send`](https://doc.rust-lang.org/1.57.0/std/hash/struct.BuildHasherDefault.html#impl-Send), etc. _Edit:_ Also does a similar change for `iter::Empty` and `future::Pending`.
This commit is contained in:
commit
dfbb6b246d
@ -12,7 +12,7 @@ use crate::task::{Context, Poll};
|
|||||||
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
|
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
|
||||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||||
pub struct Pending<T> {
|
pub struct Pending<T> {
|
||||||
_data: marker::PhantomData<T>,
|
_data: marker::PhantomData<fn() -> T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a future which never resolves, representing a computation that never
|
/// Creates a future which never resolves, representing a computation that never
|
||||||
@ -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")]
|
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
|
||||||
impl<T> Debug for Pending<T> {
|
impl<T> Debug for Pending<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
@ -602,7 +602,7 @@ pub trait BuildHasher {
|
|||||||
/// [`HashSet`]: ../../std/collections/struct.HashSet.html
|
/// [`HashSet`]: ../../std/collections/struct.HashSet.html
|
||||||
/// [zero-sized]: https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts
|
/// [zero-sized]: https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts
|
||||||
#[stable(since = "1.7.0", feature = "build_hasher")]
|
#[stable(since = "1.7.0", feature = "build_hasher")]
|
||||||
pub struct BuildHasherDefault<H>(marker::PhantomData<H>);
|
pub struct BuildHasherDefault<H>(marker::PhantomData<fn() -> H>);
|
||||||
|
|
||||||
#[stable(since = "1.9.0", feature = "core_impl_debug")]
|
#[stable(since = "1.9.0", feature = "core_impl_debug")]
|
||||||
impl<H> fmt::Debug for BuildHasherDefault<H> {
|
impl<H> fmt::Debug for BuildHasherDefault<H> {
|
||||||
|
@ -22,17 +22,17 @@ pub const fn empty<T>() -> Empty<T> {
|
|||||||
Empty(marker::PhantomData)
|
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.
|
/// An iterator that yields nothing.
|
||||||
///
|
///
|
||||||
/// This `struct` is created by the [`empty()`] function. See its documentation for more.
|
/// This `struct` is created by the [`empty()`] function. See its documentation for more.
|
||||||
#[must_use = "iterators are lazy and do nothing unless consumed"]
|
#[must_use = "iterators are lazy and do nothing unless consumed"]
|
||||||
#[stable(feature = "iter_empty", since = "1.2.0")]
|
#[stable(feature = "iter_empty", since = "1.2.0")]
|
||||||
pub struct Empty<T>(marker::PhantomData<T>);
|
pub struct Empty<T>(marker::PhantomData<FnReturning<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> {}
|
|
||||||
|
|
||||||
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
#[stable(feature = "core_impl_debug", since = "1.9.0")]
|
||||||
impl<T> fmt::Debug for Empty<T> {
|
impl<T> fmt::Debug for Empty<T> {
|
||||||
|
Loading…
Reference in New Issue
Block a user