rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.32k stars 1.61k forks source link

Auto Import not working with `derive_more` proc macros #17370

Open homchom opened 5 months ago

homchom commented 5 months ago

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:

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);
  3. Add #[derive(Display)] on the line above. While typing, observe that Auto Import correctly suggests parse_display::Display. Remove the derive attribute.
  4. Add #[derive(From)] on the line above the struct definition. While typing, observe that Auto Import does not suggest derive_more::From.
  5. To fix the error, replace From with derive_more::From. Observe that the macro resolves and the code compiles.
Veykril commented 5 months ago

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

mathew-horner commented 5 months ago

@rustbot claim

mathew-horner commented 4 days ago

@rustbot release-assignment