Skip to content

Query::map is broken because lazy norm on HRTBs equals confusion #1001

Open
@mehcode

Description

@mehcode
async fn test(conn: PgPool) {
    use crate::row::Row;
    let value = crate::query::query::<Postgres>("select 1 + 1")
        .map(|row: PgRow| row.get::<i32, _>(0))
        .fetch_all(&conn)
        .await
        .unwrap();
}
error[E0599]: no method named `fetch_all` found for struct `query::Map<'_, Postgres, impl std::marker::Send+FnMut<(<Postgres as Database>::Row,)>, PgArguments>` in the current scope
  --> sqlx-core/src/postgres/mod.rs:48:10
   |
48 |         .fetch_all(&conn)
   |          ^^^^^^^^^ method not found in `query::Map<'_, Postgres, impl std::marker::Send+FnMut<(<Postgres as Database>::Row,)>, PgArguments>`
   |
  ::: sqlx-core/src/query.rs:34:1
   |
34 | pub struct Map<'q, DB: Database, F, A> {
   | -------------------------------------- method `fetch_all` not found for this
   |
   = note: the method `fetch_all` exists but the following trait bounds were not satisfied:
           `<impl std::marker::Send+FnMut<(<Postgres as Database>::Row,)> as FnOnce<(PgRow,)>>::Output = std::result::Result<_, error::Error>`
           `impl std::marker::Send+FnMut<(<Postgres as Database>::Row,)>: FnMut<(PgRow,)>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
error: could not compile `sqlx-core`

From https://discord.com/channels/665528275556106240/665528275556106243/801701725001875458

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfix-HRTB-plsIssues relating to Higher Ranked Trait Bounds in Rust

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions