rust-lang / rust-lang/rust-analyzer
autocomplete of const generic structures seems to be broken since 5/08/23 release
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
rustc version: rustc 1.72.0-nightly (1c53407e8 2023-05-28)
This seems to be broken since rust analyzer v0.3.1514 , may be related to #14727 but I'm not sure.
I tried to narrow down the issue with simple structures featuring const generics but can't seem to trigger the bug without using the actual crate I'm developing. The crate itself is simple, just a lot of const generics usage:
cargo add spsc-ringbuf-core
use spsc_ringbuf_core::shared_pool::*;
const POOL_DEPTH: usize = 16;
pub struct Item {
id: u32,
payload: PoolIndex<POOL_DEPTH>,
}
impl HasPoolIdx<POOL_DEPTH> for Item {
fn get_pool_idx(&self) -> PoolIndex<POOL_DEPTH> {
self.payload
}
fn set_pool_idx(&mut self, pindex: PoolIndex<POOL_DEPTH>) {
self.payload = pindex
}
}
static SHARED_POOL: SharedPool<Item, Item, 16, 32> = SharedPool::new();
fn main() {
SHARED_POOL.split(); // dot autocomplete cannot find `split` or any other methods
}
dot autocompletion is broken:
However if I replace all references of POOL_DEPTH in the snippet above with a literal, e.g. 16, autocomplete works. In the earlier version (0.3.1506-standalone) the issue is not observed.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the spsc-ringbuf-core example and compare dot completion when POOL_DEPTH is used with completion when literals are used. Check whether methods such as split are discovered for const-generic structures, and consider the issue resolved when the const-generic form provides the same autocomplete results as the literal form.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100