Skip to content

Auto Import not working with derive_more proc macros #17370

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

Open
homchom opened this issue Jun 8, 2024 · 3 comments
Open

Auto Import not working with derive_more proc macros #17370

homchom opened this issue Jun 8, 2024 · 3 comments
Labels
A-assists C-bug Category: bug

Comments

@homchom
Copy link

homchom commented Jun 8, 2024

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 (7852a4c 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 homchom added the C-bug Category: bug label Jun 8, 2024
@Veykril
Copy link
Member

Veykril commented Jun 9, 2024

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
Copy link
Contributor

@rustbot claim

@mathew-horner
Copy link
Contributor

mathew-horner commented Nov 19, 2024

@rustbot release-assignment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-assists C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants