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

Diesel traits / methods are not resolved properly. #12589

Closed
oslac opened this issue Jun 20, 2022 · 11 comments
Closed

Diesel traits / methods are not resolved properly. #12589

oslac opened this issue Jun 20, 2022 · 11 comments
Labels
A-ty type system / type inference / traits / method resolution Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug

Comments

@oslac
Copy link

oslac commented Jun 20, 2022

  • rust-analyzer version: rust-analyzer version: 0.0.0 (427061da1 2022-06-19)
  • rustc version: rustc 1.63.0-nightly (bb8c2f411 2022-06-19)
  • relevant settings: None.

Issue: Rust-Analyzer fails to resolve some methods when using the Diesel ORM library. These would be the eq in diesel::ExpressionMethods and execute in diesel::RunQueryDsl as far as I can tell.

Example is available here: https://github.com/oslac/ra-diesel-traits

Screenshot from 2022-06-20 16-07-43

Screenshot from 2022-06-20 16-07-26

Expected: that RA properly resolves the traits / methods.

@bjorn3
Copy link
Member

bjorn3 commented Jun 20, 2022

Does https://github.com/oslac/ra-diesel-traits/blob/fa1b4e62ba5abf4df7847f2fe8c1cf545e9faea8/src/schema.rs#L1 get expanded or does rust-analyzer show an error for it?

@oslac
Copy link
Author

oslac commented Jun 20, 2022

Does https://github.com/oslac/ra-diesel-traits/blob/fa1b4e62ba5abf4df7847f2fe8c1cf545e9faea8/src/schema.rs#L1 get expanded or does rust-analyzer show an error for it?

No errors from the schema.rs on my end. I can see the documentation pop up when I hover over the table! etc.

@lnicola lnicola added A-ty type system / type inference / traits / method resolution Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug labels Jun 20, 2022
@bmisiak
Copy link

bmisiak commented Jun 21, 2022

Database connectors are tricky for rust-analyzer. #6833 (comment)

@QuadraticKid
Copy link

QuadraticKid commented Sep 23, 2022

Issue is still present on 2022-09-19 and nightly.
This issue was previously referenced, and is now merged; however it appears to have not been the solution.

Potentially related error log

@longsleep
Copy link

This problem seems to happen pretty much for every Diesel dsl lines.

        let mut result = users::table
            .select(User::as_select())
            .filter(users::username.eq(username))
            .load::<User>(&mut db)?;

The result variable type is {unknown}.

gnome-shell-screenshot-a0fom0

@Veykril
Copy link
Member

Veykril commented Mar 28, 2023

This works with the latest master branch of diesel, cause was their proc-macros using 2015 name resolution which r-a does not support currently

@Veykril Veykril closed this as completed Mar 28, 2023
@weiznich
Copy link
Contributor

@Veykril It's fine to close these issues, but you probably want to link them to an root issue for 2015 style name resolution, because that's an actual bug/missing feature in rust-analyzer.

@QuadraticKid
Copy link

Issue still present on nightly, even building off of diesel's master branch. (Tests per diesel-rs/diesel 4b2ebca)

Tested with diesel's examples on schema dsl operations- the first operation resolves successfully (filter), however everything after that fails.

@weiznich
Copy link
Contributor

@QuadraticKid The specific instances that are reported in this issue are resolved. What you likely see is another bug that surfaced after working around the first one. The type inference breakes as soon as a .filter()/.inner_join()/.left_join() appears in your query.

@Veykril Should I fill new issues for the broken case or do you want to reopen the existing ones?

@Veykril
Copy link
Member

Veykril commented Apr 18, 2023

New one sounds better (with crosslinking for context maybe)

@weiznich
Copy link
Contributor

I submitted #14607

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty type system / type inference / traits / method resolution Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

8 participants