internal: Replace Display impl for Name

This commit is contained in:
Lukas Wirth 2023-05-24 18:04:29 +02:00
parent 2f840c2236
commit c7ef6c25b7
108 changed files with 1045 additions and 656 deletions

View file

@ -31,7 +31,7 @@ use crate::{fix, Diagnostic, DiagnosticsContext};
pub(crate) fn missing_fields(ctx: &DiagnosticsContext<'_>, d: &hir::MissingFields) -> Diagnostic {
let mut message = String::from("missing structure fields:\n");
for field in &d.missed_fields {
format_to!(message, "- {}\n", field);
format_to!(message, "- {}\n", field.display(ctx.sema.db));
}
let ptr = InFile::new(
@ -175,7 +175,7 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::MissingFields) -> Option<Vec<Ass
fn make_ty(ty: &hir::Type, db: &dyn HirDatabase, module: hir::Module) -> ast::Type {
let ty_str = match ty.as_adt() {
Some(adt) => adt.name(db).to_string(),
Some(adt) => adt.name(db).display(db.upcast()).to_string(),
None => {
ty.display_source_code(db, module.into(), false).ok().unwrap_or_else(|| "_".to_string())
}