-
Notifications
You must be signed in to change notification settings - Fork 590
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] Macro improperly marked as invalid #3904
Comments
The issue was a bit more involved than you initially suspected because the problem was that macro repetitions inside transcribers where basically unsupported. The linked PR #3912 fixes this particular issue for structs, but due to a lack of real world examples for other block statements I didn't check if they exhibit the same or similar issues. If you have some more complex examples for macros, that would be much appreciated. Edit: Well, didn't take long for me to find a problem with that implementation. No promises when I'll find time to work on this again, considering that I also don't have an idea how to resolve it currently |
At first glance, I couldn't find any other macros that error out (that use repetitions) outside of this (partially censored) one: #[macro_export]
macro_rules! metadata {
(
namespace $ns:literal;
$(
$name:ident: $ity:ty
),+$(,)?
) => {
#[derive(Debug, Clone, Default, Eq, PartialEq)]
pub struct Metadata {
$(
$name: Option<$ity>
),+
}
impl $crate::database::Metadata for Metadata {
const NAMESPACE: &'static str = $ns;
}
}
} The others that I use that have repetitions currently do not error, e.g. #[macro_export]
macro_rules! header_map {
($($name:literal => $value:expr),* $(,)*) => {{
let mut headers = reqwest::header::HeaderMap::with_capacity($crate::__count!($($name)*));
$(
headers.insert(
reqwest::header::HeaderName::from_static($name),
reqwest::header::HeaderValue::from_static($value),
);
)*
headers
}};
} |
Yeah, it's (multiple) macro transcribers inside other blocks such as a |
What happened?
The following macro gives an erroneous
source.rust meta.macro.rust invalid.illegal.rust
scope:From a cursory view in the repository and from testing it seems this is applied because of this rule
Packages/Rust/Rust.sublime-syntax
Lines 1071 to 1080 in 9ba6b93
Adding the
;
after thestruct
definition does make the scope go away but ironically it leads to invalid code since you can't have;
after a struct definition:The text was updated successfully, but these errors were encountered: