Unused lifetime in params when is-copy = false

オープン
#282 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
postgresql, rust
領域
backend, databases

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Rust
スター
1.2k
フォーク
77
平均マージ
5日 12時間
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

cornucopia-rs/cornucopia のほかの issue

cornucopia-rs/cornucopia の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。