diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 4eac4398c1827..0a005cc536661 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -554,8 +554,13 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { if !self.span.filter_generated(sub_span, item.span) { let span = self.span_from_span(sub_span.expect("No span found for struct")); + let kind = match item.node { + ast::ItemKind::Struct(_, _) => DefKind::Struct, + ast::ItemKind::Union(_, _) => DefKind::Union, + _ => unreachable!(), + }; self.dumper.dump_def(item.vis == ast::Visibility::Public, Def { - kind: DefKind::Struct, + kind, id: ::id_from_node_id(item.id, &self.save_ctxt), span, name, @@ -1212,7 +1217,9 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc self.process_static_or_const_item(item, typ, expr), Const(ref typ, ref expr) => self.process_static_or_const_item(item, &typ, &expr), - Struct(ref def, ref ty_params) => self.process_struct(item, def, ty_params), + Struct(ref def, ref ty_params) | Union(ref def, ref ty_params) => { + self.process_struct(item, def, ty_params) + } Enum(ref def, ref ty_params) => self.process_enum(item, def, ty_params), Impl(.., ref ty_params, diff --git a/src/test/run-make/save-analysis/foo.rs b/src/test/run-make/save-analysis/foo.rs index 5cb363ac34435..834a7554a555d 100644 --- a/src/test/run-make/save-analysis/foo.rs +++ b/src/test/run-make/save-analysis/foo.rs @@ -441,6 +441,11 @@ fn test_format_args() { print!("x is {}, y is {1}, name is {n}", x, y, n = name); } + +union TestUnion { + f1: u32 +} + struct FrameBuffer; struct SilenceGenerator;