Skip to content

Commit 5ce3d48

Browse files
committed
Auto merge of #45647 - nrc:rls-bugs, r=eddyb
save-analysis: support unions r? @eddyb
2 parents a7d98c7 + a9bafe5 commit 5ce3d48

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
@@ -558,8 +558,13 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
558558

559559
if !self.span.filter_generated(sub_span, item.span) {
560560
let span = self.span_from_span(sub_span.expect("No span found for struct"));
561+
let kind = match item.node {
562+
ast::ItemKind::Struct(_, _) => DefKind::Struct,
563+
ast::ItemKind::Union(_, _) => DefKind::Union,
564+
_ => unreachable!(),
565+
};
561566
self.dumper.dump_def(item.vis == ast::Visibility::Public, Def {
562-
kind: DefKind::Struct,
567+
kind,
563568
id: ::id_from_node_id(item.id, &self.save_ctxt),
564569
span,
565570
name,
@@ -1216,7 +1221,9 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> Visitor<'l> for DumpVisitor<'l, 'tc
12161221
self.process_static_or_const_item(item, typ, expr),
12171222
Const(ref typ, ref expr) =>
12181223
self.process_static_or_const_item(item, &typ, &expr),
1219-
Struct(ref def, ref ty_params) => self.process_struct(item, def, ty_params),
1224+
Struct(ref def, ref ty_params) | Union(ref def, ref ty_params) => {
1225+
self.process_struct(item, def, ty_params)
1226+
}
12201227
Enum(ref def, ref ty_params) => self.process_enum(item, def, ty_params),
12211228
Impl(..,
12221229
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)