Skip to content

Commit a9bafe5

Browse files
committed
save-analysis: support unions
1 parent 90ef337 commit a9bafe5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/librustc_save_analysis/dump_visitor.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,13 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
554554

555555
if !self.span.filter_generated(sub_span, item.span) {
556556
let span = self.span_from_span(sub_span.expect("No span found for struct"));
557+
let kind = match item.node {
558+
ast::ItemKind::Struct(_, _) => DefKind::Struct,
559+
ast::ItemKind::Union(_, _) => DefKind::Union,
560+
_ => unreachable!(),
561+
};
557562
self.dumper.dump_def(item.vis == ast::Visibility::Public, Def {
558-
kind: DefKind::Struct,
563+
kind,
559564
id: ::id_from_node_id(item.id, &self.save_ctxt),
560565
span,
561566
name,
@@ -1212,7 +1217,9 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
12121217
self.process_static_or_const_item(item, typ, expr),
12131218
Const(ref typ, ref expr) =>
12141219
self.process_static_or_const_item(item, &typ, &expr),
1215-
Struct(ref def, ref ty_params) => self.process_struct(item, def, ty_params),
1220+
Struct(ref def, ref ty_params) | Union(ref def, ref ty_params) => {
1221+
self.process_struct(item, def, ty_params)
1222+
}
12161223
Enum(ref def, ref ty_params) => self.process_enum(item, def, ty_params),
12171224
Impl(..,
12181225
ref ty_params,

src/test/run-make/save-analysis/foo.rs

+5
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,11 @@ fn test_format_args() {
441441
print!("x is {}, y is {1}, name is {n}", x, y, n = name);
442442
}
443443

444+
445+
union TestUnion {
446+
f1: u32
447+
}
448+
444449
struct FrameBuffer;
445450

446451
struct SilenceGenerator;

0 commit comments

Comments
 (0)