-
-
Notifications
You must be signed in to change notification settings - Fork 89
RunQueryDsl overrides calls to vec.first() to RunQueryDsl::first() #142
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
Comments
Thanks for filling this bug report. I've changed it to be tracked as feature request, as it's strictly speaking not a bug. We are happy to receive a PR that improves this as long as it does not break existing code. |
I tried reading into it but did not quite understand, how does the trait work at the current moment? Does it try to infer any |
The relevant implementation is here: diesel_async/src/run_query_dsl/mod.rs Lines 626 to 637 in 1ef43d2
That one essentially says that this method is only available for types that implement |
As I understand it, the behavior of method resolution is that for a particular receiver type, the compiler looks first for inherent methods, and if that fails, then it looks for methods provided by visible traits ( One might expect the inherent As per https://doc.rust-lang.org/reference/expressions/method-call-expr.html, the algorithm is run in order for candidate receiver types, and |
For those looking for a workaround you can use: |
I think this is essentially another duplicate of rust-lang/rust#127306. Closed as this is an upstream rust bug. |
This resolves issue weiznich#142 As it more closely matches the Ts that diesel::RunQueryDsl is implemented for as opposed to all Ts
This resolves issue weiznich#142 As it more closely matches the Ts that diesel::RunQueryDsl is implemented for as opposed to all Ts
This resolves issue weiznich#142 As it more closely matches the Ts that diesel::RunQueryDsl is implemented for as opposed to all Ts
Setup
RunQueryDsl overrides calls to vec.first to RunQueryDsl::first() this happens to all possible calls to first() if the trait is imported.
Versions
Feature Flags
Problem Description
The
diesel_async::RunQueryDsl
trait overrides the default behavior of any structsfirst()
function to RunQueryDsl::first causing a nasty compile time error.What are you trying to accomplish?
I wish to use the vec.first() operation instead of vec.get(0). (Mainly becuase clippy errors, but this is a pretty hard bug to find).
Steps to reproduce
Here is a gist that shows the issue at hand.
https://gist.github.com/fastfists/9d0f1da80f825be39f9a4499aa8990a7
Checklist
closed if this is not the case)
The text was updated successfully, but these errors were encountered: