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

rust-analyzer fails to resolve invocations of xflags::xflags! #14

Closed
thomcc opened this issue Jun 5, 2021 · 4 comments · Fixed by #17
Closed

rust-analyzer fails to resolve invocations of xflags::xflags! #14

thomcc opened this issue Jun 5, 2021 · 4 comments · Fixed by #17

Comments

@thomcc
Copy link
Contributor

thomcc commented Jun 5, 2021

xflags is for the most part great (easy arg parsing without the compile time hit <3), but there are a few annoyances with using it. One of them is that rust-analyzer seems to be upset by it, producing errors like

unresolved macro `xflags::xflags!` rust-analyzer(unresolved-macro-call)

when the file containing the invocation happens to be open.

This, for the most part, isn't that big of a deal (just close the file, r-a shuts up, and everything works fine), but is an annoyance, and I've had to explain that this is what you should do to others on projects using xflags a couple times, so I figured I'd file a bug about it.

I assume the real solution is for rust-analyzer to get smarter, but... perhaps there's some workaround that xflags could to at least make this less annoying?

@lnicola
Copy link
Collaborator

lnicola commented Jul 22, 2021

This seems to happen because there's a #[cfg(not(test))], see e.g. rust-lang/rust-analyzer#9203.

@thomcc
Copy link
Contributor Author

thomcc commented Jan 8, 2022

Adding "rust-analyzer.cargo.unsetTest": ["core", "xflags-macros"] the whatever.code-workspace or .vscode/settings.json seems to work around it.

This also, of course, works if you set it in your global settings. It might be nice to document, if there's no workaround that can be done inside this library.

@lnicola
Copy link
Collaborator

lnicola commented Jan 9, 2022

I tried to remove the

#[cfg(not(test))]
line and nothing broke, maybe we can do that?

@thomcc
Copy link
Contributor Author

thomcc commented Jan 10, 2022

Submit a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants