diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs index 1b2fc9c635..59d1696618 100644 --- a/crates/ide/src/syntax_highlighting.rs +++ b/crates/ide/src/syntax_highlighting.rs @@ -323,6 +323,7 @@ fn traverse( (T![ident], NAME | NAME_REF) => parent.into(), (T![self] | T![super] | T![crate], NAME_REF) => parent.into(), (INT_NUMBER, NAME_REF) => parent.into(), + (LIFETIME_IDENT, LIFETIME) => parent.into(), _ => token.into(), } } diff --git a/crates/ide/src/syntax_highlighting/test_data/highlight_lifetimes.html b/crates/ide/src/syntax_highlighting/test_data/highlight_lifetimes.html new file mode 100644 index 0000000000..a9fcf8d2b1 --- /dev/null +++ b/crates/ide/src/syntax_highlighting/test_data/highlight_lifetimes.html @@ -0,0 +1,57 @@ + + +
+#[derive()]
+struct Foo<'a, 'b, 'c> where 'a: 'a, 'static: 'static {
+ field: &'a (),
+ field2: &'static (),
+}
+impl<'a> Foo<'_, 'a, 'static>
+where
+ 'a: 'a,
+ 'static: 'static
+{
+
+}
+
\ No newline at end of file
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs
index ec50fde356..874eaf8cf7 100644
--- a/crates/ide/src/syntax_highlighting/tests.rs
+++ b/crates/ide/src/syntax_highlighting/tests.rs
@@ -312,6 +312,30 @@ macro_rules! die {
);
}
+#[test]
+fn test_lifetime_highlighting() {
+ check_highlighting(
+ r#"
+//- minicore: derive
+
+#[derive()]
+struct Foo<'a, 'b, 'c> where 'a: 'a, 'static: 'static {
+ field: &'a (),
+ field2: &'static (),
+}
+impl<'a> Foo<'_, 'a, 'static>
+where
+ 'a: 'a,
+ 'static: 'static
+{
+
+}
+"#,
+ expect_file!["./test_data/highlight_lifetimes.html"],
+ false,
+ );
+}
+
#[test]
fn test_string_highlighting() {
// The format string detection is based on macro-expansion,