rust-lang / rust-lang/rust-analyzer

No autocompletion for `inherent_associated_types` nightly feature

Open
#16,240 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-ty B-unstable C-feature S-actionable
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

As stated above: my LSP doens't give auto completion for a constant that's typed by the inherent_associated_types feature.
Rustc does compile the program when using the feature.

UPDATE: After some testing I found that this only happens for const values and not variables defined with let (regardless of scope).

Code example

My repo is public so if my code examples aren't clear enough you can always take a look:
Current commit when writing this issue. (Bumping the nightly version from 2023-11-19 to 2023-12-29 has nothing to do with this issue).

// /core/src/hardware/bus.rs
use std::ops;

pub struct MemoryBus(/* ... */);
impl MemoryBus {
    pub type Addr = u16;
    // Also tried replacing MemoryBus::Addr with just plain u16 but didn't work
    // Moving it outside impl and just doing a plain old type does work
    pub type Region = ops::RangeInclusive<MemoryBus::Addr>; 
}

pub mod regions {
    pub const OAM: MemoryBus::Region = 0xFE00..=0xFE9F
}
// /core/src/io/graphics/objects.rs
use crate::hardware::bus;

mod oam {
    struct ObjectAttributes<'a>(bytes: &'a [u8; 4]);

    impl<'a> ObjectAttributes<'a> {
        pub fn from_bus(&memory_bus:  &bus::MemoryBus) -> [ObjectAttributes; 40] {
             // Function I was working on while encountering this issue.
             bus::regions::OAM./* I'd want my LSP to provide me with auto completion here */
        }
    }
}

Toolchain versions

rust-analyzer

$ rust-analyzer --version --verbose
rust-analyzer 1.77.0-nightly (fb5ed72 2023-12-28)

rustc

$ rustc --version --verbose
rustc 1.77.0-nightly (fb5ed726f 2023-12-28)
binary: rustc
commit-hash: fb5ed726f72c6d16c788517c60ec00d4564b9348
commit-date: 2023-12-28
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Rust feature tracking issue

https://github.com/rust-lang/rust/issues/8995

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue from the Rust code examples in /core/src/hardware/bus.rs and /core/src/io/graphics/objects.rs using the reported rust-analyzer and rustc nightly versions. Compare completion for the const OAM value with let variables and ordinary types; done means completion is provided for the inherent-associated-type const.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.