]> git.lizzy.rs Git - rust.git/commitdiff
save-analysis: add values for types
authorNick Cameron <ncameron@mozilla.com>
Sun, 23 Nov 2014 01:57:26 +0000 (14:57 +1300)
committerNick Cameron <ncameron@mozilla.com>
Sun, 23 Nov 2014 02:02:58 +0000 (15:02 +1300)
src/librustc_trans/save/mod.rs
src/librustc_trans/save/recorder.rs

index b573b8702fa2e448ea30549201965ff8444c42ba..b9273d2be1cfded3f7ae97ecb9d4517b2632299a 100644 (file)
@@ -568,13 +568,15 @@ fn process_struct(&mut self,
             Some(node_id) => node_id,
             None => -1,
         };
+        let val = self.span.snippet(item.span);
         let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Struct);
         self.fmt.struct_str(item.span,
                             sub_span,
                             item.id,
                             ctor_id,
                             qualname.as_slice(),
-                            self.cur_scope);
+                            self.cur_scope,
+                            val.as_slice());
 
         // fields
         for field in def.fields.iter() {
@@ -590,12 +592,14 @@ fn process_enum(&mut self,
                     enum_definition: &ast::EnumDef,
                     ty_params: &ast::Generics) {
         let enum_name = self.analysis.ty_cx.map.path_to_string(item.id);
+        let val = self.span.snippet(item.span);
         match self.span.sub_span_after_keyword(item.span, keywords::Enum) {
             Some(sub_span) => self.fmt.enum_str(item.span,
                                                 Some(sub_span),
                                                 item.id,
                                                 enum_name.as_slice(),
-                                                self.cur_scope),
+                                                self.cur_scope,
+                                                val.as_slice()),
             None => self.sess.span_bug(item.span,
                                        format!("Could not find subspan for enum {}",
                                                enum_name).as_slice()),
@@ -700,13 +704,14 @@ fn process_trait(&mut self,
                      trait_refs: &OwnedSlice<ast::TyParamBound>,
                      methods: &Vec<ast::TraitItem>) {
         let qualname = self.analysis.ty_cx.map.path_to_string(item.id);
-
+        let val = self.span.snippet(item.span);
         let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Trait);
         self.fmt.trait_str(item.span,
                            sub_span,
                            item.id,
                            qualname.as_slice(),
-                           self.cur_scope);
+                           self.cur_scope,
+                           val.as_slice());
 
         // super-traits
         for super_bound in trait_refs.iter() {
index 1ff1a96f0d8816b2f17769ac8adcbac077c49892..8eda199af3bb59f355ebed0a7a761c81a70b0284 100644 (file)
@@ -106,7 +106,7 @@ fn lookup_row(r: Row) -> (&'static str, Vec<&'static str>, bool, bool) {
             Variable => ("variable",
                          vec!("id","name","qualname","value","type","scopeid"),
                          true, true),
-            Enum => ("enum", vec!("id","qualname","scopeid"), true, true),
+            Enum => ("enum", vec!("id","qualname","scopeid","value"), true, true),
             Variant => ("variant",
                         vec!("id","name","qualname","type","value","scopeid"),
                         true, true),
@@ -117,8 +117,8 @@ fn lookup_row(r: Row) -> (&'static str, Vec<&'static str>, bool, bool) {
                          vec!("id","qualname","declid","declidcrate","scopeid"),
                          true, true),
             MethodDecl => ("method_decl", vec!("id","qualname","scopeid"), true, true),
-            Struct => ("struct", vec!("id","ctor_id","qualname","scopeid"), true, true),
-            Trait => ("trait", vec!("id","qualname","scopeid"), true, true),
+            Struct => ("struct", vec!("id","ctor_id","qualname","scopeid","value"), true, true),
+            Trait => ("trait", vec!("id","qualname","scopeid","value"), true, true),
             Impl => ("impl", vec!("id","refid","refidcrate","scopeid"), true, true),
             Module => ("module", vec!("id","qualname","scopeid","def_file"), true, false),
             UseAlias => ("use_alias",
@@ -161,6 +161,7 @@ pub fn make_values_str(&self,
         }
 
         let values = values.iter().map(|s| {
+            // Never take more than 1020 chars
             if s.len() > 1020 {
                 s.as_slice().slice_to(1020)
             } else {
@@ -327,11 +328,12 @@ pub fn enum_str(&mut self,
                     sub_span: Option<Span>,
                     id: NodeId,
                     name: &str,
-                    scope_id: NodeId) {
+                    scope_id: NodeId,
+                    value: &str) {
         self.check_and_record(Enum,
                               span,
                               sub_span,
-                              svec!(id, name, scope_id));
+                              svec!(id, name, scope_id, value));
     }
 
     pub fn tuple_variant_str(&mut self,
@@ -411,11 +413,12 @@ pub fn struct_str(&mut self,
                       id: NodeId,
                       ctor_id: NodeId,
                       name: &str,
-                      scope_id: NodeId) {
+                      scope_id: NodeId,
+                      value: &str) {
         self.check_and_record(Struct,
                               span,
                               sub_span,
-                              svec!(id, ctor_id, name, scope_id));
+                              svec!(id, ctor_id, name, scope_id, value));
     }
 
     pub fn trait_str(&mut self,
@@ -423,11 +426,12 @@ pub fn trait_str(&mut self,
                      sub_span: Option<Span>,
                      id: NodeId,
                      name: &str,
-                     scope_id: NodeId) {
+                     scope_id: NodeId,
+                     value: &str) {
         self.check_and_record(Trait,
                               span,
                               sub_span,
-                              svec!(id, name, scope_id));
+                              svec!(id, name, scope_id, value));
     }
 
     pub fn impl_str(&mut self,