]> git.lizzy.rs Git - rust.git/commitdiff
Do not leave braces for colons in dbg!
authorKirill Bulatov <mail4score@gmail.com>
Tue, 6 Oct 2020 11:21:22 +0000 (14:21 +0300)
committerKirill Bulatov <mail4score@gmail.com>
Tue, 6 Oct 2020 11:21:22 +0000 (14:21 +0300)
crates/assists/src/handlers/remove_dbg.rs

index a8ab2aecc405b95f016c0687c0dbfa97d98b9b60..e1061677901ce0f890c353dadde9fad02767c687 100644 (file)
@@ -1,6 +1,6 @@
 use syntax::{
     ast::{self, AstNode},
-    SyntaxElement, TextRange, TextSize, T,
+    SyntaxElement, SyntaxKind, TextRange, TextSize, T,
 };
 
 use crate::{AssistContext, AssistId, AssistKind, Assists};
@@ -117,7 +117,10 @@ fn needs_parentheses_around_macro_contents(macro_contents: Vec<SyntaxElement>) -
             }
             symbol_kind => {
                 let symbol_not_in_bracket = unpaired_brackets_in_contents.is_empty();
-                if symbol_not_in_bracket && symbol_kind.is_punct() {
+                if symbol_not_in_bracket
+                    && symbol_kind != SyntaxKind::COLON
+                    && symbol_kind.is_punct()
+                {
                     return true;
                 }
             }
@@ -159,6 +162,8 @@ fn foo(n: usize) {
 }
 ",
         );
+
+        check_assist(remove_dbg, "<|>dbg!(Foo::foo_test()).bar()", "Foo::foo_test().bar()");
     }
 
     #[test]