Rollup merge of #48448 - nikomatsakis:default-binding-mode-issue-46688, r=cramertj

reset default binding mode when we pass through a `&` pattern

Fixes #46688.

r? @cramertj
This commit is contained in:
Manish Goregaokar 2018-02-24 15:52:14 -08:00 committed by GitHub
commit 90f21d4377
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 0 deletions

View file

@ -151,6 +151,19 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
err.emit();
}
}
} else if let PatKind::Ref(..) = pat.node {
// When you encounter a `&pat` pattern, reset to "by
// value". This is so that `x` and `y` here are by value,
// as they appear to be:
//
// ```
// match &(&22, &44) {
// (&x, &y) => ...
// }
// ```
//
// cc #46688
def_bm = ty::BindByValue(hir::MutImmutable);
}
// Lose mutability now that we know binding mode and discriminant type.