-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.Diagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.F-gen_blocks`gen {}` expressions that produce `Iterator`s`gen {}` expressions that produce `Iterator`sT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
With the following in CrateMetadata
(compiler/rustc_metadata/src/rmeta/decoder.rs
), where we are using generators that need a move
:
pub(crate) fn proc_macros_for_crate(
&self,
krate: CrateNum,
cstore: &CStore,
) -> impl Iterator<Item = DefId> {
gen move {
for def_id in self.root.proc_macro_data.as_ref().into_iter().flat_map(|data| {
data.macros
.decode(CrateMetadataRef { cdata: self, cstore })
.map(move |index| DefId { index, krate })
}) {
yield def_id;
}
}
}
we currently emit
error[E0626]: borrow may still be in use when `gen` block yields
--> compiler/rustc_metadata/src/rmeta/decoder.rs:2026:49
|
2022 | gen move {
| -------- within this `gen` block
...
2026 | .map(|index| DefId { index, krate })
| ^^^^^
2027 | }) {
2028 | yield def_id;
| ------------ possible yield occurs here
which doesn't suggest .map(move |index| DefId { index, krate })
.
If we remove any of the other move
for the other closure or the gen
, we do get the appropriate suggestion.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-lack-of-suggestionDiagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.Diagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.F-gen_blocks`gen {}` expressions that produce `Iterator`s`gen {}` expressions that produce `Iterator`sT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.