Skip to content

Unused lifetime in params when is-copy = false #282

@LouisGariepy

Description

@LouisGariepy

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#186 that had similar for the return types

Severity

Annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    codegenAn issue regarding code generation, or the generated code itself.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions