-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
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:
[dependencies]
# this version already contains the workaround for the rust-analyzer name resolution "bug"
diesel = { version = "=2.0.4", features = ["sqlite"], default-features = false }
use diesel::prelude::*;
table! {
users {
id -> Integer,
name -> Text,
}
}
table! {
posts {
id -> Integer,
user_id -> Integer,
}
}
allow_tables_to_appear_in_same_query!(users, posts);
joinable!(posts -> users (user_id));
#[derive(Selectable, Queryable)]
struct User {
id: i32,
}
fn main() {
let conn = &mut SqliteConnection::establish("_").unwrap();
// these QueryDsl methods work
let u = users::table
.limit(10)
.offset(15)
.distinct()
.order_by(users::id)
.group_by(users::id)
.then_order_by(users::name)
.having(users::id.eq(42))
.select(users::id)
.load::<i32>(conn);
// these queries don't work
let u = users::table
.inner_join(posts::table)
.load::<((i32, String), (i32, i32))>(conn);
let u = users::table
.left_join(posts::table)
.load::<((i32, String), Option<(i32, i32)>)>(conn);
let u = users::table
.filter(users::id.eq(42))
.load::<(i32, String)>(conn);
let u = users::table
.find(42)
.load::<(i32, String)>(conn);
let u = users::table.select(User::as_select()).load(conn);
}