Skip to content

Commit 386f46a

Browse files
committed
Use helper method in is_format_string
1 parent 55c5014 commit 386f46a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

crates/ide-db/src/syntax_helpers/format_string.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
//! Tools to work with format string literals for the `format_args!` family of macros.
22
use syntax::{
3-
ast::{self, IsString},
4-
AstNode, AstToken, TextRange, TextSize,
3+
ast::{self, IsString}, TextRange, TextSize,
54
};
65

6+
use super::node_ext::get_outer_macro_name;
7+
78
pub fn is_format_string(string: &ast::String) -> bool {
89
// Check if `string` is a format string argument of a macro invocation.
910
// `string` is a string literal, mapped down into the innermost macro expansion.
@@ -14,8 +15,7 @@ pub fn is_format_string(string: &ast::String) -> bool {
1415
// This setup lets us correctly highlight the components of `concat!("{}", "bla")` format
1516
// strings. It still fails for `concat!("{", "}")`, but that is rare.
1617
(|| {
17-
let macro_call = string.syntax().parent_ancestors().find_map(ast::MacroCall::cast)?;
18-
let name = macro_call.path()?.segment()?.name_ref()?;
18+
let name = get_outer_macro_name(string)?;
1919

2020
if !matches!(
2121
name.text().as_str(),

0 commit comments

Comments
 (0)