rust-lang / rust-lang/rust-analyzer

Custom type alias completion priority

Open
#20,550 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-feature
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

How to customize the completion priority of type-alias?

I don't want it to always be located after the struct when completing

fn main() {
    //type Array = [u8; 256];
    struct Array;
    let _: Arr$0;
}

Output completion:

Array Array
ArrayChunks<…>~(use std::iter::ArrayChunks) ArrayChunks<{unknown}, _>
ArrayWindows<…>~(use std::slice::ArrayWindows) ArrayWindows<'_, {unknown}, _>
CharArraySearcher<…>~(use std::str::pattern::CharArraySearcher) CharArraySearcher<'_, _>
CharArrayRefSearcher<…>~(use std::str::pattern::CharArrayRefSearcher) CharArrayRefSearcher<'_, '_, _>
AllocError(use std::alloc::AllocError) AllocError
AccessError(use std::thread::AccessError) AccessError
alloc_error_handler
AddrParseError(use std::net::AddrParseError) AddrParseError
AncillaryError(use std::os::unix::net::AncillaryError) AncillaryError
AtomicOrdering(use std::intrinsics::AtomicOrdering) AtomicOrdering
AsyncIterator(alias Stream) (use std::async_iter::AsyncIterator)
IntoAsyncIterator(use std::async_iter::IntoAsyncIterator)
fn main() {
    type Array = [u8; 256];
    //struct Array;
    let _: Arr$0;
}

Output completion:

ArrayChunks<…>~(use std::iter::ArrayChunks) ArrayChunks<{unknown}, _>
ArrayWindows<…>~(use std::slice::ArrayWindows) ArrayWindows<'_, {unknown}, _>
Array
CharArraySearcher<…>~(use std::str::pattern::CharArraySearcher) CharArraySearcher<'_, _>
CharArrayRefSearcher<…>~(use std::str::pattern::CharArrayRefSearcher) CharArrayRefSearcher<'_, '_, _>
AllocError(use std::alloc::AllocError) AllocError
AccessError(use std::thread::AccessError) AccessError
alloc_error_handler
AddrParseError(use std::net::AddrParseError) AddrParseError
AncillaryError(use std::os::unix::net::AncillaryError) AncillaryError
AtomicOrdering(use std::intrinsics::AtomicOrdering) AtomicOrdering
AsyncIterator(alias Stream) (use std::async_iter::AsyncIterator)
IntoAsyncIterator(use std::async_iter::IntoAsyncIterator)

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 two Rust completion examples from the issue and compare the ordering of the struct Array and type Array results. Trace the completion-ranking entry point responsible for type aliases, then define how customization should affect the result and verify that the alias can rank ahead of the struct without disrupting other suggestions.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
developer-experience
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.