Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak wording of collect() on bad target type #66764

Merged
merged 1 commit into from
Dec 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libcore/iter/traits/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_on_unimplemented(
message="a collection of type `{Self}` cannot be built from an iterator \
message="a value of type `{Self}` cannot be built from an iterator \
over elements of type `{A}`",
label="a collection of type `{Self}` cannot be built from `std::iter::Iterator<Item={A}>`",
label="value of type `{Self}` cannot be built from `std::iter::Iterator<Item={A}>`",
)]
pub trait FromIterator<A>: Sized {
/// Creates a value from an iterator.
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/type/type-check-defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use std::ops::Add;

struct Foo<T, U: FromIterator<T>>(T, U);
struct WellFormed<Z = Foo<i32, i32>>(Z);
//~^ ERROR a collection of type `i32` cannot be built from an iterator over elements of type `i32`
//~^ ERROR a value of type `i32` cannot be built from an iterator over elements of type `i32`
struct WellFormedNoBounds<Z:?Sized = Foo<i32, i32>>(Z);
//~^ ERROR a collection of type `i32` cannot be built from an iterator over elements of type `i32`
//~^ ERROR a value of type `i32` cannot be built from an iterator over elements of type `i32`

struct Bounds<T:Copy=String>(T);
//~^ ERROR the trait bound `std::string::String: std::marker::Copy` is not satisfied [E0277]
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/type/type-check-defaults.stderr
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
error[E0277]: a collection of type `i32` cannot be built from an iterator over elements of type `i32`
error[E0277]: a value of type `i32` cannot be built from an iterator over elements of type `i32`
--> $DIR/type-check-defaults.rs:6:19
|
LL | struct Foo<T, U: FromIterator<T>>(T, U);
| ---------------------------------------- required by `Foo`
LL | struct WellFormed<Z = Foo<i32, i32>>(Z);
| ^ a collection of type `i32` cannot be built from `std::iter::Iterator<Item=i32>`
| ^ value of type `i32` cannot be built from `std::iter::Iterator<Item=i32>`
|
= help: the trait `std::iter::FromIterator<i32>` is not implemented for `i32`

error[E0277]: a collection of type `i32` cannot be built from an iterator over elements of type `i32`
error[E0277]: a value of type `i32` cannot be built from an iterator over elements of type `i32`
--> $DIR/type-check-defaults.rs:8:27
|
LL | struct Foo<T, U: FromIterator<T>>(T, U);
| ---------------------------------------- required by `Foo`
...
LL | struct WellFormedNoBounds<Z:?Sized = Foo<i32, i32>>(Z);
| ^ a collection of type `i32` cannot be built from `std::iter::Iterator<Item=i32>`
| ^ value of type `i32` cannot be built from `std::iter::Iterator<Item=i32>`
|
= help: the trait `std::iter::FromIterator<i32>` is not implemented for `i32`

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/type/type-dependent-def-issue-49241.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ fn main() {
const l: usize = v.count(); //~ ERROR attempt to use a non-constant value in a constant
let s: [u32; l] = v.into_iter().collect();
//~^ ERROR evaluation of constant value failed
//~^^ ERROR a collection of type
//~^^ ERROR a value of type
}
4 changes: 2 additions & 2 deletions src/test/ui/type/type-dependent-def-issue-49241.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ error[E0080]: evaluation of constant value failed
LL | let s: [u32; l] = v.into_iter().collect();
| ^ referenced constant has errors

error[E0277]: a collection of type `[u32; _]` cannot be built from an iterator over elements of type `{integer}`
error[E0277]: a value of type `[u32; _]` cannot be built from an iterator over elements of type `{integer}`
--> $DIR/type-dependent-def-issue-49241.rs:4:37
|
LL | let s: [u32; l] = v.into_iter().collect();
| ^^^^^^^ a collection of type `[u32; _]` cannot be built from `std::iter::Iterator<Item={integer}>`
| ^^^^^^^ value of type `[u32; _]` cannot be built from `std::iter::Iterator<Item={integer}>`
|
= help: the trait `std::iter::FromIterator<{integer}>` is not implemented for `[u32; _]`

Expand Down