1
Fork 0

random::<Improve<Mutability>>()

This commit is contained in:
Maybe Waffle 2022-11-23 19:15:23 +00:00
parent 4439f1f6a6
commit 6486ba94a3
2 changed files with 2 additions and 5 deletions

View file

@ -130,10 +130,7 @@ impl hir::Pat<'_> {
pub fn contains_explicit_ref_binding(&self) -> Option<hir::Mutability> { pub fn contains_explicit_ref_binding(&self) -> Option<hir::Mutability> {
let mut result = None; let mut result = None;
self.each_binding(|annotation, _, _, _| match annotation { self.each_binding(|annotation, _, _, _| match annotation {
hir::BindingAnnotation::REF => match result { hir::BindingAnnotation::REF if result.is_none() => result = Some(hir::Mutability::Not),
None | Some(hir::Mutability::Not) => result = Some(hir::Mutability::Not),
_ => {}
},
hir::BindingAnnotation::REF_MUT => result = Some(hir::Mutability::Mut), hir::BindingAnnotation::REF_MUT => result = Some(hir::Mutability::Mut),
_ => {} _ => {}
}); });

View file

@ -749,7 +749,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
format!("to take parameter `{binding}` by reference, move `&{mutability}` to the type"), format!("to take parameter `{binding}` by reference, move `&{mutability}` to the type"),
vec![ vec![
(pat.span.until(inner.span), "".to_owned()), (pat.span.until(inner.span), "".to_owned()),
(ty_span.shrink_to_lo(), format!("&{}", mutbl.prefix_str())), (ty_span.shrink_to_lo(), mutbl.ref_prefix_str().to_owned()),
], ],
Applicability::MachineApplicable Applicability::MachineApplicable
); );