Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/syntax_highlighting/tests.rs')
-rw-r--r--crates/ide/src/syntax_highlighting/tests.rs76
1 files changed, 72 insertions, 4 deletions
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs
index 6fed7d783e..c2990fd76e 100644
--- a/crates/ide/src/syntax_highlighting/tests.rs
+++ b/crates/ide/src/syntax_highlighting/tests.rs
@@ -22,11 +22,11 @@ fn attributes() {
check_highlighting(
r#"
//- proc_macros: identity
-//- minicore: derive, copy
+//- minicore: derive, copy, default
#[allow(dead_code)]
#[rustfmt::skip]
#[proc_macros::identity]
-#[derive(Copy)]
+#[derive(Default)]
/// This is a doc comment
// This is a normal comment
/// This is a doc comment
@@ -36,7 +36,10 @@ fn attributes() {
// This is another normal comment
#[derive(Copy, Unresolved)]
// The reason for these being here is to test AttrIds
-struct Foo;
+enum Foo {
+ #[default]
+ Bar
+}
"#,
expect_file!["./test_data/highlight_attributes.html"],
false,
@@ -630,6 +633,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(
r#"
@@ -1173,8 +1222,27 @@ fn benchmark_syntax_highlighting_parser() {
.highlight(HL_CONFIG, file_id)
.unwrap()
.iter()
- .filter(|it| it.highlight.tag == HlTag::Symbol(SymbolKind::Function))
+ .filter(|it| {
+ matches!(it.highlight.tag, HlTag::Symbol(SymbolKind::Function | SymbolKind::Method))
+ })
.count()
};
assert_eq!(hash, 1169);
}
+
+#[test]
+fn highlight_trait_with_lifetimes_regression_16958() {
+ let (analysis, file_id) = fixture::file(
+ r#"
+pub trait Deserialize<'de> {
+ fn deserialize();
+}
+
+fn f<'de, T: Deserialize<'de>>() {
+ T::deserialize();
+}
+"#
+ .trim(),
+ );
+ let _ = analysis.highlight(HL_CONFIG, file_id).unwrap();
+}