Skip to content

Commit e5d291a

Browse files
committed
mir-borrowck: Use bool for autoderef in append_lvalue_to_string()
1 parent 094d67e commit e5d291a

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/librustc_mir/borrow_check.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -1577,15 +1577,15 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
15771577
// End-user visible description of `lvalue`
15781578
fn describe_lvalue(&self, lvalue: &Lvalue<'tcx>) -> String {
15791579
let mut buf = String::new();
1580-
self.append_lvalue_to_string(lvalue, &mut buf, None);
1580+
self.append_lvalue_to_string(lvalue, &mut buf, false);
15811581
buf
15821582
}
15831583

15841584
// Appends end-user visible description of `lvalue` to `buf`.
15851585
fn append_lvalue_to_string(&self,
15861586
lvalue: &Lvalue<'tcx>,
15871587
buf: &mut String,
1588-
autoderef: Option<bool>) {
1588+
mut autoderef: bool) {
15891589
match *lvalue {
15901590
Lvalue::Local(local) => {
15911591
self.append_local_to_string(local, buf, "_");
@@ -1594,19 +1594,17 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
15941594
buf.push_str(&format!("{}", &self.tcx.item_name(static_.def_id)));
15951595
}
15961596
Lvalue::Projection(ref proj) => {
1597-
let mut autoderef = autoderef.unwrap_or(false);
1598-
15991597
match proj.elem {
16001598
ProjectionElem::Deref => {
16011599
if autoderef {
1602-
self.append_lvalue_to_string(&proj.base, buf, Some(autoderef));
1600+
self.append_lvalue_to_string(&proj.base, buf, autoderef);
16031601
} else {
16041602
buf.push_str(&"*");
1605-
self.append_lvalue_to_string(&proj.base, buf, Some(autoderef));
1603+
self.append_lvalue_to_string(&proj.base, buf, autoderef);
16061604
}
16071605
},
16081606
ProjectionElem::Downcast(..) => {
1609-
self.append_lvalue_to_string(&proj.base, buf, Some(autoderef));
1607+
self.append_lvalue_to_string(&proj.base, buf, autoderef);
16101608
},
16111609
ProjectionElem::Field(field, _ty) => {
16121610
autoderef = true;
@@ -1617,14 +1615,14 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
16171615
if is_projection_from_ty_closure {
16181616
buf.push_str(&format!("{}", field_name));
16191617
} else {
1620-
self.append_lvalue_to_string(&proj.base, buf, Some(autoderef));
1618+
self.append_lvalue_to_string(&proj.base, buf, autoderef);
16211619
buf.push_str(&format!(".{}", field_name));
16221620
}
16231621
},
16241622
ProjectionElem::Index(index) => {
16251623
autoderef = true;
16261624

1627-
self.append_lvalue_to_string(&proj.base, buf, Some(autoderef));
1625+
self.append_lvalue_to_string(&proj.base, buf, autoderef);
16281626
buf.push_str("[");
16291627
self.append_local_to_string(index, buf, "..");
16301628
buf.push_str("]");
@@ -1634,7 +1632,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
16341632
// Since it isn't possible to borrow an element on a particular index and
16351633
// then use another while the borrow is held, don't output indices details
16361634
// to avoid confusing the end-user
1637-
self.append_lvalue_to_string(&proj.base, buf, Some(autoderef));
1635+
self.append_lvalue_to_string(&proj.base, buf, autoderef);
16381636
buf.push_str(&"[..]");
16391637
},
16401638
};

0 commit comments

Comments
 (0)