Rust-analyzer doesn't analyse modules guarded by #[cfg(target_arch = ...)]

Note: already checked the user manual.

I have a project where some of the modules are only enabled on a certain arch, using #[cfg(target_arch = "...")] mod ... syntax. Currently rust-analyzer doesn't analyze those modules, so none of the function (hover, go to definition etc.) work. Is there a way to enable analyzing those modules? It's fine if I need to restrict analysis to only that arch as the code generated for this arch subsumes code for other archs.

I think config option is what you are looking for:

1 Like


Actually I was wrong, that didn't fix the issue. I still get no error checking & reporting for the modules behind the #[cfg(target_arch = "...")].

I was confused before because I saw some error checking, but it turns out I only get syntax errors. I don't get any type errors even when there are dozens of errors in a module.

Indeed, we didn't propagate target to checkOnSave, we only used it for our own analysis. Fixed in

1 Like

Perfect, that fixed it!

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.