diff options
Diffstat (limited to 'crates/syntax/src/display.rs')
-rw-r--r-- | crates/syntax/src/display.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/crates/syntax/src/display.rs b/crates/syntax/src/display.rs index d33bde30c..391647fc6 100644 --- a/crates/syntax/src/display.rs +++ b/crates/syntax/src/display.rs | |||
@@ -76,8 +76,20 @@ pub fn type_label(node: &ast::TypeAlias) -> String { | |||
76 | label.trim().to_owned() | 76 | label.trim().to_owned() |
77 | } | 77 | } |
78 | 78 | ||
79 | pub fn macro_label(node: &ast::MacroRules) -> String { | 79 | pub fn macro_label(node: &ast::Macro) -> String { |
80 | let name = node.name().map(|name| name.syntax().text().to_string()).unwrap_or_default(); | 80 | let name = node.name().map(|name| name.syntax().text().to_string()).unwrap_or_default(); |
81 | let vis = if node.has_atom_attr("macro_export") { "#[macro_export]\n" } else { "" }; | 81 | match node { |
82 | format!("{}macro_rules! {}", vis, name) | 82 | ast::Macro::MacroRules(node) => { |
83 | let vis = if node.has_atom_attr("macro_export") { "#[macro_export]\n" } else { "" }; | ||
84 | format!("{}macro_rules! {}", vis, name) | ||
85 | } | ||
86 | ast::Macro::MacroDef(node) => { | ||
87 | let mut s = String::new(); | ||
88 | if let Some(vis) = node.visibility() { | ||
89 | format_to!(s, "{} ", vis); | ||
90 | } | ||
91 | format_to!(s, "macro {}", name); | ||
92 | s | ||
93 | } | ||
94 | } | ||
83 | } | 95 | } |