-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop GAT workarounds #3395
Drop GAT workarounds #3395
Conversation
Tests seems to fail because of GAT not stable 🤔 |
diesel/.github/workflows/ci.yml Line 298 in f560c29
|
diesel/src/row.rs
Outdated
/// Field type returned by a `Row` implementation | ||
/// | ||
/// * Crates using existing backend should not concern themself with the | ||
/// concrete type of this associated type. | ||
/// | ||
/// * Crates implementing custom backends should provide their own type | ||
/// meeting the required trait bounds | ||
type Field: Field<'a, DB>; | ||
type Field<'a>: Field<'a, DB>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why doesn't this move on the Row
trait?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to keep the associated type on RowSealed in order to express FieldRet without the lifetime of Row
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explained in the commit message and additional doc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check if pub type FieldRet<'a, R, DB> = <R as Row<'a, DB>>::Field<'a>;
works for all provided cases? If that's the case I would rather move the Field
GAT to Row
instead of having another trait for this.
Likely needs some msrv upgrade, compile tests output regeneration and some clippy stuff |
Clippy warnings seems to be mostly unrelevant. For the elided lifetime, it is required and I really don't think |
The compile error comes from a warning that's also generated and seems to be a bug from Rust, as it complains for the experimental feature when it's actually feature-flagged out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening this PR 👍
I've left a number of comments about which parts should be changed so that it is clearer for potential users what the the corresponding types look like.
For the clippy/ci stuff: I've opened #3396 to address that.
.github/workflows/ci.yml
Outdated
@@ -295,7 +295,7 @@ jobs: | |||
- uses: actions/checkout@v3 | |||
- uses: dtolnay/rust-toolchain@master | |||
with: | |||
toolchain: nightly-2022-08-12 | |||
toolchain: nightly-2022-11-05 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This likely requires rerunning the compile tests with TRYBUILD=overwrite
+ committing all the changes.
@@ -423,11 +423,11 @@ jobs: | |||
run: cargo +nightly -Z build-std test --manifest-path diesel/Cargo.toml --no-default-features --features "sqlite extras libsqlite3-sys libsqlite3-sys/bundled libsqlite3-sys/with-asan" --target x86_64-unknown-linux-gnu | |||
|
|||
minimal_rust_version: | |||
name: Check Minimal supported rust version (1.60.0) | |||
name: Check Minimal supported rust version (1.65.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires an change log entry.
diesel/src/connection/mod.rs
Outdated
/// The cursor type returned by [`LoadConnection::load`] | ||
/// | ||
/// Users should handle this as opaque type that implements [`Iterator`] | ||
type Cursor<'conn, 'query>: Iterator<Item = QueryResult<Self::Row<'conn, 'query>>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The LoadConnection::load
method should be changed so that it returns QueryResult<Self::Cursor<'conn, 'query>
now. I think that's much easier to understand for potential users + it's the same type as before.
diesel/src/connection/mod.rs
Outdated
@@ -40,7 +40,17 @@ pub trait SimpleConnection { | |||
/// | |||
/// Users should threat this type as `impl Iterator<Item = QueryResult<impl Row<DB>>>` | |||
pub type LoadRowIter<'conn, 'query, C, DB, B = DefaultLoadingMode> = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type can be deprecated. (It should be behind the with-deprecated
feature flag + removed for the without-deprecated
flag)
diesel/src/row.rs
Outdated
@@ -29,15 +29,15 @@ pub trait RowIndex<I> { | |||
/// Return type of [`Row::get`] | |||
/// | |||
/// Users should threat this as opaque [`impl Field<DB>`](Field) type. | |||
pub type FieldRet<'a, R, DB> = <R as RowGatWorkaround<'a, DB>>::Field; | |||
pub type FieldRet<'a, R, DB> = <R as RowFieldLifetimeHelper<DB>>::Field<'a>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type should be deprecated as well
diesel/src/row.rs
Outdated
/// Field type returned by a `Row` implementation | ||
/// | ||
/// * Crates using existing backend should not concern themself with the | ||
/// concrete type of this associated type. | ||
/// | ||
/// * Crates implementing custom backends should provide their own type | ||
/// meeting the required trait bounds | ||
type Field: Field<'a, DB>; | ||
type Field<'a>: Field<'a, DB>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check if pub type FieldRet<'a, R, DB> = <R as Row<'a, DB>>::Field<'a>;
works for all provided cases? If that's the case I would rather move the Field
GAT to Row
instead of having another trait for this.
It looks like |
Yes |
@Elrendio Do you plan to follow up onto the comments above? |
ad8c0b6
to
464ef34
Compare
7fe9dd4
to
8a9c304
Compare
This is currently blocked on rust-lang/rust#106417 and on a trybuild release containing dtolnay/trybuild#213 |
146b3b7
to
16433b6
Compare
16433b6
to
6921fe2
Compare
076ea8a
to
cab0bdc
Compare
What it does:
Good to know:
ConnectionSealed
is kept to keep the feature gate around the Connection implementation.RowFieldLifetimeHelper
in order to expressFieldRet
without the lifetime ofRow
1.60.0
to1.65.0