@@ -4,32 +4,46 @@ error[E0658]: `for` is not allowed in a `const fn`
44LL | / for i in 0..x {
55LL | |
66LL | |
7+ LL | |
8+ LL | |
79LL | | sum += i;
810LL | | }
911 | |_____^
1012 |
1113 = note: see issue #87575 <https://github.com/rust-lang/rust/issues/87575> for more information
1214 = help: add `#![feature(const_for)]` to the crate attributes to enable
1315
14- error[E0277 ]: the trait bound `std::ops::Range<usize>: Iterator` is not satisfied
16+ error[E0015 ]: cannot convert `std::ops::Range<usize>` into an iterator in constant functions
1517 --> $DIR/const-fn-error.rs:5:14
1618 |
1719LL | for i in 0..x {
18- | ^^^^ `std::ops::Range<usize>` is not an iterator
20+ | ^^^^
1921 |
20- = help: the trait `~const Iterator` is not implemented for `std::ops::Range<usize>`
21- note: the trait `Iterator` is implemented for `std::ops::Range<usize>`, but that implementation is not `const`
22+ note: impl defined here, but it is not `const`
23+ --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
24+ |
25+ LL | impl<I: ~const Iterator> const IntoIterator for I {
26+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27+ = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
28+
29+ error[E0658]: mutable references are not allowed in constant functions
30+ --> $DIR/const-fn-error.rs:5:14
31+ |
32+ LL | for i in 0..x {
33+ | ^^^^
34+ |
35+ = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
36+ = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
37+
38+ error[E0015]: cannot call non-const fn `<std::ops::Range<usize> as Iterator>::next` in constant functions
2239 --> $DIR/const-fn-error.rs:5:14
2340 |
2441LL | for i in 0..x {
2542 | ^^^^
26- = note: required for `std::ops::Range<usize>` to implement `~const IntoIterator`
27- help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
2843 |
29- LL | const fn f(x: usize) -> usize where std::ops::Range<usize>: ~const Iterator {
30- | +++++++++++++++++++++++++++++++++++++++++++++
44+ = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
3145
32- error: aborting due to 2 previous errors
46+ error: aborting due to 4 previous errors
3347
34- Some errors have detailed explanations: E0277 , E0658.
35- For more information about an error, try `rustc --explain E0277 `.
48+ Some errors have detailed explanations: E0015 , E0658.
49+ For more information about an error, try `rustc --explain E0015 `.
0 commit comments