diff options
| author | bors <bors@rust-lang.org> | 2016-09-06 07:46:06 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-09-06 07:46:06 -0700 |
| commit | 13c4e32e7aca87cbf867be68bf0fc45528bb3fcf (patch) | |
| tree | 7f844ba6ac67b7bc253e2d5097dfaec3d368e49f /src | |
| parent | 5114f8a29ba29c7a168b46ede82fb62d67a2d619 (diff) | |
| parent | 92a1848d7725495676d8db1cadca50836787eccd (diff) | |
| download | rust-13c4e32e7aca87cbf867be68bf0fc45528bb3fcf.tar.gz rust-13c4e32e7aca87cbf867be68bf0fc45528bb3fcf.zip | |
Auto merge of #36288 - nrc:save-var-value, r=eddyb
save-analysis: some refinement to the value string for variables
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_save_analysis/dump_visitor.rs | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 9f8571e50a2..ebd0bdc71d7 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -982,15 +982,23 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> { 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); |
