-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[Feature] Semantic highlighting for asm!
and global_asm!
strings?
#6031
Comments
I can't give mentoring instructions, but it would probably be possible to implement this (and also awesome!). We have a couple of sub-languages supported: Rust code in docstrings and test fixtures and highlighting for |
Well, you just did :-) |
It would be nice if it also supported comments, labels and assembly directives highlighting. Those are almost the same across architectures with the exception of all comments other than |
Hm, the syntax of asm is some specific llvm-assmebly syntax? I wonder if this yak shave should start with building and |
I think |
The actual asm in an |
I think the new syntax is closer to Intel? Talking about https://blog.rust-lang.org/inside-rust/2020/06/08/new-inline-asm.html and https://github.com/Amanieu/rfcs/blob/inline-asm/text/0000-inline-asm.md. Reusing |
The new syntax is equivalent to wrapping the asm in |
I thought about this a few times since I've made the issue but always got stuck on how to detect which flavor of assembly is being used inside of the macro, because the project I'm currently using |
It's still an unresolved question whether the If it is, then detecting the correct flavor should be fairly straightforward. If not, then |
Oh, I wasn't aware that was even being considered! I'll have to keep a closer eye on the tracking issue :) but that does sound pretty reasonable to discern if that does end up being the case 👍 |
I began writing a really rough version of this today as a proof-of-concept to see how hard it'd be, and was pleasantly surprised that it didn't take more than about 2 hours to get something working fairly well :) I'll probably put up a WIP PR sometime soon-ish for better discussion on the actual implementation. question though, is there currently any way to query the target/architecture that the crate is being built for? my attempt right now is very general and doesn't assume a particular arch, but for more accurate highlighting that would be ideal. (assuming the |
Even a namespaced macro wouldn't guarantee that tools could determine from the source code which platforms a given asm invocation is intended for. You would still be capable of writing cross-platform #[cfg(target_arch="foo")]
use std::arch::foo::asm as foobar_asm;
#[cfg(target_arch="bar")]
use std::arch::bar::asm as foobar_asm;
foobar_asm!(...) |
@bstrie rust-analyzer does precise analysis, so it has to analyze the code relative to a specific set of cfgs, and it knows what specific macro the call resolves to. At some point, we might implement the logic to union results of several active cfg sets (so we highlight the call twice and somehow merge the results), but we’ll never be able to be cfg agnostic. |
Good to hear, although that still sounds like it's unaffected by whether or not the |
feat: IDE support for `asm!` expressions Fixes rust-lang/rust-analyzer#10461, Fixes rust-lang/rust-analyzer#6031 Progresses rust-lang/rust-analyzer#11621 Notably this only works for asm expressions not items yet. Most IDE features work, mainly completions need extra logic still.
Hi, I was wondering if it would be possible to have inline syntax highlighting for raw literals that are used with the
asm!
andglobal_asm!
macros via semantic highlighting, kind of like what happens with format string literals. Certainly wouldn't mind giving it a go myself if this is desired/possible :)Thanks!
The text was updated successfully, but these errors were encountered: