diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs index aadd4e44ae..89a1ea7709 100644 --- a/crates/hir_def/src/attr.rs +++ b/crates/hir_def/src/attr.rs @@ -2,7 +2,7 @@ use std::{ convert::{TryFrom, TryInto}, - ops, + fmt, ops, sync::Arc, }; @@ -648,6 +648,15 @@ pub enum AttrInput { TokenTree(Subtree), } +impl fmt::Display for AttrInput { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + AttrInput::Literal(lit) => write!(f, " = \"{}\"", lit.escape_debug()), + AttrInput::TokenTree(subtree) => subtree.fmt(f), + } + } +} + impl Attr { fn from_src( db: &dyn DefDatabase, diff --git a/crates/hir_def/src/path.rs b/crates/hir_def/src/path.rs index a43441b1c2..9b8873fd25 100644 --- a/crates/hir_def/src/path.rs +++ b/crates/hir_def/src/path.rs @@ -46,6 +46,15 @@ pub enum ImportAlias { Alias(Name), } +impl Display for ImportAlias { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + ImportAlias::Underscore => f.write_str("_"), + ImportAlias::Alias(name) => f.write_str(&name.to_string()), + } + } +} + impl ModPath { pub fn from_src(db: &dyn DefDatabase, path: ast::Path, hygiene: &Hygiene) -> Option { let ctx = LowerCtx::with_hygiene(db, hygiene);