Skip to content
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

Getting proc macro not expanded: No proc-macros present for crate rust-analyzer (unresolved-proc-macro) on macos #16331

Closed
kt390256 opened this issue Jan 10, 2024 · 14 comments · Fixed by #16462
Labels
A-proc-macro proc macro C-support Category: support questions

Comments

@kt390256
Copy link

kt390256 commented Jan 10, 2024

rust-analyzer version: rust-analyzer version: v0.3.1799 (https://github.com/rust-lang/rust-analyzer/commit/9db515503f11bda7812cdfb9c2839f70f4cb1fdd 2024-01-01)

OS: MacOS 14.2.1 (23C71)

rustc version: rustc 1.75.0 (82e1608df 2023-12-21)

relevant settings: none
Screenshot 2024-01-09 at 5 43 16 PM
Screenshot 2024-01-09 at 5 46 32 PM

Any effort will be appreciated!

@kt390256 kt390256 added the C-bug Category: bug label Jan 10, 2024
@Veykril
Copy link
Member

Veykril commented Jan 10, 2024

Have you tried clearing your target dir? I've seen this error happen when upgrading my toolchain from time to time (not quite sure why that error specifically happens then).

Also check the logs maybe some error is in there.

@Veykril Veykril added C-support Category: support questions A-proc-macro proc macro and removed C-bug Category: bug labels Jan 10, 2024
@Systemcluster
Copy link

Systemcluster commented Jan 18, 2024

I'm seeing the same error since ~2 weeks ago with Rust nightly (currently rustc 1.77.0-nightly (6ae4cfbbb 2024-01-17)). Deleting the target directory doesn't help. It occurs on two different systems (Windows and macOS).

In my case it errors on a #[cfg_attr(feature = "std", derive(thiserror::Error))] with proc macro 'feature' not expanded: No proc-macros present for crate at feature = "std", in this codebase.

There's no output in the "Rust Analyzer Language Server" logs.

@stjepangolemac
Copy link

Also happening to me when deriving clap::Parser in the Helix editor. There's nothing interesting in the logs.

@Veykril
Copy link
Member

Veykril commented Jan 18, 2024

There has been a breaking change in cargo afaik that breaks package ids which cargo metadata does not handle correctly. This should be fixed by the next rustc nightly. see rust-lang/cargo#13311

@martinlindhe
Copy link

Thanks, @Veykril. I had this too for a little while, and updating nightly to rustc 1.77.0-nightly (88189a71e 2024-01-19) fixes it for me.

bors added a commit that referenced this issue Jan 31, 2024
Better error message for when proc-macros have not yet been built

Closes #16331
@bors bors closed this as completed in ddf2611 Feb 8, 2024
@installgentoo
Copy link

This now happens in 1.78

@shitcodebykaushik
Copy link

It happing now tooo. And i am getting lost in searching the the solution.

@Veykril
Copy link
Member

Veykril commented May 13, 2024

Please open a new issue and fill out the template, including what operating system you are on and what error(s) you are getting

@mthmcalixto
Copy link

try

settings.json:

{
    "rust-analyzer.procMacro.enable": true
}

@modecode22
Copy link

try

settings.json:

{
    "rust-analyzer.procMacro.enable": true
}

Thanks

@flodiebold
Copy link
Member

try

settings.json:

{
    "rust-analyzer.procMacro.enable": true
}

That won't fix it. This setting is true by default, and it being disabled wouldn't lead to the original error.

@bionicles
Copy link

bionicles commented Aug 1, 2024

same / similar issue
image

@Anatoly03
Copy link

Anatoly03 commented Sep 28, 2024

Image

Related? (Code compiles, macro returns token stream from input as in the rust book example)

@ChayimFriedman2
Copy link
Contributor

ChayimFriedman2 commented Sep 29, 2024

@Anatoly03 This is a different problem. Please open a new issue, and include a minimal reproducible example (if you can) and rust-analyzer's logs (available on VSCode under Output->Rust Analyzer Language Server).

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

Successfully merging a pull request may close this issue.