Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/render/union_literal.rs')
-rw-r--r--crates/ide-completion/src/render/union_literal.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/crates/ide-completion/src/render/union_literal.rs b/crates/ide-completion/src/render/union_literal.rs
index 6e0c53ec94..93e943dbed 100644
--- a/crates/ide-completion/src/render/union_literal.rs
+++ b/crates/ide-completion/src/render/union_literal.rs
@@ -21,8 +21,10 @@ pub(crate) fn render_union_literal(
let name = local_name.unwrap_or_else(|| un.name(ctx.db()));
let (qualified_name, escaped_qualified_name) = match path {
- Some(p) => (p.unescaped().to_string(), p.to_string()),
- None => (name.unescaped().to_string(), name.to_string()),
+ Some(p) => (p.unescaped().display(ctx.db()).to_string(), p.display(ctx.db()).to_string()),
+ None => {
+ (name.unescaped().display(ctx.db()).to_string(), name.display(ctx.db()).to_string())
+ }
};
let label = format_literal_label(&name.to_smol_str(), StructKind::Record, ctx.snippet_cap());
let lookup = format_literal_lookup(&name.to_smol_str(), StructKind::Record);
@@ -51,9 +53,9 @@ pub(crate) fn render_union_literal(
format!(
"{} {{ {} }}",
escaped_qualified_name,
- fields
- .iter()
- .format_with(", ", |field, f| { f(&format_args!("{}: ()", field.name(ctx.db()))) })
+ fields.iter().format_with(", ", |field, f| {
+ f(&format_args!("{}: ()", field.name(ctx.db()).display(ctx.db())))
+ })
)
};
@@ -61,7 +63,11 @@ pub(crate) fn render_union_literal(
"{} {{ {}{} }}",
qualified_name,
fields.iter().format_with(", ", |field, f| {
- f(&format_args!("{}: {}", field.name(ctx.db()), field.ty(ctx.db()).display(ctx.db())))
+ f(&format_args!(
+ "{}: {}",
+ field.name(ctx.db()).display(ctx.db()),
+ field.ty(ctx.db()).display(ctx.db())
+ ))
}),
if fields_omitted { ", .." } else { "" }
);
@@ -76,5 +82,5 @@ pub(crate) fn render_union_literal(
None => item.insert_text(literal),
};
- Some(item.build())
+ Some(item.build(ctx.db()))
}