Skip to content

Commit 13c4e32

Browse files
authored
Auto merge of #36288 - nrc:save-var-value, r=eddyb
save-analysis: some refinement to the value string for variables
2 parents 5114f8a + 92a1848 commit 13c4e32

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/librustc_save_analysis/dump_visitor.rs

+15-7
Original file line numberDiff line numberDiff line change
@@ -982,15 +982,23 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
982982
self.visit_pat(&p);
983983

984984
for &(id, ref p, immut, _) in &collector.collected_paths {
985-
let mut value = if immut == ast::Mutability::Immutable {
986-
value.to_string()
987-
} else {
988-
"<mutable>".to_string()
985+
let mut value = match immut {
986+
ast::Mutability::Immutable => value.to_string(),
987+
_ => String::new(),
989988
};
990989
let types = self.tcx.node_types();
991-
let typ = types.get(&id).map(|t| t.to_string()).unwrap_or(String::new());
992-
value.push_str(": ");
993-
value.push_str(&typ);
990+
let typ = match types.get(&id) {
991+
Some(typ) => {
992+
let typ = typ.to_string();
993+
if !value.is_empty() {
994+
value.push_str(": ");
995+
}
996+
value.push_str(&typ);
997+
typ
998+
}
999+
None => String::new(),
1000+
};
1001+
9941002
// Get the span only for the name of the variable (I hope the path
9951003
// is only ever a variable name, but who knows?).
9961004
let sub_span = self.span.span_for_last_ident(p.span);

0 commit comments

Comments
 (0)