Decode with postgres: hr bound for fields
#3195
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #3185
expands to the following impl for
Decodedecoder.try_decodehas the following bound:sqlx/sqlx-postgres/src/types/record.rs
Line 97 in 03926de
The where-bound only provides
Decodefor a concrete lifetime'rhowever. This previously compiled because the compiler eagerly rejected the where-bound and used the more general impl. This behavior has changed in rust-lang/rust#119820.It would have already been broken before rust-lang/rust#119820 if the type of
awere generic, e.g.However, this currently results in an unrelated error as the expansion does not add the generic arguments to
Foo, resulting inI first tried to change
try_decodeto not require a higher-ranked bound, requiringT: Decode<'r, Postgres>instead. However, we need the higher ranked bound asT::decodeis called with a local buffer:sqlx/sqlx-postgres/src/types/record.rs
Lines 184 to 201 in 03926de
I therefore ended up changing the
deriveto require a higher ranked bound instead. I tested this locally but did not add a test for this as I didn't immediately understand your test suite 😅