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

Incorrect E0308: expected &(dyn ToSql + Sync), found &i32 #16336

Open
erikschul opened this issue Jan 10, 2024 · 3 comments
Open

Incorrect E0308: expected &(dyn ToSql + Sync), found &i32 #16336

erikschul opened this issue Jan 10, 2024 · 3 comments
Labels
C-bug Category: bug

Comments

@erikschul
Copy link

When using deadpool_postgres, I encountered incorrect diagnostic for E0308.
The code compiles correctly, but rust-analyzer shows an error.

See details: bikeshedder/deadpool#296 (comment)

rust-analyzer version: 0.3.1799-standalone (af40101 2024-01-07)

rustc version: rustc 1.75.0 (82e1608df 2023-12-21)

Possibly related:

@erikschul erikschul added the C-bug Category: bug label Jan 10, 2024
@erikschul
Copy link
Author

One temporary solution is to disable the diagnostic: "rust-analyzer.diagnostics.disabled": ["E0308"]

@simon-connektica

This comment was marked as off-topic.

@lynxlevin
Copy link

I am seeing another similar case when using deadpool-redis.
The code below gives expected Option<String>, found String E0308 error, though cargo check does not give any error.

rust-analyzer version: 0.3.2045
rustc version: 1.79.0 (129f3b996 2024-06-10)
editor or extension: VSCode
code snippet to reproduce:

async fn get_from_redis(
    redis_connection: &mut deadpool_redis::Connection,
    key: String,
) -> Option<String> {
    redis_connection
        .get::<String, Option<String>>(key)
        .await
        .unwrap()
}
// deadpool-redis version is "0.15.1"

The signature for the get method is as below, it looks like analyzer is applying the annotation for RV to both K and RV.

pub fn get<'a, K, RV>(&'a mut self, key: K) -> crate::types::RedisFuture<'a, RV>

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

No branches or pull requests

3 participants