intellij-rust / intellij-rust

Rust plugin for the IntelliJ Platform
https://intellij-rust.github.io
MIT License
4.53k stars 380 forks source link

Backslash at the end of triple comment line in macro breaks it #9906

Open Mersid opened 1 year ago

Mersid commented 1 year ago

Macros that take structs don't show up properly if documentation in it ends with a backslash. For example, observe these two instances. They work fine normally image But when adding backslashes to the comment (and it only works with triple slash comments that end with a backslash), image The coloring gets stripped out, showing that the IDE is no longer able to properly recognize the code. I am not quite sure why this is happening, but it does mean that these types do not show up in code completion. An example is from the wgpu crate: the functions in wgpu::Features::* do not work because two of the bit flags end with a backslash in its comment.

Originally posted by @Mersid in https://github.com/intellij-rust/intellij-rust/issues/6908#issuecomment-1357044518

neonaot commented 1 year ago

Thanks for the report! One more simple example:

macro_rules! as_is {
    ($($t:tt)*) => { $($t)* };
}

fn main() {
    as_is! {
        // a \
        struct Sssss;
        /// hello \
        struct Hello;
    }

    let v = Hello{}; // <- Hello is unresolved
    let g = Sssss{}; // <- ok
}