|
1 | 1 | //! Describes items defined or visible (ie, imported) in a certain scope. |
2 | 2 | //! This is shared between modules and blocks. |
3 | 3 |
|
4 | | -use std::sync::LazyLock; |
| 4 | +use std::{fmt, sync::LazyLock}; |
5 | 5 |
|
6 | 6 | use base_db::Crate; |
7 | 7 | use hir_expand::{AstId, MacroCallId, attrs::AttrId, db::ExpandDatabase, name::Name}; |
@@ -740,35 +740,35 @@ impl ItemScope { |
740 | 740 | entries.sort_by_key(|(name, _)| name.clone()); |
741 | 741 |
|
742 | 742 | for (name, def) in entries { |
743 | | - format_to!( |
744 | | - buf, |
745 | | - "{}:", |
746 | | - name.map_or("_".to_owned(), |name| name.display(db, Edition::LATEST).to_string()) |
747 | | - ); |
| 743 | + let display_name: &dyn fmt::Display = match &name { |
| 744 | + Some(name) => &name.display(db, Edition::LATEST), |
| 745 | + None => &"_", |
| 746 | + }; |
| 747 | + format_to!(buf, "- {display_name} :"); |
748 | 748 |
|
749 | 749 | if let Some(Item { import, .. }) = def.types { |
750 | | - buf.push_str(" t"); |
| 750 | + buf.push_str(" type"); |
751 | 751 | match import { |
752 | | - Some(ImportOrExternCrate::Import(_)) => buf.push('i'), |
753 | | - Some(ImportOrExternCrate::Glob(_)) => buf.push('g'), |
754 | | - Some(ImportOrExternCrate::ExternCrate(_)) => buf.push('e'), |
| 752 | + Some(ImportOrExternCrate::Import(_)) => buf.push_str(" (import)"), |
| 753 | + Some(ImportOrExternCrate::Glob(_)) => buf.push_str(" (glob)"), |
| 754 | + Some(ImportOrExternCrate::ExternCrate(_)) => buf.push_str(" (extern)"), |
755 | 755 | None => (), |
756 | 756 | } |
757 | 757 | } |
758 | 758 | if let Some(Item { import, .. }) = def.values { |
759 | | - buf.push_str(" v"); |
| 759 | + buf.push_str(" value"); |
760 | 760 | match import { |
761 | | - Some(ImportOrGlob::Import(_)) => buf.push('i'), |
762 | | - Some(ImportOrGlob::Glob(_)) => buf.push('g'), |
| 761 | + Some(ImportOrGlob::Import(_)) => buf.push_str(" (import)"), |
| 762 | + Some(ImportOrGlob::Glob(_)) => buf.push_str(" (glob)"), |
763 | 763 | None => (), |
764 | 764 | } |
765 | 765 | } |
766 | 766 | if let Some(Item { import, .. }) = def.macros { |
767 | | - buf.push_str(" m"); |
| 767 | + buf.push_str(" macro"); |
768 | 768 | match import { |
769 | | - Some(ImportOrExternCrate::Import(_)) => buf.push('i'), |
770 | | - Some(ImportOrExternCrate::Glob(_)) => buf.push('g'), |
771 | | - Some(ImportOrExternCrate::ExternCrate(_)) => buf.push('e'), |
| 769 | + Some(ImportOrExternCrate::Import(_)) => buf.push_str(" (import)"), |
| 770 | + Some(ImportOrExternCrate::Glob(_)) => buf.push_str(" (glob)"), |
| 771 | + Some(ImportOrExternCrate::ExternCrate(_)) => buf.push_str(" (extern)"), |
772 | 772 | None => (), |
773 | 773 | } |
774 | 774 | } |
|
0 commit comments