Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-assists/src/handlers/generate_constant.rs')
-rw-r--r--crates/ide-assists/src/handlers/generate_constant.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/crates/ide-assists/src/handlers/generate_constant.rs b/crates/ide-assists/src/handlers/generate_constant.rs
index ccdfcb0d9e..eccd7675fb 100644
--- a/crates/ide-assists/src/handlers/generate_constant.rs
+++ b/crates/ide-assists/src/handlers/generate_constant.rs
@@ -46,7 +46,8 @@ pub(crate) fn generate_constant(acc: &mut Assists, ctx: &AssistContext<'_>) -> O
let ty = ctx.sema.type_of_expr(&expr)?;
let scope = ctx.sema.scope(statement.syntax())?;
let constant_module = scope.module();
- let type_name = ty.original().display_source_code(ctx.db(), constant_module.into()).ok()?;
+ let type_name =
+ ty.original().display_source_code(ctx.db(), constant_module.into(), false).ok()?;
let target = statement.syntax().parent()?.text_range();
let path = constant_token.syntax().ancestors().find_map(ast::Path::cast)?;
@@ -106,10 +107,10 @@ fn get_text_for_generate_constant(
let mut text = format!("{vis}const {constant_token}: {type_name} = $0;");
while let Some(name_ref) = not_exist_name_ref.pop() {
let vis = if not_exist_name_ref.len() == 0 && !outer_exists { "" } else { "\npub " };
- text = text.replace("\n", "\n ");
+ text = text.replace('\n', "\n ");
text = format!("{vis}mod {name_ref} {{{text}\n}}");
}
- Some(text.replace("\n", &format!("\n{indent}")))
+ Some(text.replace('\n', &format!("\n{indent}")))
}
fn target_data_for_generate_constant(
@@ -131,7 +132,7 @@ fn target_data_for_generate_constant(
let siblings_has_newline = l_curly_token
.siblings_with_tokens(Direction::Next)
- .find(|it| it.kind() == SyntaxKind::WHITESPACE && it.to_string().contains("\n"))
+ .find(|it| it.kind() == SyntaxKind::WHITESPACE && it.to_string().contains('\n'))
.is_some();
let post_string =
if siblings_has_newline { format!("{indent}") } else { format!("\n{indent}") };