rust-lang / rls

Repository for the Rust Language Server (aka RLS)
Other
3.51k stars 257 forks source link

No autocompletion when aliasing types with cfg #1566

Open TheAifam5 opened 5 years ago

TheAifam5 commented 5 years ago

Hey!

I'm making multi-platform library for process manipulation. RLS shows the function definition when I hover over from_current or test, but RLS returns:

[Trace - 9:18:46 PM] Received response 'textDocument/codeAction - (716)' in 1ms.
Result: []

Code:

pub mod platform {
  pub trait ProcessTrait {
    fn from_current() -> Self;
    fn test(self);
  }

  #[cfg(target_os = "windows")]
  pub type Process = native::windows::Process;

  #[cfg(target_os = "macos")]
  pub type Process = native::macos::Process;

  #[cfg(target_os = "linux")]
  pub type Process = native::linux::Process;

  mod native {
    pub mod linux {
      use super::super::ProcessTrait;
      pub struct Process();

      impl ProcessTrait for Process {
        fn from_current() -> Process {
          Process {}
        }

        fn test(self) {}
      }
    }

    pub mod windows {}

    pub mod macos {}
  }
}

use platform::{Process, ProcessTrait};
fn test() {
  let p: Process = Process::from_current(); // no autocompletion after Process::
  p.test(); // no autocompletion after p.
}

Regards, TheAifam5

kevinbarabash commented 2 years ago

I'm seeing the same thing with aliased types from my library crate in the integration tests.