]> git.lizzy.rs Git - rust.git/commitdiff
save-analysis: some refinement to the value string for variables
authorNick Cameron <ncameron@mozilla.com>
Tue, 6 Sep 2016 00:44:26 +0000 (12:44 +1200)
committerNick Cameron <ncameron@mozilla.com>
Tue, 6 Sep 2016 01:07:59 +0000 (13:07 +1200)
src/librustc_save_analysis/dump_visitor.rs

index a695a07066205b4e26971951bf2a44720336f047..df657cadcbe1bfdc1ce511bfda0c814463442bd4 100644 (file)
@@ -982,15 +982,23 @@ fn process_var_decl(&mut self, p: &ast::Pat, value: String) {
         self.visit_pat(&p);
 
         for &(id, ref p, immut, _) in &collector.collected_paths {
-            let mut value = if immut == ast::Mutability::Immutable {
-                value.to_string()
-            } else {
-                "<mutable>".to_string()
+            let mut value = match immut {
+                ast::Mutability::Immutable => value.to_string(),
+                _ => String::new(),
             };
             let types = self.tcx.node_types();
-            let typ = types.get(&id).map(|t| t.to_string()).unwrap_or(String::new());
-            value.push_str(": ");
-            value.push_str(&typ);
+            let typ = match types.get(&id) {
+                Some(typ) => {
+                    let typ = typ.to_string();
+                    if !value.is_empty() {
+                        value.push_str(": ");
+                    }
+                    value.push_str(&typ);
+                    typ
+                }
+                None => String::new(),
+            };
+
             // Get the span only for the name of the variable (I hope the path
             // is only ever a variable name, but who knows?).
             let sub_span = self.span.span_for_last_ident(p.span);