Skip to content
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

explicitly provide type argument to avoid breakage in future Rust versions #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lcnr
Copy link

@lcnr lcnr commented Jan 20, 2025

D1Backend has multiple where-bounds for HasSqlType due to the super-traits of diesel::backend::Backend: HasSqlType<SmallInt>, HasSqlType<Integer>, and others. It also has one where-bound which references a generic parameter, i.e. which is non-global: HasSqlType<T>.

The compiler previously preferred such non-global where-bounds over global1 where-bounds in some cases, guiding type inference. This behavior was quite subtle and inconsistent, so we've reworked the implementation in rust-lang/rust#132325.

Because of this, we no longer infer the type argument of <D1Backend as HasSqlType<_>>::metadata to T as using SmallInt or Integer is just as valid and would also allow this code to compile. The change in inference behavior will likely be stable in version 1.85. This PR modifies your code to make the used type explicit, allowing your crate to compile in future Rust versions.

Footnotes

  1. pretty much: a where-bound which does not mention any generic parameters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant