Do not recomment cloning explicit &mut
expressions
This commit is contained in:
parent
5a7caa3174
commit
7f7f6792f1
3 changed files with 5 additions and 24 deletions
|
@ -1033,6 +1033,11 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
while let hir::ExprKind::AddrOf(.., inner) | hir::ExprKind::Unary(hir::UnOp::Deref, inner) =
|
||||
&inner_expr.kind
|
||||
{
|
||||
if let hir::ExprKind::AddrOf(_, hir::Mutability::Mut, _) = inner_expr.kind {
|
||||
// We assume that `&mut` refs are desired for their side-effects, so cloning the
|
||||
// value wouldn't do what the user wanted.
|
||||
return;
|
||||
}
|
||||
inner_expr = inner;
|
||||
}
|
||||
if inner_expr.span.lo() != expr.span.lo() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue