Open Wopple opened 1 year ago
#[repr(i32)]
it compiles.other: i32,
it compiles.With both of those, it does not compile.
Same happens with Option enum.
I suppose there is no movement on this? It's a blocking issue for me so just wondering
I upgraded rust from nightly-2023-11-09 to nightly-2024-07-02 and started facing the same issue with f32
#[derive(Debug, sqlx::Type, Serialize, Deserialize)]
#[sqlx(type_name = "margin_setting")]
pub struct MarginSetting {
pub min_price: f32,
pub max_price: f32,
pub margin: f32,
}
error: implementation of `sqlx::Decode` is not general enough
--> shared\src\database\custom_types\margin_settings.rs:4:17
|
4 | #[derive(Debug, sqlx::Type, Serialize, Deserialize)]
| ^^^^^^^^^^ implementation of `sqlx::Decode` is not general enough
|
= note: `f32` must implement `sqlx::Decode<'0, Postgres>`, for any lifetime `'0`...
= note: ...but it actually implements `sqlx::Decode<'1, Postgres>`, for some specific lifetime `'1`
= note: this error originates in the derive macro `sqlx::Type` (in Nightly builds, run with -Z macro-backtrace for more info)
error: lifetime may not live long enough
--> shared\src\database\custom_types\margin_settings.rs:4:17
|
4 | #[derive(Debug, sqlx::Type, Serialize, Deserialize)]
| ^^^^^^^^^^
| |
| lifetime `'r` defined here
| requires that `'r` must outlive `'static`
|
note: due to current limitations in the borrow checker, this implies a `'static` lifetime
--> C:\Users\Tim\.cargo\registry\src\index.crates.io-6f17d22bba15001f\sqlx-postgres-0.7.4\src\types\record.rs:97:12
|
97 | T: for<'a> Decode<'a, Postgres> + Type<Postgres>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the derive macro `sqlx::Type` (in Nightly builds, run with -Z macro-backtrace for more info)
Bug Description
I'm trying to derive postgres / sqlx types for:
This is creating a compiler error due to lifetime constraints which is weird to me since I'm not using references. Even when I implement copy semantics I get the same error.
Minimal Reproduction
Error 1:
Error 2:
Info
version = "0.6"
features = ["postgres", "runtime-actix-rustls"]
rustc --version
:rustc 1.71.0 (8ede3aae2 2023-07-12)