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] Syntax highlighting breaks in macros #3991

Open
deathaxe opened this issue Jun 16, 2024 · 1 comment
Open

[Rust] Syntax highlighting breaks in macros #3991

deathaxe opened this issue Jun 16, 2024 · 1 comment
Labels
C: Syntax T: bug A bug in an existing language feature

Comments

@deathaxe
Copy link
Collaborator

What happened?

Source

https://github.com/WebAssembly/WASI/blob/01bb90d8b66cbc1d50349aaaab9ac5b143c9c98c/legacy/tools/witx/src/abi.rs#L64-L120

Screenshot

grafik

Code Snippet

// Helper macro for defining instructions without having to have tons of
// exhaustive `match` statements to update
macro_rules! def_instruction {
    (
        $( #[$enum_attr:meta] )*
        pub enum Instruction<'a> {
            $(
                $( #[$attr:meta] )*
                $variant:ident $( {
                    $($field:ident : $field_ty:ty $(,)* )*
                } )?
                    :
                [$num_popped:expr] => [$num_pushed:expr],
            )*
        }
    ) => {
        $( #[$enum_attr] )*
        pub enum Instruction<'a> {
            $(
                $( #[$attr] )*
                $variant $( {
                    $(
                        $field : $field_ty,
                    )*
                } )? ,
            )*
        }

        impl Instruction<'_> {
            /// How many operands does this instruction pop from the stack?
            #[allow(unused_variables)]
            pub fn operands_len(&self) -> usize {
                match self {
                    $(
                        Self::$variant $( {
                            $(
                                $field,
                            )*
                        } )? => $num_popped,
                    )*
                }
            }

            /// How many results does this instruction push onto the stack?
            #[allow(unused_variables)]
            pub fn results_len(&self) -> usize {
                match self {
                    $(
                        Self::$variant $( {
                            $(
                                $field,
                            )*
                        } )? => $num_pushed,
                    )*
                }
            }
        }
    };
}
@deathaxe deathaxe added T: bug A bug in an existing language feature C: Syntax labels Jun 16, 2024
@FichteFoll
Copy link
Collaborator

Probably the same issue as #3904 but with a different construct. #3912 might be able to help (haven't checked) but introduces a different issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Syntax T: bug A bug in an existing language feature
Projects
None yet
Development

No branches or pull requests

2 participants