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

Analyzer indicates wrong return type for function #17212

Open
manuelVo opened this issue May 10, 2024 · 1 comment
Open

Analyzer indicates wrong return type for function #17212

manuelVo opened this issue May 10, 2024 · 1 comment
Labels
A-nameres name, path and module resolution C-bug Category: bug

Comments

@manuelVo
Copy link

The matrix-sdk and it's subcrates contain several structs with the name SyncResponse. When calling client.sync_once as seen below, the function returns matrix_sdk::sync::SyncResponse. However, rust-analyzer determines the type to be from the matrix_sdk_base it indicates matrix_sdk_base::sync::SyncResponse. This can be seen by doing either of those:

  1. Ctrl+Click on the Type jumps in to the source code of matrix_sdk_base
  2. Trying to extract SyncResponse::next_batch as seen in the code below. This field does exist in matrix_sdk::sync::SyncResponse but not in matrix_sdk_base::sync::SyncResponse. Since rust-analyzer resolves to matrix_sdk_base::sync::SyncResponse, the type of token cannot be resolved.

rust-analyzer version: 0.4.1954-standalone

rustc version: rustc 1.78.0 (9b00956e5 2024-04-29)

editor or extension: VSCode extension v0.3.1950

relevant settings: Unchanged default settings

code snippet to reproduce:

use matrix_sdk::{config::SyncSettings, ruma::user_id, Client};

#[tokio::main(flavor = "current_thread")]
async fn main() {
    let user = user_id!("@user:example.org");

    let client = Client::builder()
        .server_name(user.server_name())
        .build()
        .await
        .unwrap();

    let sync_response = client.sync_once(SyncSettings::new()).await.unwrap();
    let token = sync_response.next_batch;

    println!("{:?}", token);
}
[package]
name = "analyzer-bug"
version = "0.1.0"
edition = "2021"

[dependencies]
matrix-sdk = "0.7.1"
tokio = { version = "1.37.0", features = ["macros", "rt"] }
@manuelVo manuelVo added the C-bug Category: bug label May 10, 2024
@Veykril Veykril added the A-nameres name, path and module resolution label May 10, 2024
@Veykril
Copy link
Member

Veykril commented May 10, 2024

We get confused by a glob import in matrix_sdk::sync (pub use matrix_sdk_base::sync::*;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-nameres name, path and module resolution C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants