Skip to content

proc-macro panics in rust-analyzer but not cargo #20196

@blorbb

Description

@blorbb

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.

Image

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.

Image

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:

Sorry for not being able to get a smaller reproduction! Let me know if there's anything else you think I should try out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions