diff options
Diffstat (limited to 'crates/hir_def/src/item_tree/pretty.rs')
-rw-r--r-- | crates/hir_def/src/item_tree/pretty.rs | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/crates/hir_def/src/item_tree/pretty.rs b/crates/hir_def/src/item_tree/pretty.rs index 9394a5de6..d1ee697cb 100644 --- a/crates/hir_def/src/item_tree/pretty.rs +++ b/crates/hir_def/src/item_tree/pretty.rs | |||
@@ -163,21 +163,46 @@ impl<'a> Printer<'a> { | |||
163 | } | 163 | } |
164 | } | 164 | } |
165 | 165 | ||
166 | fn print_use_tree(&mut self, use_tree: &UseTree) { | ||
167 | match &use_tree.kind { | ||
168 | UseTreeKind::Single { path, alias } => { | ||
169 | w!(self, "{}", path); | ||
170 | if let Some(alias) = alias { | ||
171 | w!(self, " as {}", alias); | ||
172 | } | ||
173 | } | ||
174 | UseTreeKind::Glob { path } => { | ||
175 | if let Some(path) = path { | ||
176 | w!(self, "{}::", path); | ||
177 | } | ||
178 | w!(self, "*"); | ||
179 | } | ||
180 | UseTreeKind::Prefixed { prefix, list } => { | ||
181 | if let Some(prefix) = prefix { | ||
182 | w!(self, "{}::", prefix); | ||
183 | } | ||
184 | w!(self, "{{"); | ||
185 | for (i, tree) in list.iter().enumerate() { | ||
186 | if i != 0 { | ||
187 | w!(self, ", "); | ||
188 | } | ||
189 | self.print_use_tree(tree); | ||
190 | } | ||
191 | w!(self, "}}"); | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | |||
166 | fn print_mod_item(&mut self, item: ModItem) { | 196 | fn print_mod_item(&mut self, item: ModItem) { |
167 | self.print_attrs_of(item); | 197 | self.print_attrs_of(item); |
168 | 198 | ||
169 | match item { | 199 | match item { |
170 | ModItem::Import(it) => { | 200 | ModItem::Import(it) => { |
171 | let Import { visibility, path, is_glob, alias, ast_id: _, index } = &self.tree[it]; | 201 | let Import { visibility, use_tree, ast_id: _ } = &self.tree[it]; |
172 | self.print_visibility(*visibility); | 202 | self.print_visibility(*visibility); |
173 | w!(self, "use {}", path); | 203 | w!(self, "use "); |
174 | if *is_glob { | 204 | self.print_use_tree(use_tree); |
175 | w!(self, "::*"); | 205 | wln!(self, ";"); |
176 | } | ||
177 | if let Some(alias) = alias { | ||
178 | w!(self, " as {}", alias); | ||
179 | } | ||
180 | wln!(self, "; // {}", index); | ||
181 | } | 206 | } |
182 | ModItem::ExternCrate(it) => { | 207 | ModItem::ExternCrate(it) => { |
183 | let ExternCrate { name, alias, visibility, ast_id: _ } = &self.tree[it]; | 208 | let ExternCrate { name, alias, visibility, ast_id: _ } = &self.tree[it]; |
@@ -320,7 +345,6 @@ impl<'a> Printer<'a> { | |||
320 | visibility, | 345 | visibility, |
321 | is_auto, | 346 | is_auto, |
322 | is_unsafe, | 347 | is_unsafe, |
323 | bounds, | ||
324 | items, | 348 | items, |
325 | generic_params, | 349 | generic_params, |
326 | ast_id: _, | 350 | ast_id: _, |
@@ -334,10 +358,6 @@ impl<'a> Printer<'a> { | |||
334 | } | 358 | } |
335 | w!(self, "trait {}", name); | 359 | w!(self, "trait {}", name); |
336 | self.print_generic_params(generic_params); | 360 | self.print_generic_params(generic_params); |
337 | if !bounds.is_empty() { | ||
338 | w!(self, ": "); | ||
339 | self.print_type_bounds(bounds); | ||
340 | } | ||
341 | self.print_where_clause_and_opening_brace(generic_params); | 361 | self.print_where_clause_and_opening_brace(generic_params); |
342 | self.indented(|this| { | 362 | self.indented(|this| { |
343 | for item in &**items { | 363 | for item in &**items { |