Skip to content

Commit ed912d9

Browse files
authored
Rollup merge of rust-lang#81939 - kper:fixing-81584-allocate-in-iter, r=davidtwco
Add suggestion `.collect()` for iterators in iterators Closes rust-lang#81584 ``` error[E0515]: cannot return value referencing function parameter `y` --> main3.rs:4:38 | 4 | ... .map(|y| y.iter().map(|x| x + 1)) | -^^^^^^^^^^^^^^^^^^^^^^ | | | returns a value referencing data owned by the current function | `y` is borrowed here | help: Maybe use `.collect()` to allocate the iterator ``` Added the suggestion: `help: Maybe use `.collect()` to allocate the iterator`
2 parents 3eeb2e5 + 2661194 commit ed912d9

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

core/src/iter/traits/iterator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ fn _assert_is_object_safe(_: &dyn Iterator<Item = ()>) {}
9393
message = "`{Self}` is not an iterator"
9494
)]
9595
#[doc(spotlight)]
96+
#[rustc_diagnostic_item = "Iterator"]
9697
#[must_use = "iterators are lazy and do nothing unless consumed"]
9798
pub trait Iterator {
9899
/// The type of the elements being iterated over.

0 commit comments

Comments
 (0)