Skip to content

turnloop-mongodb: CursorBatch::rows() over-captures under Rust 2024, failing to compile with E0597 #69

Description

@proggeramlug

Problem

CursorBatch::rows(), declared as pub fn rows(&self) -> impl Iterator<Item = Result<&'a RawDocument>>, captures &self in its returned impl Iterator in addition to the 'a lifetime it's parameterized over. Under Rust 2024's capture rules, code like match batch.rows().next() { ... } in tail position fails to compile with E0597 ("borrowed value does not live long enough").

Why it matters

Perry's P7 lane calls this "a one-line fix that will otherwise bite every host" of turnloop-mongodb compiled under Rust 2024 — rustc itself suggests the fix.

What would fix it

Adding + use<'a> to the impl Iterator return type, exactly as rustc's own diagnostic suggests, so the returned iterator only captures the lifetime it actually needs rather than also capturing &self.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions