]> git.lizzy.rs Git - rust.git/commitdiff
internal: dont descend into comments
authorJake Heinz <jh@discordapp.com>
Mon, 3 Jan 2022 01:50:49 +0000 (01:50 +0000)
committerJake Heinz <jh@discordapp.com>
Mon, 3 Jan 2022 01:53:58 +0000 (01:53 +0000)
crates/ide/src/syntax_highlighting.rs

index 28c7c546fff7399a686cb7e27a669cc3296e6af5..f20d629fbf1d069867ead0036be92c953bb3fd26 100644 (file)
@@ -282,7 +282,10 @@ fn traverse(
 
         // only attempt to descend if we are inside a macro call or attribute
         // as calling `descend_into_macros_single` gets rather expensive if done for every single token
-        let descend_token = current_macro_call.is_some() || current_attr_call.is_some();
+        // additionally, do not descend into comments, descending maps down to doc attributes which get
+        // tagged as string literals.
+        let descend_token = (current_macro_call.is_some() || current_attr_call.is_some())
+            && element.kind() != COMMENT;
         let element_to_highlight = if descend_token {
             let token = match &element {
                 NodeOrToken::Node(_) => continue,