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:
commit
90f21d4377
2 changed files with 38 additions and 0 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue