diff --git a/src/test/ui/consts/const-fn-error.rs b/src/test/ui/consts/const-fn-error.rs index 5884a893f8b7..50b7ce1f8c01 100644 --- a/src/test/ui/consts/const-fn-error.rs +++ b/src/test/ui/consts/const-fn-error.rs @@ -3,8 +3,10 @@ const X : usize = 2; const fn f(x: usize) -> usize { let mut sum = 0; for i in 0..x { - //~^ ERROR the trait bound + //~^ ERROR cannot convert //~| ERROR `for` is not allowed in a `const fn` + //~| ERROR mutable references are not allowed in constant functions + //~| ERROR cannot call non-const fn sum += i; } sum diff --git a/src/test/ui/consts/const-fn-error.stderr b/src/test/ui/consts/const-fn-error.stderr index 040de150659e..e36324f0b3ee 100644 --- a/src/test/ui/consts/const-fn-error.stderr +++ b/src/test/ui/consts/const-fn-error.stderr @@ -4,6 +4,8 @@ error[E0658]: `for` is not allowed in a `const fn` LL | / for i in 0..x { LL | | LL | | +LL | | +LL | | LL | | sum += i; LL | | } | |_____^ @@ -11,25 +13,37 @@ LL | | } = note: see issue #87575 for more information = help: add `#![feature(const_for)]` to the crate attributes to enable -error[E0277]: the trait bound `std::ops::Range: Iterator` is not satisfied - --> $DIR/const-fn-error.rs:5:14 - | -LL | for i in 0..x { - | ^^^^ `std::ops::Range` is not an iterator - | - = help: the trait `~const Iterator` is not implemented for `std::ops::Range` -note: the trait `Iterator` is implemented for `std::ops::Range`, but that implementation is not `const` +error[E0015]: cannot convert `std::ops::Range` into an iterator in constant functions --> $DIR/const-fn-error.rs:5:14 | LL | for i in 0..x { | ^^^^ - = note: required for `std::ops::Range` to implement `~const IntoIterator` -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement | -LL | const fn f(x: usize) -> usize where std::ops::Range: ~const Iterator { - | +++++++++++++++++++++++++++++++++++++++++++++ +note: impl defined here, but it is not `const` + --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + | +LL | impl const IntoIterator for I { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error: aborting due to 2 previous errors +error[E0658]: mutable references are not allowed in constant functions + --> $DIR/const-fn-error.rs:5:14 + | +LL | for i in 0..x { + | ^^^^ + | + = note: see issue #57349 for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable -Some errors have detailed explanations: E0277, E0658. -For more information about an error, try `rustc --explain E0277`. +error[E0015]: cannot call non-const fn ` as Iterator>::next` in constant functions + --> $DIR/const-fn-error.rs:5:14 + | +LL | for i in 0..x { + | ^^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0015, E0658. +For more information about an error, try `rustc --explain E0015`. diff --git a/src/test/ui/consts/const-for-feature-gate.rs b/src/test/ui/consts/const-for-feature-gate.rs index 8afc25fe3e57..bec7b8089053 100644 --- a/src/test/ui/consts/const-for-feature-gate.rs +++ b/src/test/ui/consts/const-for-feature-gate.rs @@ -3,7 +3,6 @@ const _: () = { for _ in 0..5 {} //~^ error: `for` is not allowed in a `const` - //~| error: the trait bound }; fn main() {} diff --git a/src/test/ui/consts/const-for-feature-gate.stderr b/src/test/ui/consts/const-for-feature-gate.stderr index f08879538914..2ea377e09f61 100644 --- a/src/test/ui/consts/const-for-feature-gate.stderr +++ b/src/test/ui/consts/const-for-feature-gate.stderr @@ -7,21 +7,6 @@ LL | for _ in 0..5 {} = note: see issue #87575 for more information = help: add `#![feature(const_for)]` to the crate attributes to enable -error[E0277]: the trait bound `std::ops::Range<{integer}>: Iterator` is not satisfied - --> $DIR/const-for-feature-gate.rs:4:14 - | -LL | for _ in 0..5 {} - | ^^^^ `std::ops::Range<{integer}>` is not an iterator - | - = help: the trait `~const Iterator` is not implemented for `std::ops::Range<{integer}>` -note: the trait `Iterator` is implemented for `std::ops::Range<{integer}>`, but that implementation is not `const` - --> $DIR/const-for-feature-gate.rs:4:14 - | -LL | for _ in 0..5 {} - | ^^^^ - = note: required for `std::ops::Range<{integer}>` to implement `~const IntoIterator` +error: aborting due to previous error -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0277, E0658. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/const-for.rs b/src/test/ui/consts/const-for.rs index c6e958a9a951..8db248535583 100644 --- a/src/test/ui/consts/const-for.rs +++ b/src/test/ui/consts/const-for.rs @@ -3,7 +3,8 @@ const _: () = { for _ in 0..5 {} - //~^ error: the trait bound + //~^ error: cannot call + //~| error: cannot convert }; fn main() {} diff --git a/src/test/ui/consts/const-for.stderr b/src/test/ui/consts/const-for.stderr index 56637536310b..f2e1c8a4991a 100644 --- a/src/test/ui/consts/const-for.stderr +++ b/src/test/ui/consts/const-for.stderr @@ -1,17 +1,24 @@ -error[E0277]: the trait bound `std::ops::Range<{integer}>: Iterator` is not satisfied - --> $DIR/const-for.rs:5:14 - | -LL | for _ in 0..5 {} - | ^^^^ `std::ops::Range<{integer}>` is not an iterator - | - = help: the trait `~const Iterator` is not implemented for `std::ops::Range<{integer}>` -note: the trait `Iterator` is implemented for `std::ops::Range<{integer}>`, but that implementation is not `const` +error[E0015]: cannot convert `std::ops::Range` into an iterator in constants --> $DIR/const-for.rs:5:14 | LL | for _ in 0..5 {} | ^^^^ - = note: required for `std::ops::Range<{integer}>` to implement `~const IntoIterator` + | +note: impl defined here, but it is not `const` + --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + | +LL | impl const IntoIterator for I { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error: aborting due to previous error +error[E0015]: cannot call non-const fn ` as Iterator>::next` in constants + --> $DIR/const-for.rs:5:14 + | +LL | for _ in 0..5 {} + | ^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants -For more information about this error, try `rustc --explain E0277`. +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0015`. diff --git a/src/test/ui/consts/control-flow/loop.rs b/src/test/ui/consts/control-flow/loop.rs index 36daa685c5aa..2b8561a26448 100644 --- a/src/test/ui/consts/control-flow/loop.rs +++ b/src/test/ui/consts/control-flow/loop.rs @@ -51,12 +51,10 @@ const _: i32 = { let mut x = 0; for i in 0..4 { //~ ERROR `for` is not allowed in a `const` - //~^ ERROR the trait bound x += i; } for i in 0..4 { //~ ERROR `for` is not allowed in a `const` - //~^ ERROR the trait bound x += i; } diff --git a/src/test/ui/consts/control-flow/loop.stderr b/src/test/ui/consts/control-flow/loop.stderr index 747729befde2..5f6ad8c105d7 100644 --- a/src/test/ui/consts/control-flow/loop.stderr +++ b/src/test/ui/consts/control-flow/loop.stderr @@ -2,7 +2,6 @@ error[E0658]: `for` is not allowed in a `const` --> $DIR/loop.rs:53:5 | LL | / for i in 0..4 { -LL | | LL | | x += i; LL | | } | |_____^ @@ -11,10 +10,9 @@ LL | | } = help: add `#![feature(const_for)]` to the crate attributes to enable error[E0658]: `for` is not allowed in a `const` - --> $DIR/loop.rs:58:5 + --> $DIR/loop.rs:57:5 | LL | / for i in 0..4 { -LL | | LL | | x += i; LL | | } | |_____^ @@ -22,35 +20,6 @@ LL | | } = note: see issue #87575 for more information = help: add `#![feature(const_for)]` to the crate attributes to enable -error[E0277]: the trait bound `std::ops::Range<{integer}>: Iterator` is not satisfied - --> $DIR/loop.rs:53:14 - | -LL | for i in 0..4 { - | ^^^^ `std::ops::Range<{integer}>` is not an iterator - | - = help: the trait `~const Iterator` is not implemented for `std::ops::Range<{integer}>` -note: the trait `Iterator` is implemented for `std::ops::Range<{integer}>`, but that implementation is not `const` - --> $DIR/loop.rs:53:14 - | -LL | for i in 0..4 { - | ^^^^ - = note: required for `std::ops::Range<{integer}>` to implement `~const IntoIterator` +error: aborting due to 2 previous errors -error[E0277]: the trait bound `std::ops::Range<{integer}>: Iterator` is not satisfied - --> $DIR/loop.rs:58:14 - | -LL | for i in 0..4 { - | ^^^^ `std::ops::Range<{integer}>` is not an iterator - | - = help: the trait `~const Iterator` is not implemented for `std::ops::Range<{integer}>` -note: the trait `Iterator` is implemented for `std::ops::Range<{integer}>`, but that implementation is not `const` - --> $DIR/loop.rs:58:14 - | -LL | for i in 0..4 { - | ^^^^ - = note: required for `std::ops::Range<{integer}>` to implement `~const IntoIterator` - -error: aborting due to 4 previous errors - -Some errors have detailed explanations: E0277, E0658. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/issues/issue-50582.rs b/src/test/ui/issues/issue-50582.rs index 9848cf0b0b1b..2d5c93587529 100644 --- a/src/test/ui/issues/issue-50582.rs +++ b/src/test/ui/issues/issue-50582.rs @@ -2,5 +2,4 @@ fn main() { Vec::<[(); 1 + for x in 0..1 {}]>::new(); //~^ ERROR cannot add //~| ERROR `for` is not allowed in a `const` - //~| ERROR the trait bound } diff --git a/src/test/ui/issues/issue-50582.stderr b/src/test/ui/issues/issue-50582.stderr index 3b1936bb58c5..53ecc6112ffe 100644 --- a/src/test/ui/issues/issue-50582.stderr +++ b/src/test/ui/issues/issue-50582.stderr @@ -7,20 +7,6 @@ LL | Vec::<[(); 1 + for x in 0..1 {}]>::new(); = note: see issue #87575 for more information = help: add `#![feature(const_for)]` to the crate attributes to enable -error[E0277]: the trait bound `std::ops::Range<{integer}>: Iterator` is not satisfied - --> $DIR/issue-50582.rs:2:29 - | -LL | Vec::<[(); 1 + for x in 0..1 {}]>::new(); - | ^^^^ `std::ops::Range<{integer}>` is not an iterator - | - = help: the trait `~const Iterator` is not implemented for `std::ops::Range<{integer}>` -note: the trait `Iterator` is implemented for `std::ops::Range<{integer}>`, but that implementation is not `const` - --> $DIR/issue-50582.rs:2:29 - | -LL | Vec::<[(); 1 + for x in 0..1 {}]>::new(); - | ^^^^ - = note: required for `std::ops::Range<{integer}>` to implement `~const IntoIterator` - error[E0277]: cannot add `()` to `{integer}` in const contexts --> $DIR/issue-50582.rs:2:18 | @@ -39,7 +25,7 @@ LL | Vec::<[(); 1 + for x in 0..1 {}]>::new(); <&'a isize as Add> and 48 others -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0277, E0658. For more information about an error, try `rustc --explain E0277`. diff --git a/src/test/ui/issues/issue-50585.rs b/src/test/ui/issues/issue-50585.rs index 3ec56739d4be..a2f11c98d5a3 100644 --- a/src/test/ui/issues/issue-50585.rs +++ b/src/test/ui/issues/issue-50585.rs @@ -2,5 +2,4 @@ fn main() { |y: Vec<[(); for x in 0..2 {}]>| {}; //~^ ERROR mismatched types //~| ERROR `for` is not allowed in a `const` - //~| ERROR the trait bound } diff --git a/src/test/ui/issues/issue-50585.stderr b/src/test/ui/issues/issue-50585.stderr index ecd69f771c31..e43cc20cbb57 100644 --- a/src/test/ui/issues/issue-50585.stderr +++ b/src/test/ui/issues/issue-50585.stderr @@ -7,27 +7,13 @@ LL | |y: Vec<[(); for x in 0..2 {}]>| {}; = note: see issue #87575 for more information = help: add `#![feature(const_for)]` to the crate attributes to enable -error[E0277]: the trait bound `std::ops::Range<{integer}>: Iterator` is not satisfied - --> $DIR/issue-50585.rs:2:27 - | -LL | |y: Vec<[(); for x in 0..2 {}]>| {}; - | ^^^^ `std::ops::Range<{integer}>` is not an iterator - | - = help: the trait `~const Iterator` is not implemented for `std::ops::Range<{integer}>` -note: the trait `Iterator` is implemented for `std::ops::Range<{integer}>`, but that implementation is not `const` - --> $DIR/issue-50585.rs:2:27 - | -LL | |y: Vec<[(); for x in 0..2 {}]>| {}; - | ^^^^ - = note: required for `std::ops::Range<{integer}>` to implement `~const IntoIterator` - error[E0308]: mismatched types --> $DIR/issue-50585.rs:2:18 | LL | |y: Vec<[(); for x in 0..2 {}]>| {}; | ^^^^^^^^^^^^^^^^ expected `usize`, found `()` -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0277, E0308, E0658. -For more information about an error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0308, E0658. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/never_type/issue-52443.rs b/src/test/ui/never_type/issue-52443.rs index 1b87e9168536..0498a8a16259 100644 --- a/src/test/ui/never_type/issue-52443.rs +++ b/src/test/ui/never_type/issue-52443.rs @@ -8,5 +8,7 @@ fn main() { [(); { for _ in 0usize.. {}; 0}]; //~^ ERROR `for` is not allowed in a `const` - //~| ERROR the trait bound + //~| ERROR cannot convert + //~| ERROR mutable references + //~| ERROR cannot call } diff --git a/src/test/ui/never_type/issue-52443.stderr b/src/test/ui/never_type/issue-52443.stderr index 4a89d4f6d37c..3c0daa4c55f0 100644 --- a/src/test/ui/never_type/issue-52443.stderr +++ b/src/test/ui/never_type/issue-52443.stderr @@ -38,25 +38,37 @@ LL | [(); loop { break }]; | expected `usize`, found `()` | help: give it a value of the expected type: `break 42` -error[E0277]: the trait bound `RangeFrom: Iterator` is not satisfied - --> $DIR/issue-52443.rs:9:21 - | -LL | [(); { for _ in 0usize.. {}; 0}]; - | ^^^^^^^^ `RangeFrom` is not an iterator - | - = help: the trait `~const Iterator` is not implemented for `RangeFrom` -note: the trait `Iterator` is implemented for `RangeFrom`, but that implementation is not `const` +error[E0015]: cannot convert `RangeFrom` into an iterator in constants --> $DIR/issue-52443.rs:9:21 | LL | [(); { for _ in 0usize.. {}; 0}]; | ^^^^^^^^ - = note: required for `RangeFrom` to implement `~const IntoIterator` -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement | -LL | fn main() where RangeFrom: ~const Iterator { - | +++++++++++++++++++++++++++++++++++++++ +note: impl defined here, but it is not `const` + --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + | +LL | impl const IntoIterator for I { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error: aborting due to 4 previous errors; 1 warning emitted +error[E0658]: mutable references are not allowed in constants + --> $DIR/issue-52443.rs:9:21 + | +LL | [(); { for _ in 0usize.. {}; 0}]; + | ^^^^^^^^ + | + = note: see issue #57349 for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable -Some errors have detailed explanations: E0277, E0308, E0658. -For more information about an error, try `rustc --explain E0277`. +error[E0015]: cannot call non-const fn ` as Iterator>::next` in constants + --> $DIR/issue-52443.rs:9:21 + | +LL | [(); { for _ in 0usize.. {}; 0}]; + | ^^^^^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants + +error: aborting due to 6 previous errors; 1 warning emitted + +Some errors have detailed explanations: E0015, E0308, E0658. +For more information about an error, try `rustc --explain E0015`. diff --git a/src/test/ui/ufcs/ufcs-qpath-self-mismatch.rs b/src/test/ui/ufcs/ufcs-qpath-self-mismatch.rs index ec86213f8629..1a07dc46c5e8 100644 --- a/src/test/ui/ufcs/ufcs-qpath-self-mismatch.rs +++ b/src/test/ui/ufcs/ufcs-qpath-self-mismatch.rs @@ -4,6 +4,7 @@ fn main() { >::add(1, 2); //~^ ERROR cannot add `u32` to `i32` //~| ERROR cannot add `u32` to `i32` + //~| ERROR cannot add `u32` to `i32` >::add(1u32, 2); //~^ ERROR mismatched types >::add(1, 2u32); diff --git a/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr b/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr index eaab6ff3d9a0..22647622128c 100644 --- a/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr +++ b/src/test/ui/ufcs/ufcs-qpath-self-mismatch.stderr @@ -18,8 +18,26 @@ LL | >::add(1, 2); <&'a isize as Add> and 48 others +error[E0277]: cannot add `u32` to `i32` + --> $DIR/ufcs-qpath-self-mismatch.rs:4:5 + | +LL | >::add(1, 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `i32 + u32` + | + = help: the trait `Add` is not implemented for `i32` + = help: the following other types implement trait `Add`: + <&'a f32 as Add> + <&'a f64 as Add> + <&'a i128 as Add> + <&'a i16 as Add> + <&'a i32 as Add> + <&'a i64 as Add> + <&'a i8 as Add> + <&'a isize as Add> + and 48 others + error[E0308]: mismatched types - --> $DIR/ufcs-qpath-self-mismatch.rs:7:28 + --> $DIR/ufcs-qpath-self-mismatch.rs:8:28 | LL | >::add(1u32, 2); | ---------------------- ^^^^ expected `i32`, found `u32` @@ -37,7 +55,7 @@ LL | >::add(1i32, 2); | ~~~ error[E0308]: mismatched types - --> $DIR/ufcs-qpath-self-mismatch.rs:9:31 + --> $DIR/ufcs-qpath-self-mismatch.rs:10:31 | LL | >::add(1, 2u32); | ---------------------- ^^^^ expected `i32`, found `u32` @@ -72,7 +90,7 @@ LL | >::add(1, 2); <&'a isize as Add> and 48 others -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors Some errors have detailed explanations: E0277, E0308. For more information about an error, try `rustc --explain E0277`.