rust-analyzer: Autocomplete fails on Vec after custom allocators support was added

Description

Autocomplete fails to show any result under specific circumstances:

demo

This problem only seems to happen on rust nightly. It consistently disappears after rustup default stable and restarting the RA server. The bytes crate doesn’t seems to have anything cfg’ed on nightly. Functions in other traits (e.g. std::io::Read) seems to work fine.

Environment

  • RA: 2020-11-23 (cadf0e9)
  • VSCode: 1.51.1
  • Rust: 1.50.0-nightly (1c389ffef 2020-11-24)

Minimal reproducible example

  1. Switch to nightly toolchain
  2. Add bytes = "0.6" to dependencies
  3. Add use bytes::{BytesMut, buf::Buf};
  4. Write let buf = BytesMut::new();
  5. Try to complete on buf.<|>

(Verified to be reproducible in Windows Sandbox using a fresh install of Rust, VSCode, and RA without changing any settings)

This is maybe related to #6612, but I’m not sure because a) it doesn’t complete no matter what I do or how long I wait; and b) it somehow only appears in Rust nightly.

Edit: see https://github.com/rust-analyzer/rust-analyzer/issues/6668#issuecomment-735501557

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (16 by maintainers)

Commits related to this issue

Most upvoted comments


struct Slice<T> {}
struct Box<T, A> {}
struct Vec<T, A> {}

impl<T> Slice<T> {
    pub fn into_vec<A>(self: Box<Self, A>) -> Vec<T, A> { }
}

fn main() {
    let foo: Slice<u32>;
    foo.
}

reproduces the problem on stable. I’m pretty sure the problem is the second type parameter on the Box.

For me the latest working version is da3846948 2020-11-21 and it fails on a0d664bae 2020-11-22, so it shouldn’t be the same issue? The only major difference between them appears to be rust-lang/rust#78461.

Oh! I see. BytesMut derefs to Vec<u8>, so that’s why most of the other types don’t have the same issue.

use std::ops::Deref;

fn main() {
    let test = Test { vec: vec![] };
    test.<|>        // Fails to complete
}

struct Test {
    vec: Vec<u8>
}

impl Deref for Test {
    type Target = Vec<u8>;

    fn deref(&self) -> &Self::Target {
        &self.vec
    }
}