mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Properly account for editions in names
This PR touches a lot of parts. But the main changes are changing `hir_expand::Name` to be raw edition-dependently and only when necessary (unrelated to how the user originally wrote the identifier), and changing `is_keyword()` and `is_raw_identifier()` to be edition-aware (this was done in #17896, but the FIXMEs were fixed here). It is possible that I missed some cases, but most IDE parts should properly escape (or not escape) identifiers now. The rules of thumb are: - If we show the identifier to the user, its rawness should be determined by the edition of the edited crate. This is nice for IDE features, but really important for changes we insert to the source code. - For tests, I chose `Edition::CURRENT` (so we only have to (maybe) update tests when an edition becomes stable, to avoid churn). - For debugging tools (helper methods and logs), I used `Edition::LATEST`.
This commit is contained in:
parent
91aa3f46b3
commit
9d3368f2c2
179 changed files with 2485 additions and 1250 deletions
|
@ -14,11 +14,14 @@ pub(crate) fn render_const(ctx: RenderContext<'_>, const_: hir::Const) -> Option
|
|||
fn render(ctx: RenderContext<'_>, const_: hir::Const) -> Option<CompletionItem> {
|
||||
let db = ctx.db();
|
||||
let name = const_.name(db)?;
|
||||
let (name, escaped_name) =
|
||||
(name.unescaped().display(db).to_smolstr(), name.display(db).to_smolstr());
|
||||
let detail = const_.display(db).to_string();
|
||||
let (name, escaped_name) = (
|
||||
name.unescaped().display(db).to_smolstr(),
|
||||
name.display(db, ctx.completion.edition).to_smolstr(),
|
||||
);
|
||||
let detail = const_.display(db, ctx.completion.edition).to_string();
|
||||
|
||||
let mut item = CompletionItem::new(SymbolKind::Const, ctx.source_range(), name);
|
||||
let mut item =
|
||||
CompletionItem::new(SymbolKind::Const, ctx.source_range(), name, ctx.completion.edition);
|
||||
item.set_documentation(ctx.docs(const_))
|
||||
.set_deprecated(ctx.is_deprecated(const_) || ctx.is_deprecated_assoc_item(const_))
|
||||
.detail(detail)
|
||||
|
@ -26,7 +29,7 @@ fn render(ctx: RenderContext<'_>, const_: hir::Const) -> Option<CompletionItem>
|
|||
|
||||
if let Some(actm) = const_.as_assoc_item(db) {
|
||||
if let Some(trt) = actm.container_or_implemented_trait(db) {
|
||||
item.trait_name(trt.name(db).display_no_db().to_smolstr());
|
||||
item.trait_name(trt.name(db).display_no_db(ctx.completion.edition).to_smolstr());
|
||||
}
|
||||
}
|
||||
item.insert_text(escaped_name);
|
||||
|
|
|
@ -4,7 +4,7 @@ use hir::{db::HirDatabase, AsAssocItem, HirDisplay};
|
|||
use ide_db::{SnippetCap, SymbolKind};
|
||||
use itertools::Itertools;
|
||||
use stdx::{format_to, to_lower_snake_case};
|
||||
use syntax::{format_smolstr, AstNode, SmolStr, ToSmolStr};
|
||||
use syntax::{format_smolstr, AstNode, Edition, SmolStr, ToSmolStr};
|
||||
|
||||
use crate::{
|
||||
context::{CompletionContext, DotAccess, DotAccessKind, PathCompletionCtx, PathKind},
|
||||
|
@ -62,9 +62,16 @@ fn render(
|
|||
receiver.unescaped().display(ctx.db()),
|
||||
name.unescaped().display(ctx.db())
|
||||
),
|
||||
format_smolstr!("{}.{}", receiver.display(ctx.db()), name.display(ctx.db())),
|
||||
format_smolstr!(
|
||||
"{}.{}",
|
||||
receiver.display(ctx.db(), completion.edition),
|
||||
name.display(ctx.db(), completion.edition)
|
||||
),
|
||||
),
|
||||
_ => (
|
||||
name.unescaped().display(db).to_smolstr(),
|
||||
name.display(db, completion.edition).to_smolstr(),
|
||||
),
|
||||
_ => (name.unescaped().display(db).to_smolstr(), name.display(db).to_smolstr()),
|
||||
};
|
||||
let has_self_param = func.self_param(db).is_some();
|
||||
let mut item = CompletionItem::new(
|
||||
|
@ -75,6 +82,7 @@ fn render(
|
|||
}),
|
||||
ctx.source_range(),
|
||||
call.clone(),
|
||||
completion.edition,
|
||||
);
|
||||
|
||||
let ret_type = func.ret_type(db);
|
||||
|
@ -141,9 +149,9 @@ fn render(
|
|||
}
|
||||
|
||||
let detail = if ctx.completion.config.full_function_signatures {
|
||||
detail_full(db, func)
|
||||
detail_full(db, func, ctx.completion.edition)
|
||||
} else {
|
||||
detail(db, func)
|
||||
detail(db, func, ctx.completion.edition)
|
||||
};
|
||||
item.set_documentation(ctx.docs(func))
|
||||
.set_deprecated(ctx.is_deprecated(func) || ctx.is_deprecated_assoc_item(func))
|
||||
|
@ -161,7 +169,9 @@ fn render(
|
|||
None => {
|
||||
if let Some(actm) = assoc_item {
|
||||
if let Some(trt) = actm.container_or_implemented_trait(db) {
|
||||
item.trait_name(trt.name(db).display_no_db().to_smolstr());
|
||||
item.trait_name(
|
||||
trt.name(db).display_no_db(ctx.completion.edition).to_smolstr(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -219,7 +229,7 @@ pub(super) fn add_call_parens<'b>(
|
|||
params.iter().enumerate().format_with(", ", |(index, param), f| {
|
||||
match param.name(ctx.db) {
|
||||
Some(n) => {
|
||||
let smol_str = n.display_no_db().to_smolstr();
|
||||
let smol_str = n.display_no_db(ctx.edition).to_smolstr();
|
||||
let text = smol_str.as_str().trim_start_matches('_');
|
||||
let ref_ = ref_of_param(ctx, text, param.ty());
|
||||
f(&format_args!("${{{}:{ref_}{text}}}", index + offset))
|
||||
|
@ -238,7 +248,7 @@ pub(super) fn add_call_parens<'b>(
|
|||
format!(
|
||||
"{}(${{1:{}}}{}{})$0",
|
||||
escaped_name,
|
||||
self_param.display(ctx.db),
|
||||
self_param.display(ctx.db, ctx.edition),
|
||||
if params.is_empty() { "" } else { ", " },
|
||||
function_params_snippet
|
||||
)
|
||||
|
@ -276,7 +286,7 @@ fn ref_of_param(ctx: &CompletionContext<'_>, arg: &str, ty: &hir::Type) -> &'sta
|
|||
""
|
||||
}
|
||||
|
||||
fn detail(db: &dyn HirDatabase, func: hir::Function) -> String {
|
||||
fn detail(db: &dyn HirDatabase, func: hir::Function, edition: Edition) -> String {
|
||||
let mut ret_ty = func.ret_type(db);
|
||||
let mut detail = String::new();
|
||||
|
||||
|
@ -293,15 +303,15 @@ fn detail(db: &dyn HirDatabase, func: hir::Function) -> String {
|
|||
format_to!(detail, "unsafe ");
|
||||
}
|
||||
|
||||
format_to!(detail, "fn({})", params_display(db, func));
|
||||
format_to!(detail, "fn({})", params_display(db, func, edition));
|
||||
if !ret_ty.is_unit() {
|
||||
format_to!(detail, " -> {}", ret_ty.display(db));
|
||||
format_to!(detail, " -> {}", ret_ty.display(db, edition));
|
||||
}
|
||||
detail
|
||||
}
|
||||
|
||||
fn detail_full(db: &dyn HirDatabase, func: hir::Function) -> String {
|
||||
let signature = format!("{}", func.display(db));
|
||||
fn detail_full(db: &dyn HirDatabase, func: hir::Function, edition: Edition) -> String {
|
||||
let signature = format!("{}", func.display(db, edition));
|
||||
let mut detail = String::with_capacity(signature.len());
|
||||
|
||||
for segment in signature.split_whitespace() {
|
||||
|
@ -315,16 +325,16 @@ fn detail_full(db: &dyn HirDatabase, func: hir::Function) -> String {
|
|||
detail
|
||||
}
|
||||
|
||||
fn params_display(db: &dyn HirDatabase, func: hir::Function) -> String {
|
||||
fn params_display(db: &dyn HirDatabase, func: hir::Function, edition: Edition) -> String {
|
||||
if let Some(self_param) = func.self_param(db) {
|
||||
let assoc_fn_params = func.assoc_fn_params(db);
|
||||
let params = assoc_fn_params
|
||||
.iter()
|
||||
.skip(1) // skip the self param because we are manually handling that
|
||||
.map(|p| p.ty().display(db));
|
||||
.map(|p| p.ty().display(db, edition));
|
||||
format!(
|
||||
"{}{}",
|
||||
self_param.display(db),
|
||||
self_param.display(db, edition),
|
||||
params.format_with("", |display, f| {
|
||||
f(&", ")?;
|
||||
f(&display)
|
||||
|
@ -332,7 +342,7 @@ fn params_display(db: &dyn HirDatabase, func: hir::Function) -> String {
|
|||
)
|
||||
} else {
|
||||
let assoc_fn_params = func.assoc_fn_params(db);
|
||||
assoc_fn_params.iter().map(|p| p.ty().display(db)).join(", ")
|
||||
assoc_fn_params.iter().map(|p| p.ty().display(db, edition)).join(", ")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,16 +76,16 @@ fn render(
|
|||
};
|
||||
let (qualified_name, escaped_qualified_name) = (
|
||||
qualified_name.unescaped().display(ctx.db()).to_string(),
|
||||
qualified_name.display(ctx.db()).to_string(),
|
||||
qualified_name.display(ctx.db(), completion.edition).to_string(),
|
||||
);
|
||||
let snippet_cap = ctx.snippet_cap();
|
||||
|
||||
let mut rendered = match kind {
|
||||
StructKind::Tuple if should_add_parens => {
|
||||
render_tuple_lit(db, snippet_cap, &fields, &escaped_qualified_name)
|
||||
render_tuple_lit(db, snippet_cap, &fields, &escaped_qualified_name, completion.edition)
|
||||
}
|
||||
StructKind::Record if should_add_parens => {
|
||||
render_record_lit(db, snippet_cap, &fields, &escaped_qualified_name)
|
||||
render_record_lit(db, snippet_cap, &fields, &escaped_qualified_name, completion.edition)
|
||||
}
|
||||
_ => RenderedLiteral {
|
||||
literal: escaped_qualified_name.clone(),
|
||||
|
@ -103,7 +103,10 @@ fn render(
|
|||
}
|
||||
let label = format_literal_label(&qualified_name, kind, snippet_cap);
|
||||
let lookup = if qualified {
|
||||
format_literal_lookup(&short_qualified_name.display(ctx.db()).to_string(), kind)
|
||||
format_literal_lookup(
|
||||
&short_qualified_name.display(ctx.db(), completion.edition).to_string(),
|
||||
kind,
|
||||
)
|
||||
} else {
|
||||
format_literal_lookup(&qualified_name, kind)
|
||||
};
|
||||
|
@ -112,6 +115,7 @@ fn render(
|
|||
CompletionItemKind::SymbolKind(thing.symbol_kind()),
|
||||
ctx.source_range(),
|
||||
label,
|
||||
completion.edition,
|
||||
);
|
||||
|
||||
item.lookup_by(lookup);
|
||||
|
|
|
@ -46,8 +46,10 @@ fn render(
|
|||
ctx.source_range()
|
||||
};
|
||||
|
||||
let (name, escaped_name) =
|
||||
(name.unescaped().display(ctx.db()).to_smolstr(), name.display(ctx.db()).to_smolstr());
|
||||
let (name, escaped_name) = (
|
||||
name.unescaped().display(ctx.db()).to_smolstr(),
|
||||
name.display(ctx.db(), completion.edition).to_smolstr(),
|
||||
);
|
||||
let docs = ctx.docs(macro_);
|
||||
let docs_str = docs.as_ref().map(Documentation::as_str).unwrap_or_default();
|
||||
let is_fn_like = macro_.is_fn_like(completion.db);
|
||||
|
@ -59,9 +61,10 @@ fn render(
|
|||
SymbolKind::from(macro_.kind(completion.db)),
|
||||
source_range,
|
||||
label(&ctx, needs_bang, bra, ket, &name),
|
||||
completion.edition,
|
||||
);
|
||||
item.set_deprecated(ctx.is_deprecated(macro_))
|
||||
.detail(macro_.display(completion.db).to_string())
|
||||
.detail(macro_.display(completion.db, completion.edition).to_string())
|
||||
.set_documentation(docs)
|
||||
.set_relevance(ctx.completion_relevance());
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use hir::{db::HirDatabase, Name, StructKind};
|
||||
use ide_db::{documentation::HasDocs, SnippetCap};
|
||||
use itertools::Itertools;
|
||||
use syntax::{SmolStr, ToSmolStr};
|
||||
use syntax::{Edition, SmolStr, ToSmolStr};
|
||||
|
||||
use crate::{
|
||||
context::{ParamContext, ParamKind, PathCompletionCtx, PatternContext},
|
||||
|
@ -31,8 +31,10 @@ pub(crate) fn render_struct_pat(
|
|||
}
|
||||
|
||||
let name = local_name.unwrap_or_else(|| strukt.name(ctx.db()));
|
||||
let (name, escaped_name) =
|
||||
(name.unescaped().display(ctx.db()).to_smolstr(), name.display(ctx.db()).to_smolstr());
|
||||
let (name, escaped_name) = (
|
||||
name.unescaped().display(ctx.db()).to_smolstr(),
|
||||
name.display(ctx.db(), ctx.completion.edition).to_smolstr(),
|
||||
);
|
||||
let kind = strukt.kind(ctx.db());
|
||||
let label = format_literal_label(name.as_str(), kind, ctx.snippet_cap());
|
||||
let lookup = format_literal_lookup(name.as_str(), kind);
|
||||
|
@ -60,13 +62,13 @@ pub(crate) fn render_variant_pat(
|
|||
let (name, escaped_name) = match path {
|
||||
Some(path) => (
|
||||
path.unescaped().display(ctx.db()).to_string().into(),
|
||||
path.display(ctx.db()).to_string().into(),
|
||||
path.display(ctx.db(), ctx.completion.edition).to_string().into(),
|
||||
),
|
||||
None => {
|
||||
let name = local_name.unwrap_or_else(|| variant.name(ctx.db()));
|
||||
let it = (
|
||||
name.unescaped().display(ctx.db()).to_smolstr(),
|
||||
name.display(ctx.db()).to_smolstr(),
|
||||
name.display(ctx.db(), ctx.completion.edition).to_smolstr(),
|
||||
);
|
||||
it
|
||||
}
|
||||
|
@ -119,7 +121,12 @@ fn build_completion(
|
|||
relevance.type_match = super::compute_type_match(ctx.completion, &adt_ty);
|
||||
}
|
||||
|
||||
let mut item = CompletionItem::new(CompletionItemKind::Binding, ctx.source_range(), label);
|
||||
let mut item = CompletionItem::new(
|
||||
CompletionItemKind::Binding,
|
||||
ctx.source_range(),
|
||||
label,
|
||||
ctx.completion.edition,
|
||||
);
|
||||
item.set_documentation(ctx.docs(def))
|
||||
.set_deprecated(ctx.is_deprecated(def))
|
||||
.detail(&pat)
|
||||
|
@ -142,9 +149,14 @@ fn render_pat(
|
|||
) -> Option<String> {
|
||||
let mut pat = match kind {
|
||||
StructKind::Tuple => render_tuple_as_pat(ctx.snippet_cap(), fields, name, fields_omitted),
|
||||
StructKind::Record => {
|
||||
render_record_as_pat(ctx.db(), ctx.snippet_cap(), fields, name, fields_omitted)
|
||||
}
|
||||
StructKind::Record => render_record_as_pat(
|
||||
ctx.db(),
|
||||
ctx.snippet_cap(),
|
||||
fields,
|
||||
name,
|
||||
fields_omitted,
|
||||
ctx.completion.edition,
|
||||
),
|
||||
StructKind::Unit => name.to_owned(),
|
||||
};
|
||||
|
||||
|
@ -173,6 +185,7 @@ fn render_record_as_pat(
|
|||
fields: &[hir::Field],
|
||||
name: &str,
|
||||
fields_omitted: bool,
|
||||
edition: Edition,
|
||||
) -> String {
|
||||
let fields = fields.iter();
|
||||
match snippet_cap {
|
||||
|
@ -180,7 +193,7 @@ fn render_record_as_pat(
|
|||
format!(
|
||||
"{name} {{ {}{} }}",
|
||||
fields.enumerate().format_with(", ", |(idx, field), f| {
|
||||
f(&format_args!("{}${}", field.name(db).display(db.upcast()), idx + 1))
|
||||
f(&format_args!("{}${}", field.name(db).display(db.upcast(), edition), idx + 1))
|
||||
}),
|
||||
if fields_omitted { ", .." } else { "" },
|
||||
name = name
|
||||
|
@ -189,7 +202,7 @@ fn render_record_as_pat(
|
|||
None => {
|
||||
format!(
|
||||
"{name} {{ {}{} }}",
|
||||
fields.map(|field| field.name(db).display_no_db().to_smolstr()).format(", "),
|
||||
fields.map(|field| field.name(db).display_no_db(edition).to_smolstr()).format(", "),
|
||||
if fields_omitted { ", .." } else { "" },
|
||||
name = name
|
||||
)
|
||||
|
|
|
@ -33,14 +33,22 @@ fn render(
|
|||
let (name, escaped_name) = if with_eq {
|
||||
(
|
||||
SmolStr::from_iter([&name.unescaped().display(db).to_smolstr(), " = "]),
|
||||
SmolStr::from_iter([&name.display_no_db().to_smolstr(), " = "]),
|
||||
SmolStr::from_iter([&name.display_no_db(ctx.completion.edition).to_smolstr(), " = "]),
|
||||
)
|
||||
} else {
|
||||
(name.unescaped().display(db).to_smolstr(), name.display_no_db().to_smolstr())
|
||||
(
|
||||
name.unescaped().display(db).to_smolstr(),
|
||||
name.display_no_db(ctx.completion.edition).to_smolstr(),
|
||||
)
|
||||
};
|
||||
let detail = type_alias.display(db).to_string();
|
||||
let detail = type_alias.display(db, ctx.completion.edition).to_string();
|
||||
|
||||
let mut item = CompletionItem::new(SymbolKind::TypeAlias, ctx.source_range(), name);
|
||||
let mut item = CompletionItem::new(
|
||||
SymbolKind::TypeAlias,
|
||||
ctx.source_range(),
|
||||
name,
|
||||
ctx.completion.edition,
|
||||
);
|
||||
item.set_documentation(ctx.docs(type_alias))
|
||||
.set_deprecated(ctx.is_deprecated(type_alias) || ctx.is_deprecated_assoc_item(type_alias))
|
||||
.detail(detail)
|
||||
|
@ -48,7 +56,7 @@ fn render(
|
|||
|
||||
if let Some(actm) = type_alias.as_assoc_item(db) {
|
||||
if let Some(trt) = actm.container_or_implemented_trait(db) {
|
||||
item.trait_name(trt.name(db).display_no_db().to_smolstr());
|
||||
item.trait_name(trt.name(db).display_no_db(ctx.completion.edition).to_smolstr());
|
||||
}
|
||||
}
|
||||
item.insert_text(escaped_name);
|
||||
|
|
|
@ -22,21 +22,29 @@ 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().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())
|
||||
}
|
||||
Some(p) => (
|
||||
p.unescaped().display(ctx.db()).to_string(),
|
||||
p.display(ctx.db(), ctx.completion.edition).to_string(),
|
||||
),
|
||||
None => (
|
||||
name.unescaped().display(ctx.db()).to_string(),
|
||||
name.display(ctx.db(), ctx.completion.edition).to_string(),
|
||||
),
|
||||
};
|
||||
let label = format_literal_label(
|
||||
&name.display_no_db().to_smolstr(),
|
||||
&name.display_no_db(ctx.completion.edition).to_smolstr(),
|
||||
StructKind::Record,
|
||||
ctx.snippet_cap(),
|
||||
);
|
||||
let lookup = format_literal_lookup(&name.display_no_db().to_smolstr(), StructKind::Record);
|
||||
let lookup = format_literal_lookup(
|
||||
&name.display_no_db(ctx.completion.edition).to_smolstr(),
|
||||
StructKind::Record,
|
||||
);
|
||||
let mut item = CompletionItem::new(
|
||||
CompletionItemKind::SymbolKind(SymbolKind::Union),
|
||||
ctx.source_range(),
|
||||
label,
|
||||
ctx.completion.edition,
|
||||
);
|
||||
|
||||
item.lookup_by(lookup);
|
||||
|
@ -54,7 +62,10 @@ pub(crate) fn render_union_literal(
|
|||
escaped_qualified_name,
|
||||
fields
|
||||
.iter()
|
||||
.map(|field| field.name(ctx.db()).display_no_db().to_smolstr())
|
||||
.map(|field| field
|
||||
.name(ctx.db())
|
||||
.display_no_db(ctx.completion.edition)
|
||||
.to_smolstr())
|
||||
.format(",")
|
||||
)
|
||||
} else {
|
||||
|
@ -62,7 +73,10 @@ pub(crate) fn render_union_literal(
|
|||
"{} {{ {} }}",
|
||||
escaped_qualified_name,
|
||||
fields.iter().format_with(", ", |field, f| {
|
||||
f(&format_args!("{}: ()", field.name(ctx.db()).display(ctx.db())))
|
||||
f(&format_args!(
|
||||
"{}: ()",
|
||||
field.name(ctx.db()).display(ctx.db(), ctx.completion.edition)
|
||||
))
|
||||
})
|
||||
)
|
||||
};
|
||||
|
@ -73,8 +87,8 @@ pub(crate) fn render_union_literal(
|
|||
fields.iter().format_with(", ", |field, f| {
|
||||
f(&format_args!(
|
||||
"{}: {}",
|
||||
field.name(ctx.db()).display(ctx.db()),
|
||||
field.ty(ctx.db()).display(ctx.db())
|
||||
field.name(ctx.db()).display(ctx.db(), ctx.completion.edition),
|
||||
field.ty(ctx.db()).display(ctx.db(), ctx.completion.edition)
|
||||
))
|
||||
}),
|
||||
if fields_omitted { ", .." } else { "" }
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::context::CompletionContext;
|
|||
use hir::{db::HirDatabase, sym, HasAttrs, HasCrate, HasVisibility, HirDisplay, StructKind};
|
||||
use ide_db::SnippetCap;
|
||||
use itertools::Itertools;
|
||||
use syntax::SmolStr;
|
||||
use syntax::{Edition, SmolStr};
|
||||
|
||||
/// A rendered struct, union, or enum variant, split into fields for actual
|
||||
/// auto-completion (`literal`, using `field: ()`) and display in the
|
||||
|
@ -21,20 +21,29 @@ pub(crate) fn render_record_lit(
|
|||
snippet_cap: Option<SnippetCap>,
|
||||
fields: &[hir::Field],
|
||||
path: &str,
|
||||
edition: Edition,
|
||||
) -> RenderedLiteral {
|
||||
if snippet_cap.is_none() {
|
||||
return RenderedLiteral { literal: path.to_owned(), detail: path.to_owned() };
|
||||
}
|
||||
let completions = fields.iter().enumerate().format_with(", ", |(idx, field), f| {
|
||||
if snippet_cap.is_some() {
|
||||
f(&format_args!("{}: ${{{}:()}}", field.name(db).display(db.upcast()), idx + 1))
|
||||
f(&format_args!(
|
||||
"{}: ${{{}:()}}",
|
||||
field.name(db).display(db.upcast(), edition),
|
||||
idx + 1
|
||||
))
|
||||
} else {
|
||||
f(&format_args!("{}: ()", field.name(db).display(db.upcast())))
|
||||
f(&format_args!("{}: ()", field.name(db).display(db.upcast(), edition)))
|
||||
}
|
||||
});
|
||||
|
||||
let types = fields.iter().format_with(", ", |field, f| {
|
||||
f(&format_args!("{}: {}", field.name(db).display(db.upcast()), field.ty(db).display(db)))
|
||||
f(&format_args!(
|
||||
"{}: {}",
|
||||
field.name(db).display(db.upcast(), edition),
|
||||
field.ty(db).display(db, edition)
|
||||
))
|
||||
});
|
||||
|
||||
RenderedLiteral {
|
||||
|
@ -50,6 +59,7 @@ pub(crate) fn render_tuple_lit(
|
|||
snippet_cap: Option<SnippetCap>,
|
||||
fields: &[hir::Field],
|
||||
path: &str,
|
||||
edition: Edition,
|
||||
) -> RenderedLiteral {
|
||||
if snippet_cap.is_none() {
|
||||
return RenderedLiteral { literal: path.to_owned(), detail: path.to_owned() };
|
||||
|
@ -62,7 +72,7 @@ pub(crate) fn render_tuple_lit(
|
|||
}
|
||||
});
|
||||
|
||||
let types = fields.iter().format_with(", ", |field, f| f(&field.ty(db).display(db)));
|
||||
let types = fields.iter().format_with(", ", |field, f| f(&field.ty(db).display(db, edition)));
|
||||
|
||||
RenderedLiteral {
|
||||
literal: format!("{path}({completions})"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue