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

Should prefer associated items over a possible import with the same name #18554

Open
kpreid opened this issue Nov 25, 2024 · 0 comments
Open
Labels
A-completion autocompletion C-enhancement Category: enhancement

Comments

@kpreid
Copy link
Contributor

kpreid commented Nov 25, 2024

rust-analyzer version: 0.3.2188-standalone (ba56d9b 2024-11-17)
rustc version: rustc 1.82.0 (f6e511eec 2024-10-15)
editor or extension: VSCode; version of the RA extension is v0.3.2188

(I also tested with nightly / pre-release versions; the behavior was the same.)

code snippet to reproduce:

fn main() {
    let x = f32::INF
}

Put the cursor at the end of the line and press ^Space for completions. The first two suggestions will both complete to f32::INFINITY, but the first one on the list is one which will insert use core::f32; too.

Image

Since those constants are sort-of-deprecated, I don’t think RA should be preferring them, and in the general case, I would think that given any two identical local paths, it makes sense to rank completing the associated item over importing something new.

@kpreid kpreid added the C-bug Category: bug label Nov 25, 2024
@ChayimFriedman2 ChayimFriedman2 added the A-completion autocompletion label Nov 25, 2024
@flodiebold flodiebold added C-enhancement Category: enhancement and removed C-bug Category: bug labels Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-completion autocompletion C-enhancement Category: enhancement
Projects
None yet
Development

No branches or pull requests

3 participants