More precise highlighting rules for constant modifier

This commit is contained in:
Lukas Wirth 2024-03-17 11:26:05 +01:00
parent 640c8b722e
commit 77607ab99a
22 changed files with 87 additions and 6 deletions

View file

@ -629,6 +629,52 @@ fn main() {
);
}
#[test]
fn test_const_highlighting() {
check_highlighting(
r#"
macro_rules! id {
($($tt:tt)*) => {
$($tt)*
};
}
const CONST_ITEM: *const () = &raw const ();
const fn const_fn<const CONST_PARAM: ()>(const {}: const fn()) where (): const ConstTrait {
CONST_ITEM;
CONST_PARAM;
const {
const || {}
}
id!(
CONST_ITEM;
CONST_PARAM;
const {
const || {}
};
&raw const ();
const
);
}
trait ConstTrait {
const ASSOC_CONST: () = ();
const fn assoc_const_fn() {}
}
impl const ConstTrait for () {
const ASSOC_CONST: () = ();
const fn assoc_const_fn() {}
}
macro_rules! unsafe_deref {
() => {
*(&() as *const ())
};
}
"#,
expect_file!["./test_data/highlight_const.html"],
false,
);
}
#[test]
fn test_highlight_doc_comment() {
check_highlighting(