-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Some diesel trait resolution remains broken #14607
Comments
fix: Resolve `$crate` in derive paths Paths in derive meta item list may contain any kind of paths, including those that start with `$crate` generated by macros. We need to take hygiene into account when we lower paths in the list. This issue was identified while investigating #14607, though this patch doesn't fix the broken trait resolution.
One of the ultimate causes of this bug is same as #14369, for which I submitted rust-lang/chalk#792. Because of this, chalk fails to normalize Note that rust-lang/chalk#792 only fixes some issues and introduces a few new type mismatches (see the image below taken with my custom-built rust-analyzer with the chalk patch applied). I had analyzed this regression before submitting the patch, and it's not because the patch is wrong, I believe, but because it uncovers another consequence of rust-lang/chalk#584. I'd rather not write in details on this as it's complicated, though I can provide more info if necessary. It's really not human friendly, but here's a gist with chalk's debug log I analyzed if anyone's interested. |
Is there a version of rust analyzer where this works? |
I would like to bump this, as having to estimate types in Diesel is rather frustrating. |
@weiznich I see that you say this current bug is rust-analyzer's issue here: If you are confident this is the case, can we link to that issue/missing feature here? |
The remaining resolution errors here are not due to the 2015 name resolution being missing in r-a as diesel no longer uses that. There are some other type inference problems in r-a here that cause the remaining ones. |
Welp, I don't think I'm doing this wrong, but there are times when I'm getting absolutely no help. @Veykril do we have an idea what's wrong? Can I help? |
lowr pointed some of the issues out #14607 (comment) |
The |
For some reason my rust analyzer works fine with diesel on my MacBook but I run into issues when I try to use it on pop os. |
This comment was marked as off-topic.
This comment was marked as off-topic.
@weiznich any updates on this? Anywhere I can help? |
This is blocked on the new trait solver integration, there isn't anything we can do right now |
From diesel's point of view there are two At least for the Instead of this: let result = users::table.filter(users::id.eq(42)).load::<User>(conn)?; write this: let mut user_query = users::table.into_boxed();
user_query = user_query.filter(users::id.eq(42));
let result = user_query.load::<User>(conn)?; The important parts here are:
That workarounds the above issue as rust-analyzer is able to infer the type of the boxed query at the first assign. Afterwards it can assume that the type stays the same even if it cannot infer the correct type of the I'm not aware of any workaround for the I would assume that if someone wants to help resolving both cases for real the best way forward is to build a minimal example that triggers the same behavior. That would mean you would start with the latest diesel version and strip out as much stuff as possible so that the issue still reproduces. See the following blog post for general strategies how to do that. |
rust-analyzer version: rust-analyzer 0.3.1481-standalone (I've downloaded this release)
rustc version: rustc 1.68.0 (2c8cc3432 2023-03-06)
relevant settings: None non-standard settings
Rust analyzer fails to infer some diesel trait bounds even after applying a workaround for the previous name resolution bug. It seems to correctly pick up some of the diesel provided traits, but fails on others. It's unclear why some work, while others remain broken even if they use similar implementation patterns.
For example this impl in diesel works, while this won't work. I'm happy to provide more information here if someone points out what might be helpful.
This results in no type hints being shown and no completions being suggested after one of the failing trait methods is used.
Code to reproduce the issue:
Inferred Types:
The text was updated successfully, but these errors were encountered: