diff options
| author | Basile Desloges <basile.desloges@gmail.com> | 2017-11-16 17:06:48 +0100 |
|---|---|---|
| committer | Basile Desloges <basile.desloges@gmail.com> | 2017-11-19 20:19:11 +0100 |
| commit | e5d291afbfd253cdca60bcf83f2afb2b5719c6ba (patch) | |
| tree | 33f287f2de470e7fff0b84a64d606311421af536 /src | |
| parent | 094d67ee37d37caa2ebd755fa39ebcaa7b586b26 (diff) | |
| download | rust-e5d291afbfd253cdca60bcf83f2afb2b5719c6ba.tar.gz rust-e5d291afbfd253cdca60bcf83f2afb2b5719c6ba.zip | |
mir-borrowck: Use bool for autoderef in append_lvalue_to_string()
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/borrow_check.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/librustc_mir/borrow_check.rs b/src/librustc_mir/borrow_check.rs index 486f95f68ea..b1fa9ba4848 100644 --- a/src/librustc_mir/borrow_check.rs +++ b/src/librustc_mir/borrow_check.rs @@ -1577,7 +1577,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // End-user visible description of `lvalue` fn describe_lvalue(&self, lvalue: &Lvalue<'tcx>) -> String { let mut buf = String::new(); - self.append_lvalue_to_string(lvalue, &mut buf, None); + self.append_lvalue_to_string(lvalue, &mut buf, false); buf } @@ -1585,7 +1585,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { fn append_lvalue_to_string(&self, lvalue: &Lvalue<'tcx>, buf: &mut String, - autoderef: Option<bool>) { + mut autoderef: bool) { match *lvalue { Lvalue::Local(local) => { self.append_local_to_string(local, buf, "_"); @@ -1594,19 +1594,17 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { buf.push_str(&format!("{}", &self.tcx.item_name(static_.def_id))); } Lvalue::Projection(ref proj) => { - let mut autoderef = autoderef.unwrap_or(false); - match proj.elem { ProjectionElem::Deref => { if autoderef { - self.append_lvalue_to_string(&proj.base, buf, Some(autoderef)); + self.append_lvalue_to_string(&proj.base, buf, autoderef); } else { buf.push_str(&"*"); - self.append_lvalue_to_string(&proj.base, buf, Some(autoderef)); + self.append_lvalue_to_string(&proj.base, buf, autoderef); } }, ProjectionElem::Downcast(..) => { - self.append_lvalue_to_string(&proj.base, buf, Some(autoderef)); + self.append_lvalue_to_string(&proj.base, buf, autoderef); }, ProjectionElem::Field(field, _ty) => { autoderef = true; @@ -1617,14 +1615,14 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { if is_projection_from_ty_closure { buf.push_str(&format!("{}", field_name)); } else { - self.append_lvalue_to_string(&proj.base, buf, Some(autoderef)); + self.append_lvalue_to_string(&proj.base, buf, autoderef); buf.push_str(&format!(".{}", field_name)); } }, ProjectionElem::Index(index) => { autoderef = true; - self.append_lvalue_to_string(&proj.base, buf, Some(autoderef)); + self.append_lvalue_to_string(&proj.base, buf, autoderef); buf.push_str("["); self.append_local_to_string(index, buf, ".."); buf.push_str("]"); @@ -1634,7 +1632,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // Since it isn't possible to borrow an element on a particular index and // then use another while the borrow is held, don't output indices details // to avoid confusing the end-user - self.append_lvalue_to_string(&proj.base, buf, Some(autoderef)); + self.append_lvalue_to_string(&proj.base, buf, autoderef); buf.push_str(&"[..]"); }, }; |
