-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-iteratorsArea: IteratorsArea: IteratorsC-bugCategory: This is a bug.Category: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
I tried this code:
let mut i = 0;
let iterator = repeat_with(move || {
i += 1;
i
});
let _ = iterator.take(1);
let _ = iterator.take(1);
I expected to see this happen:
This should fail to compile with an error like "use of moved value: iterator
"
Instead, this happened:
It compiles and creates a copy of the iterator.
Meta
rustc --version --verbose
:
rustc 1.89.0 (29483883e 2025-08-04)
binary: rustc
commit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2
commit-date: 2025-08-04
host: x86_64-unknown-linux-gnu
release: 1.89.0
LLVM version: 20.1.7
Metadata
Metadata
Assignees
Labels
A-iteratorsArea: IteratorsArea: IteratorsC-bugCategory: This is a bug.Category: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.