-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Autocomplete fails on Vec after custom allocators support was added #6668
Comments
If you write |
It shows |
Actually no, autocomplete fails to give any result on But other types, like |
The symptoms are familiar to #6672
so maybe nightly after all. |
For me the latest working version is Oh! I see. 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
}
} |
fn f() {
let mut v = Vec::new();
v.<|>
}
Looks like we aren't accounting for default type parameters somewhere. |
Self-contained repro (minus use core::ops;
pub struct Vec<T, A = ()> {
}
impl<T> Vec<T> {
pub const fn new() -> Self {
}
}
impl<T, A> ops::Deref for Vec<T, A> {
type Target = [T];
fn deref(&self) -> &[T] {
}
} and then again fn f() {
let mut v = Vec::new();
v.<|>
} |
Hmm. I fear that might be our slightly hacky Deref handling... (I'd recommend turning the self-contained repro into a test in hir-ty by adding |
@jonas-schievink I can't reproduce the problem with your repro, with current RA and rustc 1.48 🤔 E.g. |
You need nightly Rust, custom allocator support for |
But why would your self-contained repro depend on custom allocator support in |
You're right though, it reproduces with nightly 🤔 Edit: It's not related to Edit 2: I suspect const generics. |
Oh, right, huh. |
The problem seems to be with |
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 |
Without arbitrary self types, the self type could never refer to the method type parameters, so this wasn't a problem; but with arbitrary self types, it can. This fixes the crash from rust-lang#6668; but it doesn't make method resolution work for these methods.
Without arbitrary self types, the self type could never refer to the method type parameters, so this wasn't a problem; but with arbitrary self types, it can. This fixes the crash from rust-lang#6668; but it doesn't make method resolution work for these methods.
6723: Use correct, full substs for self type in impl r=flodiebold a=flodiebold Without arbitrary self types, the self type could never refer to the method type parameters, so this wasn't a problem; but with arbitrary self types, it can. This fixes the crash from #6668; but it doesn't make method resolution work for these methods. Co-authored-by: Florian Diebold <[email protected]>
Should be fixed on master now. |
Without arbitrary self types, the self type could never refer to the method type parameters, so this wasn't a problem; but with arbitrary self types, it can. This fixes the crash from rust-lang#6668; but it doesn't make method resolution work for these methods.
Description
Autocomplete fails to show any result under specific circumstances:
This problem only seems to happen on rust nightly. It consistently disappears after
rustup default stable
and restarting the RA server. Thebytes
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
2020-11-23
(cadf0e9)1.51.1
1.50.0-nightly (1c389ffef 2020-11-24)
Minimal reproducible example
nightly
toolchainbytes = "0.6"
to dependenciesuse bytes::{BytesMut, buf::Buf};
let buf = BytesMut::new();
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 #6668 (comment)
The text was updated successfully, but these errors were encountered: