Skip to content

Commit

Permalink
Rollup merge of #103945 - H4x5:remove-iter-empty-hack, r=compiler-errors
Browse files Browse the repository at this point in the history
Remove `iter::Empty` hack

`iter::Empty` uses a newtype to work around `#![feature(const_fn_fn_ptr_basics)]`, which has been stable since 1.61.0.
  • Loading branch information
fee1-dead authored Dec 28, 2022
2 parents dc98aa6 + b473bc9 commit d1193ad
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions library/core/src/iter/sources/empty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,12 @@ 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<FnReturning<T>>);
pub struct Empty<T>(marker::PhantomData<fn() -> T>);

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

0 comments on commit d1193ad

Please sign in to comment.