-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
rust-analyzer version: 0.4.2528-standalone
rustc version: rustc 1.89.0-nightly (99e7c15e8 2025-06-01)
editor or extension: VSCode, v0.4.2528 (pre-release). Latest stable has the same issue.
relevant settings: don't think any of my settings are relevant
repository link (if public, optional): https://github.com/blorbb/leptos-mview/tree/ra-debug there's some nightly and custom cfg features, but these are disabled in this repro.
code snippet to reproduce:
See repo link above. The test that is failing is at the end of src/lib.rs, or the below:
#[cfg(test)]
mod tests {
use leptos::prelude::*;
use super::mview;
#[component]
fn Component() -> impl IntoView {}
#[test]
fn ids() {
_ = mview! {
Component #thing-a;
};
}
}
rust-analyzer is panicking on the above test, with the message "expected literal", but running cargo test -p leptos-mview --lib
compiles fine.

I've been trying to debug this for a while but could not figure out where the error comes from.
If I go to leptos-mview-macro/src/lib.rs and change the implementation to:
#[proc_macro_error]
#[proc_macro]
pub fn mview(input: TokenStream) -> TokenStream {
let result: TokenStream = leptos_mview_core::mview_impl(input.into()).into();
panic!("{result}");
}
That last panic runs and I get an output that looks like an expected output.

Further, all of these snippets below don't get any errors.
mview! {
Component #thing;
}
mview! {
Component .thing-a;
}
mview! {
div #thing-a;
}
Possibly relevant implementation details include:
- kebab-case identifier parsing for why it only panics with a kebab-case ident
- id/class parsing and id expansion for why it only panics with an id, but not a class.
- component expansion for why it doesn't panic on regular HTML elements. The expansion for HTML elements is just above this if you want to compare.
Sorry for not being able to get a smaller reproduction! Let me know if there's anything else you think I should try out.