Skip to content

Error on proc macro #6696

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

Closed
aurexav opened this issue Dec 2, 2020 · 8 comments · Fixed by #6820
Closed

Error on proc macro #6696

aurexav opened this issue Dec 2, 2020 · 8 comments · Fixed by #6820
Assignees
Labels
A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now

Comments

@aurexav
Copy link

aurexav commented Dec 2, 2020

It can work 2 days ago.

But today I update it on vscode.

And the proc macro report error. Looks so noisy.

2020-12-02_13-52

@aurexav
Copy link
Author

aurexav commented Dec 2, 2020

This macro is from crate frame-support.

frame-support = { version = "2.0.0" }

use frame_support::decl_storage;

@bjorn3
Copy link
Member

bjorn3 commented Dec 2, 2020

It expects CARGO_PKG_NAME to be set: https://github.com/paritytech/substrate/blob/918313f9bea2766bddcef8ea5b5a454486f3acfe/frame/support/procedural/tools/src/lib.rs#L41

@aurexav
Copy link
Author

aurexav commented Dec 2, 2020

It expects CARGO_PKG_NAME to be set: https://github.com/paritytech/substrate/blob/918313f9bea2766bddcef8ea5b5a454486f3acfe/frame/support/procedural/tools/src/lib.rs#L41

Any quick fix that I can do?

Seems there's a env setting in rust-analyzer.

@flodiebold
Copy link
Member

The macro-error diagnostic is new; this was probably already not working before you updated, you just didn't see the error. You can disable the macro-error diagnostic using the rust-analyzer.diagnostics.disable setting to go back to not seeing it ;)

Setting CARGO_PKG_NAME would probably have to be done programmatically by RA, since it depends on the crate we're "compiling", I guess? I wonder if that's intended/supported usage though...

@jonas-schievink jonas-schievink added the A-macro macro expansion label Dec 3, 2020
@aurexav
Copy link
Author

aurexav commented Dec 3, 2020

The macro-error diagnostic is new; this was probably already not working before you updated, you just didn't see the error. You can disable the macro-error diagnostic using the rust-analyzer.diagnostics.disable setting to go back to not seeing it ;)

Setting CARGO_PKG_NAME would probably have to be done programmatically by RA, since it depends on the crate we're "compiling", I guess? I wonder if that's intended/supported usage though...

Seems this setting not exist.

Oh, I found it.

"rust-analyzer.diagnostics.enable": false,

@tomjakubowski
Copy link

@AurevoirXavier I used this:

"rust-analyzer.diagnostics.disabled": [
  "macro-error"
]

Setting what you did disables all of rust-analyzer's diagnostics, probably not what we want.

@aurexav
Copy link
Author

aurexav commented Dec 3, 2020

@AurevoirXavier I used this:

"rust-analyzer.diagnostics.disabled": [
  "macro-error"
]

Setting what you did disables all of rust-analyzer's diagnostics, probably not what we want.

Thanks.

bors bot added a commit that referenced this issue Dec 10, 2020
6807: Replicate Cargo environment variables r=jonas-schievink a=jonas-schievink

These might be relied on by procedural macros, and can also be accessed via `env!`.

Required for fixing #6696. We do not yet propagate these to any proc macros though.

Co-authored-by: Jonas Schievink <[email protected]>
@jonas-schievink jonas-schievink self-assigned this Dec 11, 2020
@lnicola lnicola added the S-actionable Someone could pick this issue up and work on it right now label Dec 20, 2020
@bors bors bot closed this as completed in 8f26221 Dec 27, 2020
@ntn-x2
Copy link

ntn-x2 commented Feb 2, 2022

The same is happening again, on Mac Silicon with Rust Analyzer version 0.2.853 and VSCode version Version: 1.63.2
Commit: 899d46d82c4c95423fb7e10e68eba52050e30ba3, for the frame macro frame_support::pallet. Anyone else with the same issue and, more importantly, anyone with a fix? 😂

Diagnostics for macro-error are already disabled, but when then exporting the module wrapped by the macro, it is an unresolved import error. Enabling the diagnostics results in the very same problem as discussed above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants