Rust-analyzer: Variable type not resolved even though function return type is known

Created on 21 Jan 2020  路  3Comments  路  Source: rust-analyzer/rust-analyzer

In the following code:

use smithay_client_toolkit::{default_environment, init_default_environment};

default_environment!(Environment, desktop);

fn main() {
    let (env, _, _) = init_default_environment!(Environment, desktop).unwrap();
    let surface = env.create_surface();
}

using https://github.com/Smithay/client-toolkit/commit/4a80863e6dce2749701299f2ebcb567cec34f370, rust-analyzer ad10d0c says the type of surface is {unknown}, even though it correctly determines the signature of create_surface(), which doesn't have any generics or anything funny and which does include a return type.

Most helpful comment

I took a look; the problem is that the return type of that function is defined in code generated by a build script, so this depends on #1964.

All 3 comments

Does it know the type of env? The signature might be misleading because it might be based on an index lookup (I'm not sure whether we still do that for signature help).

Yes, it does know the type of env. Also I meant that the type of the function was known to hover; I don't use signature help (don't have it set up).

I took a look; the problem is that the return type of that function is defined in code generated by a build script, so this depends on #1964.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jhpratt picture jhpratt  路  3Comments

mehmooda picture mehmooda  路  3Comments

matklad picture matklad  路  4Comments

matklad picture matklad  路  4Comments

csmoe picture csmoe  路  4Comments