Skip to content

Commit

Permalink
save-analysis: some refinement to the value string for variables
Browse files Browse the repository at this point in the history
  • Loading branch information
nrc committed Sep 6, 2016
1 parent 987b475 commit 92a1848
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/librustc_save_analysis/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 92a1848

Please sign in to comment.