From 00c21f2eec0a239f15bc4a934d204eac7164852c Mon Sep 17 00:00:00 2001 From: ltdk Date: Mon, 23 Nov 2026 20:49:12 -0500 Subject: [PATCH 1/2] Add regression test for delegated Iterator impl --- tests/ui/iterators/delegated.rs | 66 +++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 tests/ui/iterators/delegated.rs diff --git a/tests/ui/iterators/delegated.rs b/tests/ui/iterators/delegated.rs new file mode 100644 index 0000000000000..a6c282d4bffa5 --- /dev/null +++ b/tests/ui/iterators/delegated.rs @@ -0,0 +1,66 @@ +//@ check-pass + +// This is a regression test for: +// - https://github.com/rust-lang/rust/issues/109632 +// - https://github.com/rust-lang/rust/issues/166229 +// (It's the same regression, we just didn't add a regression test. Now we have.) + +use std::marker::PhantomData; +use std::ops::Deref; + +pub trait Indirect { + type Output; +} + +pub struct Wrapper { + inner: PhantomData, +} + +impl Deref for Wrapper { + type Target = I::Output; + fn deref(&self) -> &Self::Target { + unimplemented!() + } +} + +impl std::ops::DerefMut for Wrapper { + fn deref_mut(&mut self) -> &mut Self::Target { + unimplemented!() + } +} + +// NOTE: the regression here is that the signatures of the below don't actually match the bounds +// on these methods, since the trait solver wasn't able to determine that blanket impls on +// `Destruct` trivially apply to the given type for non-const implementations. which methods we +// choose to delegate here is mostly arbitrary, but we use manual delegation since the original +// regression was for automatically generated code. + +impl Iterator for Wrapper +where + ::Target: Iterator, +{ + type Item = <::Target as Iterator>::Item; + fn next(&mut self) -> Option<<::Target as Iterator>::Item> { + (**self).next() + } + fn size_hint(&self) -> (usize, Option) { + (**self).size_hint() + } + fn nth(&mut self, n: usize) -> Option<<::Target as Iterator>::Item> { + (**self).nth(n) + } +} + +impl DoubleEndedIterator for Wrapper +where + ::Target: DoubleEndedIterator, +{ + fn next_back(&mut self) -> Option<<::Target as Iterator>::Item> { + (**self).next_back() + } + fn nth_back(&mut self, n: usize) -> Option<<::Target as Iterator>::Item> { + (**self).nth_back(n) + } +} + +fn main() {} From a9ed451a901a163eb1872899a7b8ebabbd6b6ba7 Mon Sep 17 00:00:00 2001 From: ltdk Date: Sun, 22 Nov 2026 00:47:21 -0500 Subject: [PATCH 2/2] Revert "implement const Iterator for Range" This reverts commits 2f9fea1dec8a0d800f32129787b3464e919b300a..0c12d6f94b8d3d6856aad2d6294eaebae2c26ef8. --- library/core/src/iter/range.rs | 20 +++------- library/core/src/iter/traits/double_ended.rs | 30 ++++----------- library/core/src/iter/traits/iterator.rs | 30 ++++----------- library/core/src/iter/traits/marker.rs | 3 +- library/core/src/slice/cmp.rs | 10 ++++- library/core/src/slice/mod.rs | 7 +++- tests/codegen-llvm/array-cmp.rs | 21 +++++------ tests/ui/consts/const-for-feature-gate.rs | 2 - tests/ui/consts/const-for-feature-gate.stderr | 36 ++---------------- tests/ui/consts/const-for.rs | 9 +++++ tests/ui/consts/const-for.stderr | 20 ++++++++++ tests/ui/consts/control-flow/loop.rs | 7 ++-- tests/ui/consts/control-flow/loop.stderr | 37 +++++++++++++++++++ .../ui/typeck/typeck_type_placeholder_item.rs | 1 - .../typeck_type_placeholder_item.stderr | 20 ++-------- 15 files changed, 123 insertions(+), 130 deletions(-) create mode 100644 tests/ui/consts/const-for.rs create mode 100644 tests/ui/consts/const-for.stderr create mode 100644 tests/ui/consts/control-flow/loop.stderr diff --git a/library/core/src/iter/range.rs b/library/core/src/iter/range.rs index 331c367314e63..e6acf3081c890 100644 --- a/library/core/src/iter/range.rs +++ b/library/core/src/iter/range.rs @@ -2,7 +2,6 @@ use super::{ FusedIterator, TrustedLen, TrustedRandomAccess, TrustedRandomAccessNoCoerce, TrustedStep, }; use crate::ascii::Char as AsciiChar; -use crate::marker::Destruct; use crate::mem; use crate::net::{Ipv4Addr, Ipv6Addr}; use crate::num::NonZero; @@ -1001,7 +1000,7 @@ macro_rules! range_incl_exact_iter_impl { } /// Specialization implementations for `Range`. -const trait RangeIteratorImpl { +trait RangeIteratorImpl { type Item; // Iterator @@ -1015,8 +1014,7 @@ const trait RangeIteratorImpl { fn spec_advance_back_by(&mut self, n: usize) -> Result<(), NonZero>; } -#[rustc_const_unstable(feature = "const_iter", issue = "92476")] -const impl RangeIteratorImpl for ops::Range { +impl RangeIteratorImpl for ops::Range { type Item = A; #[inline] @@ -1096,8 +1094,7 @@ const impl RangeIteratorImpl for ops::Range< } } -#[rustc_const_unstable(feature = "const_iter", issue = "92476")] -const impl RangeIteratorImpl for ops::Range { +impl RangeIteratorImpl for ops::Range { #[inline] fn spec_next(&mut self) -> Option { if self.start < self.end { @@ -1180,8 +1177,7 @@ const impl RangeIteratorImpl for ops: } #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature = "const_iter", issue = "92476")] -const impl Iterator for ops::Range { +impl Iterator for ops::Range { type Item = A; #[inline] @@ -1234,10 +1230,7 @@ const impl Iterator for ops::Range { } #[inline] - fn is_sorted(self) -> bool - where - Self: [const] Destruct, - { + fn is_sorted(self) -> bool { true } @@ -1317,8 +1310,7 @@ range_incl_exact_iter_impl! { } #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_const_unstable(feature = "const_iter", issue = "92476")] -const impl DoubleEndedIterator for ops::Range { +impl DoubleEndedIterator for ops::Range { #[inline] fn next_back(&mut self) -> Option { self.spec_next_back() diff --git a/library/core/src/iter/traits/double_ended.rs b/library/core/src/iter/traits/double_ended.rs index 3c3db756d91ea..1b6cde764872e 100644 --- a/library/core/src/iter/traits/double_ended.rs +++ b/library/core/src/iter/traits/double_ended.rs @@ -185,22 +185,14 @@ pub const trait DoubleEndedIterator: [const] Iterator { /// [`Err(k)`]: Err #[inline] #[unstable(feature = "iter_advance_by", issue = "77404")] - fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero> - where - Self::Item: [const] Destruct, - { + #[rustc_non_const_trait_method] + fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero> { /// Helper trait to specialize `advance_back_by` via `try_rfold` for `Sized` iterators. - - #[rustc_const_unstable(feature = "const_iter", issue = "92476")] - const trait SpecAdvanceBackBy { + trait SpecAdvanceBackBy { fn spec_advance_back_by(&mut self, n: usize) -> Result<(), NonZero>; } - #[rustc_const_unstable(feature = "const_iter", issue = "92476")] - const impl SpecAdvanceBackBy for I - where - I::Item: [const] Destruct, - { + impl SpecAdvanceBackBy for I { default fn spec_advance_back_by(&mut self, n: usize) -> Result<(), NonZero> { for i in 0..n { if self.next_back().is_none() { @@ -212,17 +204,13 @@ pub const trait DoubleEndedIterator: [const] Iterator { } } - #[rustc_const_unstable(feature = "const_iter", issue = "92476")] - const impl SpecAdvanceBackBy for I - where - I::Item: [const] Destruct, - { + impl SpecAdvanceBackBy for I { fn spec_advance_back_by(&mut self, n: usize) -> Result<(), NonZero> { let Some(n) = NonZero::new(n) else { return Ok(()); }; - let res = self.try_rfold(n, const |n, _| NonZero::new(n.get() - 1)); + let res = self.try_rfold(n, |n, _| NonZero::new(n.get() - 1)); match res { None => Ok(()), @@ -277,10 +265,8 @@ pub const trait DoubleEndedIterator: [const] Iterator { /// ``` #[inline] #[stable(feature = "iter_nth_back", since = "1.37.0")] - fn nth_back(&mut self, n: usize) -> Option - where - Self::Item: [const] Destruct, - { + #[rustc_non_const_trait_method] + fn nth_back(&mut self, n: usize) -> Option { self.advance_back_by(n).ok()?; self.next_back() } diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index 21714f50f8e9a..2cda2e8e74286 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -306,22 +306,14 @@ pub const trait Iterator { /// ``` #[inline] #[unstable(feature = "iter_advance_by", issue = "77404")] - fn advance_by(&mut self, n: usize) -> Result<(), NonZero> - where - Self::Item: [const] Destruct, - { + #[rustc_non_const_trait_method] + fn advance_by(&mut self, n: usize) -> Result<(), NonZero> { /// Helper trait to specialize `advance_by` via `try_fold` for `Sized` iterators. - - #[rustc_const_unstable(feature = "const_iter", issue = "92476")] - const trait SpecAdvanceBy { + trait SpecAdvanceBy { fn spec_advance_by(&mut self, n: usize) -> Result<(), NonZero>; } - #[rustc_const_unstable(feature = "const_iter", issue = "92476")] - const impl SpecAdvanceBy for I - where - I::Item: [const] Destruct, - { + impl SpecAdvanceBy for I { default fn spec_advance_by(&mut self, n: usize) -> Result<(), NonZero> { for i in 0..n { if self.next().is_none() { @@ -333,17 +325,13 @@ pub const trait Iterator { } } - #[rustc_const_unstable(feature = "const_iter", issue = "92476")] - const impl SpecAdvanceBy for I - where - I::Item: [const] Destruct, - { + impl SpecAdvanceBy for I { fn spec_advance_by(&mut self, n: usize) -> Result<(), NonZero> { let Some(n) = NonZero::new(n) else { return Ok(()); }; - let res = self.try_fold(n, const |n, _| NonZero::new(n.get() - 1)); + let res = self.try_fold(n, |n, _| NonZero::new(n.get() - 1)); match res { None => Ok(()), @@ -397,10 +385,8 @@ pub const trait Iterator { #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "iter_nth"] - fn nth(&mut self, n: usize) -> Option - where - Self::Item: [const] Destruct, - { + #[rustc_non_const_trait_method] + fn nth(&mut self, n: usize) -> Option { self.advance_by(n).ok()?; self.next() } diff --git a/library/core/src/iter/traits/marker.rs b/library/core/src/iter/traits/marker.rs index fd96424566bcc..1e6704fe524a9 100644 --- a/library/core/src/iter/traits/marker.rs +++ b/library/core/src/iter/traits/marker.rs @@ -115,5 +115,4 @@ pub unsafe trait InPlaceIterable { /// for details. Consumers are free to rely on the invariants in unsafe code. #[unstable(feature = "trusted_step", issue = "85731")] #[rustc_specialization_trait] -#[rustc_const_unstable(feature = "const_iter", issue = "92476")] -pub const unsafe trait TrustedStep: [const] Step + Copy {} +pub unsafe trait TrustedStep: Step + Copy {} diff --git a/library/core/src/slice/cmp.rs b/library/core/src/slice/cmp.rs index 3abf75cbf5e2b..2d61eed8e1a73 100644 --- a/library/core/src/slice/cmp.rs +++ b/library/core/src/slice/cmp.rs @@ -118,11 +118,14 @@ where // Implemented as explicit indexing rather // than zipped iterators for performance reasons. // See PR https://github.com/rust-lang/rust/pull/116846 - for idx in 0..len { + // FIXME(const_hack): make this a `for idx in 0..len` loop. + let mut idx = 0; + while idx < len { // SAFETY: idx < len, so both are in-bounds and readable if unsafe { *lhs.add(idx) != *rhs.add(idx) } { return false; } + idx += 1; } true @@ -205,8 +208,11 @@ const fn chaining_impl<'l, 'r, A: PartialOrd, B, C>( let lhs = &left[..l]; let rhs = &right[..l]; - for i in 0..l { + // FIXME(const-hack): revert this to `for i in 0..l` once `impl const Iterator for Range` + let mut i: usize = 0; + while i < l { elem_chain(&lhs[i], &rhs[i])?; + i += 1; } len_chain(&left.len(), &right.len()) diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index c212df6459e24..4a3c0c8eb8187 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -5668,8 +5668,11 @@ where // But since it can't be relied on we also have an explicit specialization for T: Copy. let len = self.len(); let src = &src[..len]; - for i in 0..len { - self[i].clone_from(&src[i]); + // FIXME(const_hack): make this a `for idx in 0..self.len()` loop. + let mut idx = 0; + while idx < self.len() { + self[idx].clone_from(&src[idx]); + idx += 1; } } } diff --git a/tests/codegen-llvm/array-cmp.rs b/tests/codegen-llvm/array-cmp.rs index 2eb498d08f254..5b0a802f4097e 100644 --- a/tests/codegen-llvm/array-cmp.rs +++ b/tests/codegen-llvm/array-cmp.rs @@ -42,16 +42,6 @@ pub fn array_of_tuple_le(a: &[(i16, u16); 2], b: &[(i16, u16); 2]) -> bool { // CHECK: %[[EQ00:.+]] = icmp eq i16 %[[A00]], %[[B00]] // CHECK-NEXT: br i1 %[[EQ00]], label %[[L01:.+]], label %[[EXIT_S:.+]] - // CHECK: [[L01]]: - // CHECK: %[[PA01:.+]] = getelementptr{{.+}}i8, ptr %a, {{i32|i64}} 2 - // CHECK: %[[PB01:.+]] = getelementptr{{.+}}i8, ptr %b, {{i32|i64}} 2 - // CHECK: %[[A01:.+]] = load i16, ptr %[[PA01]] - // CHECK: %[[B01:.+]] = load i16, ptr %[[PB01]] - // CHECK-NOT: cmp - // CHECK: %[[EQ01:.+]] = icmp eq i16 %[[A01]], %[[B01]] - // CHECK-NEXT: br i1 %[[EQ01]], label %[[L10:.+]], label %[[EXIT_U:.+]] - - // CHECK: [[L10]]: // CHECK: %[[PA10:.+]] = getelementptr{{.+}}i8, ptr %a, {{i32|i64}} 4 // CHECK: %[[PB10:.+]] = getelementptr{{.+}}i8, ptr %b, {{i32|i64}} 4 // CHECK: %[[A10:.+]] = load i16, ptr %[[PA10]] @@ -67,7 +57,16 @@ pub fn array_of_tuple_le(a: &[(i16, u16); 2], b: &[(i16, u16); 2]) -> bool { // CHECK: %[[B11:.+]] = load i16, ptr %[[PB11]] // CHECK-NOT: cmp // CHECK: %[[EQ11:.+]] = icmp eq i16 %[[A11]], %[[B11]] - // CHECK-NEXT: br i1 %[[EQ11]], label %[[DONE:.+]], label %[[EXIT_U]] + // CHECK-NEXT: br i1 %[[EQ11]], label %[[DONE:.+]], label %[[EXIT_U:.+]] + + // CHECK: [[L01]]: + // CHECK: %[[PA01:.+]] = getelementptr{{.+}}i8, ptr %a, {{i32|i64}} 2 + // CHECK: %[[PB01:.+]] = getelementptr{{.+}}i8, ptr %b, {{i32|i64}} 2 + // CHECK: %[[A01:.+]] = load i16, ptr %[[PA01]] + // CHECK: %[[B01:.+]] = load i16, ptr %[[PB01]] + // CHECK-NOT: cmp + // CHECK: %[[EQ01:.+]] = icmp eq i16 %[[A01]], %[[B01]] + // CHECK-NEXT: br i1 %[[EQ01]], label %{{.+}}, label %[[EXIT_U]] // CHECK: [[DONE]]: // LLVM22: %[[RET:.+]] = phi i1 [ %{{.+}}, %[[EXIT_S]] ], [ %{{.+}}, %[[EXIT_U]] ], [ true, %[[L11]] ] diff --git a/tests/ui/consts/const-for-feature-gate.rs b/tests/ui/consts/const-for-feature-gate.rs index 1024beace3d89..b643e63c09690 100644 --- a/tests/ui/consts/const-for-feature-gate.rs +++ b/tests/ui/consts/const-for-feature-gate.rs @@ -3,9 +3,7 @@ const _: () = { for _ in 0..5 {} //~^ ERROR cannot use `for` - //~| ERROR `IntoIterator` is not yet stable //~| ERROR cannot use `for` - //~| ERROR `Iterator` is not yet stable }; fn main() {} diff --git a/tests/ui/consts/const-for-feature-gate.stderr b/tests/ui/consts/const-for-feature-gate.stderr index 5876f1476341c..29db5d24ac866 100644 --- a/tests/ui/consts/const-for-feature-gate.stderr +++ b/tests/ui/consts/const-for-feature-gate.stderr @@ -1,48 +1,20 @@ -error[E0658]: cannot use `for` loop on `std::ops::Range` in constants +error[E0015]: cannot use `for` loop on `std::ops::Range` in constants --> $DIR/const-for-feature-gate.rs:4:14 | LL | for _ in 0..5 {} | ^^^^ | = note: calls in constants are limited to constant functions, tuple structs and tuple variants - = note: see issue #143874 for more information - = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: `IntoIterator` is not yet stable as a const trait - --> $DIR/const-for-feature-gate.rs:4:14 - | -LL | for _ in 0..5 {} - | ^^^^ - | -help: add `#![feature(const_iter)]` to the crate attributes to enable - | -LL + #![feature(const_iter)] - | - -error[E0658]: cannot use `for` loop on `std::ops::Range` in constants +error[E0015]: cannot use `for` loop on `std::ops::Range` in constants --> $DIR/const-for-feature-gate.rs:4:14 | LL | for _ in 0..5 {} | ^^^^ | = note: calls in constants are limited to constant functions, tuple structs and tuple variants - = note: see issue #143874 for more information - = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `Iterator` is not yet stable as a const trait - --> $DIR/const-for-feature-gate.rs:4:14 - | -LL | for _ in 0..5 {} - | ^^^^ - | -help: add `#![feature(const_iter)]` to the crate attributes to enable - | -LL + #![feature(const_iter)] - | - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0658`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/const-for.rs b/tests/ui/consts/const-for.rs new file mode 100644 index 0000000000000..6f7895457c53d --- /dev/null +++ b/tests/ui/consts/const-for.rs @@ -0,0 +1,9 @@ +#![feature(const_for)] + +const _: () = { + for _ in 0..5 {} + //~^ ERROR cannot use `for` + //~| ERROR cannot use `for` +}; + +fn main() {} diff --git a/tests/ui/consts/const-for.stderr b/tests/ui/consts/const-for.stderr new file mode 100644 index 0000000000000..d1308a8dedc85 --- /dev/null +++ b/tests/ui/consts/const-for.stderr @@ -0,0 +1,20 @@ +error[E0015]: cannot use `for` loop on `std::ops::Range` in constants + --> $DIR/const-for.rs:4:14 + | +LL | for _ in 0..5 {} + | ^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants + +error[E0015]: cannot use `for` loop on `std::ops::Range` in constants + --> $DIR/const-for.rs:4:14 + | +LL | for _ in 0..5 {} + | ^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/control-flow/loop.rs b/tests/ui/consts/control-flow/loop.rs index 7da88dfd2ac89..b02c31c4c25b5 100644 --- a/tests/ui/consts/control-flow/loop.rs +++ b/tests/ui/consts/control-flow/loop.rs @@ -1,6 +1,3 @@ -//@ check-pass -#![feature(const_iter,const_trait_impl)] - const _: () = loop { break (); }; static FOO: i32 = loop { break 4; }; @@ -54,10 +51,14 @@ const _: i32 = { let mut x = 0; for i in 0..4 { + //~^ ERROR: cannot use `for` + //~| ERROR: cannot use `for` x += i; } for i in 0..4 { + //~^ ERROR: cannot use `for` + //~| ERROR: cannot use `for` x += i; } diff --git a/tests/ui/consts/control-flow/loop.stderr b/tests/ui/consts/control-flow/loop.stderr new file mode 100644 index 0000000000000..b91371f9dc218 --- /dev/null +++ b/tests/ui/consts/control-flow/loop.stderr @@ -0,0 +1,37 @@ +error[E0015]: cannot use `for` loop on `std::ops::Range` in constants + --> $DIR/loop.rs:53:14 + | +LL | for i in 0..4 { + | ^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants + +error[E0015]: cannot use `for` loop on `std::ops::Range` in constants + --> $DIR/loop.rs:53:14 + | +LL | for i in 0..4 { + | ^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0015]: cannot use `for` loop on `std::ops::Range` in constants + --> $DIR/loop.rs:59:14 + | +LL | for i in 0..4 { + | ^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants + +error[E0015]: cannot use `for` loop on `std::ops::Range` in constants + --> $DIR/loop.rs:59:14 + | +LL | for i in 0..4 { + | ^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/typeck/typeck_type_placeholder_item.rs b/tests/ui/typeck/typeck_type_placeholder_item.rs index 2eda0c5863471..7616e391a35a9 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.rs +++ b/tests/ui/typeck/typeck_type_placeholder_item.rs @@ -239,6 +239,5 @@ fn evens_squared(n: usize) -> _ { const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); //~^ ERROR the placeholder -//~| ERROR `Iterator` is not yet stable //~| ERROR cannot call //~| ERROR cannot call diff --git a/tests/ui/typeck/typeck_type_placeholder_item.stderr b/tests/ui/typeck/typeck_type_placeholder_item.stderr index 469c41b286a75..2772d55f953a8 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item.stderr @@ -678,27 +678,13 @@ LL | fn map(_: fn() -> Option<&'static T>) -> Option { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error[E0658]: cannot call conditionally-const method ` as Iterator>::filter::<{closure@$DIR/typeck_type_placeholder_item.rs:240:29: 240:32}>` in constants +error[E0015]: cannot call non-const method ` 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 - = note: see issue #143874 for more information - = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: `Iterator` is not yet stable as a const trait - --> $DIR/typeck_type_placeholder_item.rs:240:14 - | -LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: add `#![feature(const_iter)]` to the crate attributes to enable - | -LL + #![feature(const_iter)] - | error[E0015]: cannot call non-const method `, {closure@$DIR/typeck_type_placeholder_item.rs:240:29: 240:32}> as Iterator>::map::` in constants --> $DIR/typeck_type_placeholder_item.rs:240:45 @@ -708,7 +694,7 @@ 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 84 previous errors +error: aborting due to 83 previous errors -Some errors have detailed explanations: E0015, E0046, E0121, E0282, E0403, E0658. +Some errors have detailed explanations: E0015, E0046, E0121, E0282, E0403. For more information about an error, try `rustc --explain E0015`.