-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suggest using
iter()
or into_iter()
for Vec
We cannot do that for `&Vec` because `#[rustc_on_unimplemented]` is limited (it does not clean generic instantiation for references, only for ADTs).
- Loading branch information
1 parent
47aee31
commit 456f1ff
Showing
3 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fn main() { | ||
vec![true, false].map(|v| !v).collect::<Vec<_>>(); | ||
//~^ ERROR `Vec<bool>` is not an iterator | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
error[E0599]: `Vec<bool>` is not an iterator | ||
--> $DIR/vec-on-unimplemented.rs:2:23 | ||
| | ||
LL | vec![true, false].map(|v| !v).collect::<Vec<_>>(); | ||
| ^^^ `Vec<bool>` is not an iterator; try calling `.into_iter()` or `.iter()` | ||
| | ||
::: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | ||
| | ||
LL | pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> { | ||
| ------------------------------------------------------------------------------------------------ doesn't satisfy `Vec<bool>: Iterator` | ||
| | ||
= note: the following trait bounds were not satisfied: | ||
`Vec<bool>: Iterator` | ||
which is required by `&mut Vec<bool>: Iterator` | ||
`[bool]: Iterator` | ||
which is required by `&mut [bool]: Iterator` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0599`. |