de-non_const some iterator methods

This commit is contained in:
Lars Schumann
2026-04-02 21:13:28 +00:00
parent fff9e44322
commit fc71bad873
27 changed files with 74 additions and 94 deletions
+6 -4
View File
@@ -1005,9 +1005,10 @@ fn drop(&mut self) {
/// dropped.
///
/// Used for [`Iterator::next_chunk`].
#[rustc_const_unstable(feature = "const_iter", issue = "92476")]
#[inline]
pub(crate) fn iter_next_chunk<T, const N: usize>(
iter: &mut impl Iterator<Item = T>,
pub(crate) const fn iter_next_chunk<T, const N: usize>(
iter: &mut impl [const] Iterator<Item = T>,
) -> Result<[T; N], IntoIter<T, N>> {
let mut array = [const { MaybeUninit::uninit() }; N];
let r = iter_next_chunk_erased(&mut array, iter);
@@ -1028,10 +1029,11 @@ pub(crate) fn iter_next_chunk<T, const N: usize>(
///
/// Unfortunately this loop has two exit conditions, the buffer filling up
/// or the iterator running out of items, making it tend to optimize poorly.
#[rustc_const_unstable(feature = "const_iter", issue = "92476")]
#[inline]
fn iter_next_chunk_erased<T>(
const fn iter_next_chunk_erased<T>(
buffer: &mut [MaybeUninit<T>],
iter: &mut impl Iterator<Item = T>,
iter: &mut impl [const] Iterator<Item = T>,
) -> Result<(), usize> {
// if `Iterator::next` panics, this guard will drop already initialized items
let mut guard = Guard { array_mut: buffer, initialized: 0 };
@@ -26,7 +26,7 @@ impl<I, const N: usize> ArrayChunks<I, N>
I: Iterator,
{
#[track_caller]
pub(in crate::iter) fn new(iter: I) -> Self {
pub(in crate::iter) const fn new(iter: I) -> Self {
assert!(N != 0, "chunk size must be non-zero");
Self { iter, remainder: None }
}
+1 -1
View File
@@ -33,7 +33,7 @@ pub struct Chain<A, B> {
b: Option<B>,
}
impl<A, B> Chain<A, B> {
pub(in super::super) fn new(a: A, b: B) -> Chain<A, B> {
pub(in super::super) const fn new(a: A, b: B) -> Chain<A, B> {
Chain { a: Some(a), b: Some(b) }
}
}
+1 -1
View File
@@ -20,7 +20,7 @@ pub struct Cloned<I> {
}
impl<I> Cloned<I> {
pub(in crate::iter) fn new(it: I) -> Cloned<I> {
pub(in crate::iter) const fn new(it: I) -> Cloned<I> {
Cloned { it }
}
}
+1 -1
View File
@@ -21,7 +21,7 @@ pub struct Copied<I> {
}
impl<I> Copied<I> {
pub(in crate::iter) fn new(it: I) -> Copied<I> {
pub(in crate::iter) const fn new(it: I) -> Copied<I> {
Copied { it }
}
+2 -1
View File
@@ -17,7 +17,8 @@ pub struct Cycle<I> {
iter: I,
}
impl<I: Clone> Cycle<I> {
#[rustc_const_unstable(feature = "const_iter", issue = "92476")]
const impl<I: [const] Clone> Cycle<I> {
pub(in crate::iter) fn new(iter: I) -> Cycle<I> {
Cycle { orig: iter.clone(), iter }
}
+1 -1
View File
@@ -20,7 +20,7 @@ pub struct Enumerate<I> {
count: usize,
}
impl<I> Enumerate<I> {
pub(in crate::iter) fn new(iter: I) -> Enumerate<I> {
pub(in crate::iter) const fn new(iter: I) -> Enumerate<I> {
Enumerate { iter, count: 0 }
}
+1 -1
View File
@@ -24,7 +24,7 @@ pub struct Filter<I, P> {
predicate: P,
}
impl<I, P> Filter<I, P> {
pub(in crate::iter) fn new(iter: I, predicate: P) -> Filter<I, P> {
pub(in crate::iter) const fn new(iter: I, predicate: P) -> Filter<I, P> {
Filter { iter, predicate }
}
}
+1 -1
View File
@@ -20,7 +20,7 @@ pub struct FilterMap<I, F> {
f: F,
}
impl<I, F> FilterMap<I, F> {
pub(in crate::iter) fn new(iter: I, f: F) -> FilterMap<I, F> {
pub(in crate::iter) const fn new(iter: I, f: F) -> FilterMap<I, F> {
FilterMap { iter, f }
}
}
+6 -3
View File
@@ -185,7 +185,8 @@ pub struct Flatten<I: Iterator<Item: IntoIterator>> {
inner: FlattenCompat<I, <I::Item as IntoIterator>::IntoIter>,
}
impl<I: Iterator<Item: IntoIterator>> Flatten<I> {
#[rustc_const_unstable(feature = "const_iter", issue = "92476")]
const impl<I: [const] Iterator<Item: IntoIterator>> Flatten<I> {
pub(in super::super) fn new(iter: I) -> Flatten<I> {
Flatten { inner: FlattenCompat::new(iter) }
}
@@ -358,9 +359,11 @@ struct FlattenCompat<I, U> {
frontiter: Option<U>,
backiter: Option<U>,
}
impl<I, U> FlattenCompat<I, U>
#[rustc_const_unstable(feature = "const_iter", issue = "92476")]
const impl<I, U> FlattenCompat<I, U>
where
I: Iterator,
I: [const] Iterator,
{
/// Adapts an iterator by flattening it, for use in `flatten()` and `flat_map()`.
fn new(iter: I) -> FlattenCompat<I, U> {
+1 -1
View File
@@ -21,7 +21,7 @@ pub struct Fuse<I> {
iter: Option<I>,
}
impl<I> Fuse<I> {
pub(in crate::iter) fn new(iter: I) -> Fuse<I> {
pub(in crate::iter) const fn new(iter: I) -> Fuse<I> {
Fuse { iter: Some(iter) }
}
+1 -1
View File
@@ -20,7 +20,7 @@ pub struct Inspect<I, F> {
f: F,
}
impl<I, F> Inspect<I, F> {
pub(in crate::iter) fn new(iter: I, f: F) -> Inspect<I, F> {
pub(in crate::iter) const fn new(iter: I, f: F) -> Inspect<I, F> {
Inspect { iter, f }
}
}
@@ -20,7 +20,7 @@ impl<I: Iterator> Intersperse<I>
where
I::Item: Clone,
{
pub(in crate::iter) fn new(iter: I, separator: I::Item) -> Self {
pub(in crate::iter) const fn new(iter: I, separator: I::Item) -> Self {
Self { started: false, separator, next_item: None, iter }
}
}
@@ -129,7 +129,7 @@ impl<I, G> IntersperseWith<I, G>
I: Iterator,
G: FnMut() -> I::Item,
{
pub(in crate::iter) fn new(iter: I, separator: G) -> Self {
pub(in crate::iter) const fn new(iter: I, separator: G) -> Self {
Self { started: false, separator, next_item: None, iter }
}
}
+1 -1
View File
@@ -65,7 +65,7 @@ pub struct Map<I, F> {
}
impl<I, F> Map<I, F> {
pub(in crate::iter) fn new(iter: I, f: F) -> Map<I, F> {
pub(in crate::iter) const fn new(iter: I, f: F) -> Map<I, F> {
Map { iter, f }
}
+1 -1
View File
@@ -20,7 +20,7 @@ pub struct MapWhile<I, P> {
}
impl<I, P> MapWhile<I, P> {
pub(in crate::iter) fn new(iter: I, predicate: P) -> MapWhile<I, P> {
pub(in crate::iter) const fn new(iter: I, predicate: P) -> MapWhile<I, P> {
MapWhile { iter, predicate }
}
}
@@ -43,7 +43,7 @@ struct Buffer<T, const N: usize> {
}
impl<I: Iterator, F, const N: usize> MapWindows<I, F, N> {
pub(in crate::iter) fn new(iter: I, f: F) -> Self {
pub(in crate::iter) const fn new(iter: I, f: F) -> Self {
assert!(N != 0, "array in `Iterator::map_windows` must contain more than 0 elements");
// Only ZST arrays' length can be so large.
@@ -60,7 +60,7 @@ pub(in crate::iter) fn new(iter: I, f: F) -> Self {
impl<I: Iterator, const N: usize> MapWindowsInner<I, N> {
#[inline]
fn new(iter: I) -> Self {
const fn new(iter: I) -> Self {
Self { iter, buffer: None }
}
+1 -1
View File
@@ -21,7 +21,7 @@ pub struct Peekable<I: Iterator> {
}
impl<I: Iterator> Peekable<I> {
pub(in crate::iter) fn new(iter: I) -> Peekable<I> {
pub(in crate::iter) const fn new(iter: I) -> Peekable<I> {
Peekable { iter, peeked: None }
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ pub struct Rev<T> {
}
impl<T> Rev<T> {
pub(in crate::iter) fn new(iter: T) -> Rev<T> {
pub(in crate::iter) const fn new(iter: T) -> Rev<T> {
Rev { iter }
}
+1 -1
View File
@@ -21,7 +21,7 @@ pub struct Scan<I, St, F> {
}
impl<I, St, F> Scan<I, St, F> {
pub(in crate::iter) fn new(iter: I, state: St, f: F) -> Scan<I, St, F> {
pub(in crate::iter) const fn new(iter: I, state: St, f: F) -> Scan<I, St, F> {
Scan { iter, state, f }
}
}
+1 -1
View File
@@ -24,7 +24,7 @@ pub struct Skip<I> {
}
impl<I> Skip<I> {
pub(in crate::iter) fn new(iter: I, n: usize) -> Skip<I> {
pub(in crate::iter) const fn new(iter: I, n: usize) -> Skip<I> {
Skip { iter, n }
}
}
+1 -1
View File
@@ -21,7 +21,7 @@ pub struct SkipWhile<I, P> {
}
impl<I, P> SkipWhile<I, P> {
pub(in crate::iter) fn new(iter: I, predicate: P) -> SkipWhile<I, P> {
pub(in crate::iter) const fn new(iter: I, predicate: P) -> SkipWhile<I, P> {
SkipWhile { iter, flag: false, predicate }
}
}
+1 -1
View File
@@ -20,7 +20,7 @@ pub struct Take<I> {
}
impl<I> Take<I> {
pub(in crate::iter) fn new(iter: I, n: usize) -> Take<I> {
pub(in crate::iter) const fn new(iter: I, n: usize) -> Take<I> {
Take { iter, n }
}
}
+1 -1
View File
@@ -21,7 +21,7 @@ pub struct TakeWhile<I, P> {
}
impl<I, P> TakeWhile<I, P> {
pub(in crate::iter) fn new(iter: I, predicate: P) -> TakeWhile<I, P> {
pub(in crate::iter) const fn new(iter: I, predicate: P) -> TakeWhile<I, P> {
TakeWhile { iter, flag: false, predicate }
}
}
+4 -2
View File
@@ -10,11 +10,12 @@
/// [`sum()`]: Iterator::sum
/// [`FromIterator`]: iter::FromIterator
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
#[rustc_const_unstable(feature = "const_iter", issue = "92476")]
#[diagnostic::on_unimplemented(
message = "a value of type `{Self}` cannot be made by summing an iterator over elements of type `{A}`",
label = "value of type `{Self}` cannot be made by summing a `std::iter::Iterator<Item={A}>`"
)]
pub trait Sum<A = Self>: Sized {
pub const trait Sum<A = Self>: Sized {
/// Takes an iterator and generates `Self` from the elements by "summing up"
/// the items.
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
@@ -31,11 +32,12 @@ pub trait Sum<A = Self>: Sized {
/// [`product()`]: Iterator::product
/// [`FromIterator`]: iter::FromIterator
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
#[rustc_const_unstable(feature = "const_iter", issue = "92476")]
#[diagnostic::on_unimplemented(
message = "a value of type `{Self}` cannot be made by multiplying all elements of type `{A}` from an iterator",
label = "value of type `{Self}` cannot be made by multiplying all elements from a `std::iter::Iterator<Item={A}>`"
)]
pub trait Product<A = Self>: Sized {
pub const trait Product<A = Self>: Sized {
/// Takes an iterator and generates `Self` from the elements by multiplying
/// the items.
#[stable(feature = "iter_arith_traits", since = "1.12.0")]
+13 -37
View File
@@ -109,7 +109,6 @@ pub const trait Iterator {
/// ```
#[inline]
#[unstable(feature = "iter_next_chunk", issue = "98326")]
#[rustc_non_const_trait_method]
fn next_chunk<const N: usize>(
&mut self,
) -> Result<[Self::Item; N], array::IntoIter<Self::Item, N>>
@@ -222,16 +221,18 @@ fn size_hint(&self) -> (usize, Option<usize>) {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_non_const_trait_method]
fn count(self) -> usize
where
Self: Sized,
Self: Sized + [const] Destruct,
Self::Item: [const] Destruct,
{
self.fold(
0,
#[rustc_inherit_overflow_checks]
|count, _| count + 1,
)
// FIXME(const-hack): revert this to a const closure
#[rustc_const_unstable(feature = "const_iter", issue = "92476")]
#[rustc_inherit_overflow_checks]
const fn plus_one<T: [const] Destruct>(accum: usize, _elem: T) -> usize {
accum + 1
}
self.fold(0, plus_one)
}
/// Consumes the iterator, returning the last element.
@@ -508,11 +509,10 @@ fn step_by(self, step: usize) -> StepBy<Self>
/// [`OsStr`]: ../../std/ffi/struct.OsStr.html
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_non_const_trait_method]
fn chain<U>(self, other: U) -> Chain<Self, U::IntoIter>
where
Self: Sized,
U: IntoIterator<Item = Self::Item>,
U: [const] IntoIterator<Item = Self::Item>,
{
Chain::new(self, other.into_iter())
}
@@ -692,7 +692,6 @@ fn zip<U>(self, other: U) -> Zip<Self, U::IntoIter>
/// [`intersperse_with`]: Iterator::intersperse_with
#[inline]
#[unstable(feature = "iter_intersperse", issue = "79524")]
#[rustc_non_const_trait_method]
fn intersperse(self, separator: Self::Item) -> Intersperse<Self>
where
Self: Sized,
@@ -772,7 +771,6 @@ fn intersperse(self, separator: Self::Item) -> Intersperse<Self>
/// [`intersperse_with`]: Iterator::intersperse_with
#[inline]
#[unstable(feature = "iter_intersperse", issue = "79524")]
#[rustc_non_const_trait_method]
fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>
where
Self: Sized,
@@ -832,7 +830,6 @@ fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>
#[rustc_diagnostic_item = "IteratorMap"]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_non_const_trait_method]
fn map<B, F>(self, f: F) -> Map<Self, F>
where
Self: Sized,
@@ -954,7 +951,6 @@ fn call<T>(mut f: impl FnMut(T)) -> impl FnMut((), T) {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "iter_filter"]
#[rustc_non_const_trait_method]
fn filter<P>(self, predicate: P) -> Filter<Self, P>
where
Self: Sized,
@@ -1000,7 +996,6 @@ fn filter<P>(self, predicate: P) -> Filter<Self, P>
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_non_const_trait_method]
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
where
Self: Sized,
@@ -1048,7 +1043,6 @@ fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "enumerate_method"]
#[rustc_non_const_trait_method]
fn enumerate(self) -> Enumerate<Self>
where
Self: Sized,
@@ -1120,7 +1114,6 @@ fn enumerate(self) -> Enumerate<Self>
/// [`next`]: Iterator::next
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_non_const_trait_method]
fn peekable(self) -> Peekable<Self>
where
Self: Sized,
@@ -1186,7 +1179,6 @@ fn peekable(self) -> Peekable<Self>
#[inline]
#[doc(alias = "drop_while")]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_non_const_trait_method]
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
where
Self: Sized,
@@ -1265,7 +1257,6 @@ fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
/// the iteration should stop, but wasn't placed back into the iterator.
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_non_const_trait_method]
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
where
Self: Sized,
@@ -1354,7 +1345,6 @@ fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
/// [`fuse`]: Iterator::fuse
#[inline]
#[stable(feature = "iter_map_while", since = "1.57.0")]
#[rustc_non_const_trait_method]
fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>
where
Self: Sized,
@@ -1384,7 +1374,6 @@ fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_non_const_trait_method]
fn skip(self, n: usize) -> Skip<Self>
where
Self: Sized,
@@ -1457,7 +1446,6 @@ fn skip(self, n: usize) -> Skip<Self>
#[doc(alias = "limit")]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_non_const_trait_method]
fn take(self, n: usize) -> Take<Self>
where
Self: Sized,
@@ -1505,7 +1493,6 @@ fn take(self, n: usize) -> Take<Self>
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_non_const_trait_method]
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
where
Self: Sized,
@@ -1629,7 +1616,6 @@ fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
/// [`flat_map()`]: Iterator::flat_map
#[inline]
#[stable(feature = "iterator_flatten", since = "1.29.0")]
#[rustc_non_const_trait_method]
fn flatten(self) -> Flatten<Self>
where
Self: Sized,
@@ -1784,7 +1770,6 @@ fn flatten(self) -> Flatten<Self>
/// ```
#[inline]
#[unstable(feature = "iter_map_windows", issue = "87155")]
#[rustc_non_const_trait_method]
fn map_windows<F, R, const N: usize>(self, f: F) -> MapWindows<Self, F, N>
where
Self: Sized,
@@ -1847,7 +1832,6 @@ fn map_windows<F, R, const N: usize>(self, f: F) -> MapWindows<Self, F, N>
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_non_const_trait_method]
fn fuse(self) -> Fuse<Self>
where
Self: Sized,
@@ -1932,7 +1916,6 @@ fn fuse(self) -> Fuse<Self>
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_non_const_trait_method]
fn inspect<F>(self, f: F) -> Inspect<Self, F>
where
Self: Sized,
@@ -3459,7 +3442,6 @@ fn fold<T>(mut compare: impl FnMut(&T, &T) -> Ordering) -> impl FnMut(T, T) -> T
#[inline]
#[doc(alias = "reverse")]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_non_const_trait_method]
fn rev(self) -> Rev<Self>
where
Self: Sized + DoubleEndedIterator,
@@ -3528,7 +3510,6 @@ fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
/// ```
#[stable(feature = "iter_copied", since = "1.36.0")]
#[rustc_diagnostic_item = "iter_copied"]
#[rustc_non_const_trait_method]
fn copied<'a, T>(self) -> Copied<Self>
where
T: Copy + 'a,
@@ -3577,7 +3558,6 @@ fn copied<'a, T>(self) -> Copied<Self>
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "iter_cloned"]
#[rustc_non_const_trait_method]
fn cloned<'a, T>(self) -> Cloned<Self>
where
T: Clone + 'a,
@@ -3609,10 +3589,9 @@ fn cloned<'a, T>(self) -> Cloned<Self>
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
#[rustc_non_const_trait_method]
fn cycle(self) -> Cycle<Self>
where
Self: Sized + Clone,
Self: Sized + [const] Clone,
{
Cycle::new(self)
}
@@ -3653,7 +3632,6 @@ fn cycle(self) -> Cycle<Self>
/// ```
#[track_caller]
#[unstable(feature = "iter_array_chunks", issue = "100450")]
#[rustc_non_const_trait_method]
fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>
where
Self: Sized,
@@ -3690,11 +3668,10 @@ fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>
/// assert_eq!(sum, -0.0_f32);
/// ```
#[stable(feature = "iter_arith", since = "1.11.0")]
#[rustc_non_const_trait_method]
fn sum<S>(self) -> S
where
Self: Sized,
S: Sum<Self::Item>,
S: [const] Sum<Self::Item>,
{
Sum::sum(self)
}
@@ -3723,11 +3700,10 @@ fn sum<S>(self) -> S
/// assert_eq!(factorial(5), 120);
/// ```
#[stable(feature = "iter_arith", since = "1.11.0")]
#[rustc_non_const_trait_method]
fn product<P>(self) -> P
where
Self: Sized,
P: Product<Self::Item>,
P: [const] Product<Self::Item>,
{
Product::product(self)
}
@@ -239,5 +239,5 @@ fn evens_squared(n: usize) -> _ {
const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
//~^ ERROR the placeholder
//~| ERROR cannot call non-const
//~| ERROR cannot call non-const
//~| ERROR the trait bound `std::ops::Range<{integer}>: const Iterator` is not satisfied
//~| ERROR the trait bound `Filter<std::ops::Range<{integer}>
@@ -587,17 +587,29 @@ LL - fn evens_squared(n: usize) -> _ {
LL + fn evens_squared(n: usize) -> impl Iterator<Item = usize> {
|
error[E0277]: the trait bound `std::ops::Range<{integer}>: const Iterator` is not satisfied
--> $DIR/typeck_type_placeholder_item.rs:240:15
|
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
| ^^^^^ ------ required by a bound introduced by this call
|
note: trait `Iterator` is implemented but not `const`
--> $SRC_DIR/core/src/iter/range.rs:LL:COL
error[E0277]: the trait bound `Filter<std::ops::Range<{integer}>, {closure@$DIR/typeck_type_placeholder_item.rs:240:29: 240:32}>: const Iterator` is not satisfied
--> $DIR/typeck_type_placeholder_item.rs:240:45
|
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
| ^^^
|
note: trait `Iterator` is implemented but not `const`
--> $SRC_DIR/core/src/iter/adapters/filter.rs:LL:COL
error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
--> $DIR/typeck_type_placeholder_item.rs:240:10
|
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
| ^ not allowed in type signatures
|
note: however, the inferred type `Map<Filter<Range<i32>, {closure@typeck_type_placeholder_item.rs:240:29}>, {closure@typeck_type_placeholder_item.rs:240:49}>` cannot be named
--> $DIR/typeck_type_placeholder_item.rs:240:14
|
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
--> $DIR/typeck_type_placeholder_item.rs:40:24
@@ -678,23 +690,7 @@ LL | fn map<T>(_: fn() -> Option<&'static T>) -> Option<T> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error[E0015]: cannot call non-const method `<std::ops::Range<i32> as Iterator>::filter::<{closure@$DIR/typeck_type_placeholder_item.rs:240:29: 240:32}>` in constants
--> $DIR/typeck_type_placeholder_item.rs:240:22
|
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error[E0015]: cannot call non-const method `<Filter<std::ops::Range<i32>, {closure@$DIR/typeck_type_placeholder_item.rs:240:29: 240:32}> as Iterator>::map::<i32, {closure@$DIR/typeck_type_placeholder_item.rs:240:49: 240:52}>` in constants
--> $DIR/typeck_type_placeholder_item.rs:240:45
|
LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
| ^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
error: aborting due to 83 previous errors
Some errors have detailed explanations: E0015, E0046, E0121, E0282, E0403.
Some errors have detailed explanations: E0015, E0046, E0121, E0277, E0282, E0403.
For more information about an error, try `rustc --explain E0015`.