Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/infer/closure.rs')
-rw-r--r--crates/hir-ty/src/infer/closure.rs20
1 files changed, 4 insertions, 16 deletions
diff --git a/crates/hir-ty/src/infer/closure.rs b/crates/hir-ty/src/infer/closure.rs
index df2ad7af34..6d03c76eb6 100644
--- a/crates/hir-ty/src/infer/closure.rs
+++ b/crates/hir-ty/src/infer/closure.rs
@@ -148,7 +148,7 @@ impl HirPlace {
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
-pub(crate) enum CaptureKind {
+pub enum CaptureKind {
ByRef(BorrowKind),
ByValue,
}
@@ -166,23 +166,11 @@ impl CapturedItem {
self.place.local
}
- pub fn display_kind(&self) -> &'static str {
- match self.kind {
- CaptureKind::ByRef(k) => match k {
- BorrowKind::Shared => "immutable borrow",
- BorrowKind::Shallow => {
- never!("shallow borrow should not happen in closure captures");
- "shallow borrow"
- },
- BorrowKind::Unique => "unique immutable borrow ([read more](https://doc.rust-lang.org/stable/reference/types/closure.html#unique-immutable-borrows-in-captures))",
- BorrowKind::Mut { .. } => "mutable borrow",
- },
- CaptureKind::ByValue => "move",
- }
+ pub fn kind(&self) -> CaptureKind {
+ self.kind
}
- pub fn display_place(&self, owner: ClosureId, db: &dyn HirDatabase) -> String {
- let owner = db.lookup_intern_closure(owner.into()).0;
+ pub fn display_place(&self, owner: DefWithBodyId, db: &dyn HirDatabase) -> String {
let body = db.body(owner);
let mut result = body[self.place.local].name.to_string();
let mut field_need_paren = false;