Skip to content

Rust: incorrect highlights of pub macro and /// (doc-comment) #13732

Open
@Rudxain

Description

@Rudxain

Summary

I've done a git bisect and both bugs exist long before the Tree-House migration, so I suspect the problem lies in TS-Rs grammar

Reproduction Steps

I tried this:

  1. hx tmp.rs
  2. Paste this into the buffer:
// this is needed for repro
fn f(){}

// prepending `pub` fixes the HL of the next `pub`
macro _const_assert {
    ($condition: expr, $const_msg:literal, $runtime_msg:literal, $($arg:tt)*) => {{
        if !$crate::intrinsics::likely($condition) {
            $crate::panic::const_panic!($const_msg, $runtime_msg, $($arg)*)
        }
    }}
} //`;` // fixes the HL of the lone `///`
// only if the previous `macro` has `pub` as well

/// A version of `assert` that prints a non-formatting message in const contexts.
///
/// See [`const_panic!`].
#[doc(hidden)] // attributes are needed to repro `pub` bug
pub macro const_assert {
    ($condition: expr, $const_msg:literal, $runtime_msg:literal, $($arg:tt)*) => {{
        if !$crate::intrinsics::likely($condition) {
            $crate::panic::const_panic!($const_msg, $runtime_msg, $($arg)*)
        }
    }}
}

I expected this to happen: pub is keyword; /// is comment.

Instead, this happened: pub is variable; /// is operator.

Helix log

~/.cache/helix/helix.log

Platform

Linux

Terminal Emulator

irrelevant

Installation Method

source

Helix Version

unknown

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-language-supportArea: Support for programming/text languagesC-bugCategory: This is a bugupstream

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions