Unused lifetime in params when is-copy = false

Aperta
#282 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
postgresql, rust
Ambito
backend, databases

Direzione di ricerca

Start by finding the code that generates query parameter structs and borrowed row structs for mappings with is-copy = false; the issue shows the generated output in crates/clorinde/src/queries/repro.rs. Trace how generated lifetimes are added when mapped fields do not borrow data, then check the generated structs compile without unused lifetime errors for the provided pgvector mapping and query.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

codegen

Migrated from halcyonnouveau/clorinde#257, originally reported by @SinnySupernova on 2026-05-09.

Describe the bug

I'm mapping pgvector and having compiler tell me about unsed lifetime:

error[E0392]: lifetime parameter `'a` is never used
 --> crates/clorinde/src/queries/repro.rs:4:32
  |
4 | pub struct SearchVectorsParams<'a> {
  |                                ^^ unused lifetime parameter
  |
  = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`

error[E0392]: lifetime parameter `'a` is never used
  --> crates/clorinde/src/queries/repro.rs:13:30
   |
13 | pub struct VectorRowBorrowed<'a> {
   |                              ^^ unused lifetime parameter
   |
   = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`

Reproduction

clorinde.toml (tried with or without borrowed-type)

[types.mapping]
"public.vector" = { rust-type = "pgvector::Vector", borrowed-type = "pgvector::Vector", is-copy = false }

query

--! search_vectors : VectorRow()
SELECT id, embedding FROM vectors
ORDER BY embedding <=> :query_embedding
LIMIT :limit;

result struct file

// This file was generated with `clorinde`. Do not modify.

#[derive(Debug)]
pub struct SearchVectorsParams<'a> {
    pub query_embedding: pgvector::Vector,
    pub limit: i64,
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct VectorRow {
    pub id: uuid::Uuid,
    pub embedding: pgvector::Vector,
}
pub struct VectorRowBorrowed<'a> {
    pub id: uuid::Uuid,
    pub embedding: pgvector::Vector,
}
impl<'a> From<VectorRowBorrowed<'a>> for VectorRow {
    fn from(VectorRowBorrowed { id, embedding }: VectorRowBorrowed<'a>) -> Self {
        Self {
            id,
            embedding: embedding.into(),
        }
    }
}
// ... more stuff
Expected behavior

no angry compiler

Logs

Additional context

there is halcyonnouveau/clorinde#186 that had similar for the return types

Severity

Annoyance

Lingua principale
Rust
Stelle
1.2k
Fork
77
Merge medio
5g 12h
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cornucopia-rs/cornucopia

Tutte le issue di cornucopia-rs/cornucopia

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.