Skip to content
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

No autocompletion for inherent_associated_types nightly feature #16240

Open
Ziothh opened this issue Jan 3, 2024 · 5 comments
Open

No autocompletion for inherent_associated_types nightly feature #16240

Ziothh opened this issue Jan 3, 2024 · 5 comments
Labels
A-ty type system / type inference / traits / method resolution C-feature Category: feature request S-actionable Someone could pick this issue up and work on it right now

Comments

@Ziothh
Copy link

Ziothh commented Jan 3, 2024

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

rust-lang/rust#8995

@Ziothh Ziothh added the C-bug Category: bug label Jan 3, 2024
@Veykril
Copy link
Member

Veykril commented Jan 3, 2024

The feature is not supported at all in rust-analyzer right now~~, and iirc to implement it we need the new trait solver (or chalk support for it)~~ actually that was assoc type default, unsure about this feature

@Veykril Veykril added A-ty type system / type inference / traits / method resolution S-unactionable Issue requires feedback, design decisions or is blocked on other work C-feature Category: feature request A-chalk chalk related issue and removed C-bug Category: bug labels Jan 3, 2024
@Ziothh
Copy link
Author

Ziothh commented Jan 3, 2024

Hey @Veykril, thanks for the quick response.

Are there any relevant issues you could forward me to so I can keep up to date with progress being made on that trait solver you mentioned and/or chalk?

Should I go ahead and close this issue or do you want to keep it open until the feature is supported?

@Veykril
Copy link
Member

Veykril commented Jan 3, 2024

We can keep this open I don't think we have an issue tracking this feature here yet.

@Ziothh Ziothh changed the title No autocompletion for **inherent_associated_types** nightly feature No autocompletion for inherent_associated_types nightly feature Jan 3, 2024
@flodiebold
Copy link
Member

actually that was assoc type default, unsure about this feature

Yeah, I feel like this shouldn't be particularly hard to support -- there's really not much difference between

impl Foo {
    type Bar = u32;
}

and

type FooBar = u32;

, is there?

@flodiebold flodiebold added S-actionable Someone could pick this issue up and work on it right now and removed S-unactionable Issue requires feedback, design decisions or is blocked on other work A-chalk chalk related issue labels Jan 3, 2024
@Ziothh
Copy link
Author

Ziothh commented Jan 4, 2024

Just to be clear: Foo::Bar seems to be supported by rust-analyzer.

It just doesn't resolve (for auto completion & type inference) when a const BAR: Foo::Bar is used somewhere.
It does complain if I assign the wrong value to BAR when it's declared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty type system / type inference / traits / method resolution C-feature Category: feature request S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

3 participants