Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/method_resolution.rs')
-rw-r--r--crates/hir-ty/src/method_resolution.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/crates/hir-ty/src/method_resolution.rs b/crates/hir-ty/src/method_resolution.rs
index b04029d54b..740b6ddc27 100644
--- a/crates/hir-ty/src/method_resolution.rs
+++ b/crates/hir-ty/src/method_resolution.rs
@@ -954,7 +954,14 @@ fn iterate_method_candidates_with_autoref(
)
};
- iterate_method_candidates_by_receiver(receiver_ty, first_adjustment.clone())?;
+ let mut maybe_reborrowed = first_adjustment.clone();
+ if let Some((_, _, m)) = receiver_ty.value.as_reference() {
+ // Prefer reborrow of references to move
+ maybe_reborrowed.autoref = Some(m);
+ maybe_reborrowed.autoderefs += 1;
+ }
+
+ iterate_method_candidates_by_receiver(receiver_ty, maybe_reborrowed)?;
let refed = Canonical {
value: TyKind::Ref(Mutability::Not, static_lifetime(), receiver_ty.value.clone())