From af4ae86e2700209283333490da377767e00f5ed2 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 6 Oct 2020 14:21:22 +0300 Subject: Do not leave braces for colons in dbg! --- crates/assists/src/handlers/remove_dbg.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'crates') diff --git a/crates/assists/src/handlers/remove_dbg.rs b/crates/assists/src/handlers/remove_dbg.rs index a8ab2aecc..e10616779 100644 --- a/crates/assists/src/handlers/remove_dbg.rs +++ b/crates/assists/src/handlers/remove_dbg.rs @@ -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) - } 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] -- cgit v1.2.3