rust-lang / rust-lang/rust-analyzer

Auto Import not working with `derive_more` proc macros

Open
#17,370 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

This is not a duplicate of #6183 because

  1. the import resolves.
  2. procMacro.enable is set to true.

rust-analyzer version: 0.3.1983-standalone (7852a4c77 2024-06-02)

rustc version: 1.78.0 (9b00956e5 2024-04-29)

editor or extension: VSCode

relevant settings:

  • "rust-analyzer.completion.autoimport": true
  • "rust-analyzer.procMacro.enable": true

to reproduce:

  1. Create a new library crate project with dependencies derive_more and parse-display.
  2. In lib.rs, define the following struct:
struct Example(i32);
  1. Add #[derive(Display)] on the line above. While typing, observe that Auto Import correctly suggests parse_display::Display. Remove the derive attribute.
  2. Add #[derive(From)] on the line above the struct definition. While typing, observe that Auto Import does not suggest derive_more::From.
  3. To fix the error, replace From with derive_more::From. Observe that the macro resolves and the code compiles.

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

Start by reproducing the behavior in a new library crate using lib.rs, the derive_more and parse-display dependencies, and the listed rust-analyzer settings. Compare completion for parse_display::Display with derive_more::From, then trace the auto-import handling for proc-macro derives; done means derive_more::From is suggested while proc macros are enabled and the existing reproduction still compiles.

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.