]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #45647 - nrc:rls-bugs, r=eddyb
authorbors <bors@rust-lang.org>
Thu, 2 Nov 2017 12:34:13 +0000 (12:34 +0000)
committerbors <bors@rust-lang.org>
Thu, 2 Nov 2017 12:34:13 +0000 (12:34 +0000)
save-analysis: support unions

r? @eddyb

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

index 2658ba22e7d1642d94be429778361a9c996b03a3..dcce714e5423d44f1efb8f9f888cb80038a96fc6 100644 (file)
@@ -558,8 +558,13 @@ fn process_struct(&mut self,
 
         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,
@@ -1216,7 +1221,9 @@ fn visit_item(&mut self, item: &'l ast::Item) {
                 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,
index 5cb363ac34435719f0c493518753cbbad34195e3..834a7554a555d4a48a37327f686bc6f3f76e2672 100644 (file)
@@ -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;