or-patterns: remove Arm::contains_explicit_ref_binding.

This commit is contained in:
Mazdak Farrokhzad 2019-09-15 04:07:56 +02:00
parent 9ca42a5600
commit 57eeb61cc8
2 changed files with 5 additions and 22 deletions

View File

@ -189,20 +189,3 @@ pub fn contains_explicit_ref_binding(&self) -> Option<hir::Mutability> {
result
}
}
impl hir::Arm {
/// Checks if the patterns for this arm contain any `ref` or `ref mut`
/// bindings, and if yes whether its containing mutable ones or just immutables ones.
pub fn contains_explicit_ref_binding(&self) -> Option<hir::Mutability> {
// FIXME(tschottdorf): contains_explicit_ref_binding() must be removed
// for #42640 (default match binding modes).
//
// See #44848.
self.top_pats_hack().iter()
.filter_map(|pat| pat.contains_explicit_ref_binding())
.max_by_key(|m| match *m {
hir::MutMutable => 1,
hir::MutImmutable => 0,
})
}
}

View File

@ -411,11 +411,11 @@ fn demand_discriminant_type(
//
// See #44848.
let contains_ref_bindings = arms.iter()
.filter_map(|a| a.contains_explicit_ref_binding())
.max_by_key(|m| match *m {
hir::MutMutable => 1,
hir::MutImmutable => 0,
});
.filter_map(|a| a.pat.contains_explicit_ref_binding())
.max_by_key(|m| match *m {
hir::MutMutable => 1,
hir::MutImmutable => 0,
});
if let Some(m) = contains_ref_bindings {
self.check_expr_with_needs(discrim, Needs::maybe_mut_place(m))