Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-db/src/syntax_helpers/format_string.rs')
-rw-r--r--crates/ide-db/src/syntax_helpers/format_string.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/crates/ide-db/src/syntax_helpers/format_string.rs b/crates/ide-db/src/syntax_helpers/format_string.rs
index f48a570086..894a4b0fbb 100644
--- a/crates/ide-db/src/syntax_helpers/format_string.rs
+++ b/crates/ide-db/src/syntax_helpers/format_string.rs
@@ -1,9 +1,10 @@
//! Tools to work with format string literals for the `format_args!` family of macros.
use syntax::{
- ast::{self, IsString},
- AstNode, AstToken, TextRange, TextSize,
+ ast::{self, IsString}, TextRange, TextSize,
};
+use super::node_ext::get_outer_macro_name;
+
pub fn is_format_string(string: &ast::String) -> bool {
// Check if `string` is a format string argument of a macro invocation.
// `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 {
// This setup lets us correctly highlight the components of `concat!("{}", "bla")` format
// strings. It still fails for `concat!("{", "}")`, but that is rare.
(|| {
- let macro_call = string.syntax().parent_ancestors().find_map(ast::MacroCall::cast)?;
- let name = macro_call.path()?.segment()?.name_ref()?;
+ let name = get_outer_macro_name(string)?;
if !matches!(
name.text().as_str(),