desktop M10.4: fix stmt lifetime in reminders/search
Desktop (Tauri) / Tauri desktop (Linux) (push) Successful in 3m20s

Both chained `stmt.query_map(...)?.collect()?` as the block's tail expression,
so the prepared statement (a block local) was dropped before the borrow held by
the mapped rows ended (E0597). Bind `let rows` first, matching every other query
in the file. rustc error, so this also unblocks test + the release build.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FRgehjoz7Yv8LkUfADxACm
This commit is contained in:
2026-07-24 23:10:22 -04:00
co-authored by Claude Opus 4.8
parent 41cf4b3598
commit 3958db0a8b
+4 -4
View File
@@ -302,8 +302,8 @@ pub fn reminders(conn: &Connection) -> rusqlite::Result<Vec<Note>> {
let ids: Vec<String> = { let ids: Vec<String> = {
let mut stmt = let mut stmt =
conn.prepare("SELECT id FROM notes WHERE trashed = 0 AND remind_at IS NOT NULL ORDER BY remind_at ASC")?; conn.prepare("SELECT id FROM notes WHERE trashed = 0 AND remind_at IS NOT NULL ORDER BY remind_at ASC")?;
stmt.query_map([], |r| r.get::<_, String>(0))? let rows = stmt.query_map([], |r| r.get::<_, String>(0))?;
.collect::<rusqlite::Result<Vec<String>>>()? rows.collect::<rusqlite::Result<Vec<String>>>()?
}; };
ids.iter().map(|id| load_note(conn, id)).collect() ids.iter().map(|id| load_note(conn, id)).collect()
} }
@@ -327,8 +327,8 @@ pub fn search(conn: &Connection, q: &str) -> rusqlite::Result<Vec<Note>> {
let mut stmt = conn.prepare( let mut stmt = conn.prepare(
"SELECT id FROM notes WHERE trashed = 0 AND (title LIKE ?1 ESCAPE '\\' OR body LIKE ?1 ESCAPE '\\') ORDER BY updated_at DESC", "SELECT id FROM notes WHERE trashed = 0 AND (title LIKE ?1 ESCAPE '\\' OR body LIKE ?1 ESCAPE '\\') ORDER BY updated_at DESC",
)?; )?;
stmt.query_map([&pat], |r| r.get::<_, String>(0))? let rows = stmt.query_map([&pat], |r| r.get::<_, String>(0))?;
.collect::<rusqlite::Result<Vec<String>>>()? rows.collect::<rusqlite::Result<Vec<String>>>()?
}; };
ids.iter().map(|id| load_note(conn, id)).collect() ids.iter().map(|id| load_note(conn, id)).collect()
} }