rust-lang / rust-lang/rust-analyzer

Unable to quick fix import when function name conflicts with builtin type

Open
#15,296 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

rust-analyzer version: 0.3.1583-standalone (ff1563483 2023-07-09)

rustc version:rustc 1.73.0-nightly (ad963232d 2023-07-14)

The nom parsing library contains various functions that have the same name as rust's builtin types, for example:

  • nom::character::complete::char
  • nom::character::complete::u8
  • nom::character::complete::u32

It seems rust-analyzer is unable to suggest a quick fix action to import these functions.
image

While it may be questionable to import a function with the same name as a type, I feel there should be some kind of quick-fix option here.

cargo clippy correctly suggests a fix:
image

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 missing quick fix with the nom functions char, u8, or u32, using the versions and example described in the issue. Compare the behavior with cargo clippy's suggested fix; done means rust-analyzer offers a working import quick fix for functions whose names conflict with builtin types.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.