Skip to content

Inlay hints and symbol renaming not working when using no_main custom entry point (embedded) #10753

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
eflukx opened this issue Nov 12, 2021 · 8 comments
Labels
A-macro macro expansion C-bug Category: bug

Comments

@eflukx
Copy link

eflukx commented Nov 12, 2021

I have (perceived) strange behavior when using rust analyzer in vscode on an embedded project. In this example a trivial example project based on the nRF52840 devkit.

The (inline) type hints are missing when variable are declared mut (at let mut _key = [0u8; 128];),
furthermore symbol renaming does not work (see renamed vs. peripherals)

image

When commenting out the #[entry] line (obviously the code breaks, but) inline hints and symbol renaming work as expected...

image

Have been fiddling with some rust analyzer settings, ran rustup update, tried rust_analyzer nightly, tried older versions, all to no avail.. Am I missing something, or did we encounter a bug?

@Veykril
Copy link
Member

Veykril commented Nov 12, 2021

I don't have knowledge about embedded libraries, from what crate is the entry attribute?

@eflukx
Copy link
Author

eflukx commented Nov 12, 2021

As I'm using a cortex-m architecture, in my case it's from the cortex_m_rt create (use cortex_m_rt::entry;).

The #[entry] attribute declares function the be the entry point of the program and is used in all 'no_main' (e.g. embedded) projects.

@Veykril Veykril added A-macro macro expansion C-bug Category: bug labels Nov 12, 2021
@eflukx
Copy link
Author

eflukx commented Nov 13, 2021

Another symptom is the 'run/debug' buttons do not show up as supposed and autocompletion seems to not be fully working (as if RA is not fully aware of its context).

Tried with another embedded architecture (AVR template project): same issue. Tested on another (Windows) PC: same issue. Both in native Windows as from WSL2 the issue is the same.

@Veykril
Copy link
Member

Veykril commented Nov 13, 2021

The autocomplete issue is known and needs a fix in the attribute proc-macro itself, see #10520

@eflukx
Copy link
Author

eflukx commented Nov 14, 2021

Ran into another issue with embedded target, that could be (or seems) related.
I bisected that problem down to a specific rust-analyzer VSCode plugin version. The version that solves that problem, also seems to fix this issue(!):

v0.2.760 is the last version that seem to work correctly, from v0.2.768 onwards, the problem arises.

see: Rahix/avr-hal-template#3 (comment)

@Veykril
Copy link
Member

Veykril commented Nov 14, 2021

Ye thats the version of when we enabled attribute macros by default, prior to that the attribute didn't do anything. Note if this is a bigger problem for you currently you can get the old behavior back by disabling the rust-analyzer.experimental.procAttrMacros setting.

@flodiebold
Copy link
Member

@eflukx Are you still having problems with this with current RA versions?

@eflukx
Copy link
Author

eflukx commented Apr 4, 2022

@eflukx Are you still having problems with this with current RA versions?

Thanks for informing on this :) Up to now I've been working with the rust-analyzer.experimental.procAttrMacros: false setting. Just commented it out (so i expect it to be at its default true) and 'stuff' did not seem to break. ie. inlay types are displayed and everything else seemed normal/as expected. So looks good.

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

No branches or pull requests

3 participants