rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

Auto Import not working with `derive_more` proc macros

Open homchom opened this issue 1 year ago • 2 comments

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.

homchom avatar Jun 08 '24 19:06 homchom

LIkely due to the collision of the From trait in the prelude, r-a doesn't handle those well for auto imports yet iirc

Veykril avatar Jun 09 '24 04:06 Veykril

@rustbot claim

mathew-horner avatar Jun 09 '24 06:06 mathew-horner

@rustbot release-assignment

mathew-horner avatar Nov 19 '24 15:11 mathew-horner