Skip to content

save-analysis: support unions #45647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/librustc_save_analysis/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/test/run-make/save-analysis/foo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down