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

losing type information when adding WHERE (filter) clause to query #3900

Closed
3 tasks done
is-it-ayush opened this issue Jan 11, 2024 · 3 comments
Closed
3 tasks done
Labels

Comments

@is-it-ayush
Copy link

is-it-ayush commented Jan 11, 2024

Setup

Versions

  • Rust: 1.72.1
  • Diesel: 2.1.0
  • Database: 16.1
  • Operating System Linux 6.1.0-16-amd64

Feature Flags

  • diesel: postgres

Problem Description

Anytime I use a .filter(some_field.<operator>(some_value)) (ex. .filter(username.eq("ayush"))). I loose type information on the returning result. The program still compiles unaffected but the types vanish. Here is an example,

  • with .filter
    image
  • without .filter
    image

You'll notice that without filter it's being parsed as Vec<User> while with filter it's being parsed as ! (diverging). I was following the "getting started" guide so I'm not sure what causes this.

What are you trying to accomplish?

The type information to be parsed correctly.

What is the expected output?

The correct type for results i.e. Vec<User>.

What is the actual output?

It's !. For some reason, rust thinks it's diverging.

Are you seeing any additional errors?

Nope! The program compiles perfectly fine.

Steps to reproduce

Unfortunately I don't yet know why this occurs but here is the link to the above code.

Checklist

  • This issue can be reproduced on Rust's stable channel. (Your issue will be
    closed if this is not the case)
  • This issue can be reproduced without requiring a third party crate
@weiznich
Copy link
Member

Duplicate of #3876 and rust-lang/rust-analyzer#14607

The code itself is fine as it is accepted by rustc. It's just an IDE issue. There is nothing we can do in diesel to fix this issue. It needs to be fixed in rust-analyzer.

@weiznich weiznich closed this as not planned Won't fix, can't repro, duplicate, stale Jan 11, 2024
@barokurniawan
Copy link

I am glad I am not alone, this drives me crazy.

@opsnull
Copy link

opsnull commented Aug 2, 2024

same problem here

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

No branches or pull requests

4 participants