diff options
-rw-r--r-- | crates/hir_def/src/attr.rs | 11 | ||||
-rw-r--r-- | crates/hir_def/src/path.rs | 9 |
2 files changed, 19 insertions, 1 deletions
diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs index aadd4e44a..89a1ea770 100644 --- a/crates/hir_def/src/attr.rs +++ b/crates/hir_def/src/attr.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | use std::{ | 3 | use std::{ |
4 | convert::{TryFrom, TryInto}, | 4 | convert::{TryFrom, TryInto}, |
5 | ops, | 5 | fmt, ops, |
6 | sync::Arc, | 6 | sync::Arc, |
7 | }; | 7 | }; |
8 | 8 | ||
@@ -648,6 +648,15 @@ pub enum AttrInput { | |||
648 | TokenTree(Subtree), | 648 | TokenTree(Subtree), |
649 | } | 649 | } |
650 | 650 | ||
651 | impl fmt::Display for AttrInput { | ||
652 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
653 | match self { | ||
654 | AttrInput::Literal(lit) => write!(f, " = \"{}\"", lit.escape_debug()), | ||
655 | AttrInput::TokenTree(subtree) => subtree.fmt(f), | ||
656 | } | ||
657 | } | ||
658 | } | ||
659 | |||
651 | impl Attr { | 660 | impl Attr { |
652 | fn from_src( | 661 | fn from_src( |
653 | db: &dyn DefDatabase, | 662 | db: &dyn DefDatabase, |
diff --git a/crates/hir_def/src/path.rs b/crates/hir_def/src/path.rs index a43441b1c..9b8873fd2 100644 --- a/crates/hir_def/src/path.rs +++ b/crates/hir_def/src/path.rs | |||
@@ -46,6 +46,15 @@ pub enum ImportAlias { | |||
46 | Alias(Name), | 46 | Alias(Name), |
47 | } | 47 | } |
48 | 48 | ||
49 | impl Display for ImportAlias { | ||
50 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
51 | match self { | ||
52 | ImportAlias::Underscore => f.write_str("_"), | ||
53 | ImportAlias::Alias(name) => f.write_str(&name.to_string()), | ||
54 | } | ||
55 | } | ||
56 | } | ||
57 | |||
49 | impl ModPath { | 58 | impl ModPath { |
50 | pub fn from_src(db: &dyn DefDatabase, path: ast::Path, hygiene: &Hygiene) -> Option<ModPath> { | 59 | pub fn from_src(db: &dyn DefDatabase, path: ast::Path, hygiene: &Hygiene) -> Option<ModPath> { |
51 | let ctx = LowerCtx::with_hygiene(db, hygiene); | 60 | let ctx = LowerCtx::with_hygiene(db, hygiene); |