Stream: t-compiler/rust-analyzer

Topic: No code-completion when using the ash crate


Clemens Wasser (Jan 04 2020 at 21:59, on Zulip):

Here is the Problem:

use ash::version::*;
use ash::*;

fn main() {
  let entry = Entry::new().unwrap(); // rust analyzer deduces the type correctly: ash::EntryCustom<Arc<DynamicLibrary>>
  let instance = entry.create_instance(&vk::InstanceCreateInfo::builder(), None).unwrap(); // rust analyzer does not deduce any type: {unknown}
  // should be: ash::Instance
  // When I remove the ".unwrap()" He deduces it as: Result<{unknown}, InstanceError>
}

Here is the corresponding source in the ash crate:

pub trait EntryV1_0 {
    type Instance; // Here is Self::Instance, but rust-analyzer fails to identify it as this (I think, ... no idea -> what do you think?)

//...

    unsafe fn create_instance(
        &self,
        create_info: &vk::InstanceCreateInfo,
        allocation_callbacks: Option<&vk::AllocationCallbacks>,
    ) -> Result<Self::Instance, InstanceError>; // rust-analyzer cannot deduce the Type: Self::Instance, which is up there ^^

//...

}
Jeremy Kolb (Jan 04 2020 at 22:54, on Zulip):

Might be https://github.com/rust-analyzer/rust-analyzer/issues/2603

Florian Diebold (Jan 04 2020 at 23:31, on Zulip):

Yes, probably that (or rather, another instance of rust-lang/chalk#234)

Clemens Wasser (Jan 06 2020 at 16:14, on Zulip):

Thanks for pointing that out.

Clemens Wasser (Jan 06 2020 at 16:35, on Zulip):

It turns out, that rust-analyzer knows the "create_instance" function and "go-to-function" and "show-function-signature" / "parameters" (shift+ctrl+space) do work... ?

matklad (Jan 06 2020 at 16:37, on Zulip):

When we fail at using types to solve goto definition, we use a heuristics which basically looks for a function with appropriate name

Clemens Wasser (Jan 06 2020 at 17:57, on Zulip):

When we fail at using types to solve goto definition, we use a heuristics which basically looks for a function with appropriate name

Thanks

Clemens Wasser (Jan 23 2020 at 19:37, on Zulip):

Somehow it now works... Thanks! :D

Last update: Jul 26 2021 at 13:45UTC