Unnamed repository; edit this file 'description' to name the repository.
| -rw-r--r-- | crates/hir-ty/src/infer/closure.rs | 4 | ||||
| -rw-r--r-- | crates/ide/src/hover/tests.rs | 27 |
2 files changed, 29 insertions, 2 deletions
diff --git a/crates/hir-ty/src/infer/closure.rs b/crates/hir-ty/src/infer/closure.rs index c3918286f4..a7d9246b7c 100644 --- a/crates/hir-ty/src/infer/closure.rs +++ b/crates/hir-ty/src/infer/closure.rs @@ -710,14 +710,14 @@ impl InferenceContext<'_> { false } - fn is_ty_copy(&self, ty: Ty) -> bool { + fn is_ty_copy(&mut self, ty: Ty) -> bool { if let TyKind::Closure(id, _) = ty.kind(Interner) { // FIXME: We handle closure as a special case, since chalk consider every closure as copy. We // should probably let chalk know which closures are copy, but I don't know how doing it // without creating query cycles. return self.result.closure_info.get(id).map(|x| x.1 == FnTrait::Fn).unwrap_or(true); } - ty.is_copy(self.db, self.owner) + self.table.resolve_completely(ty).is_copy(self.db, self.owner) } fn select_from_expr(&mut self, expr: ExprId) { diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs index 60708cb42e..ca6c169348 100644 --- a/crates/ide/src/hover/tests.rs +++ b/crates/ide/src/hover/tests.rs @@ -301,6 +301,33 @@ fn main() { * `(*x.f2.0.0).f` by mutable borrow "#]], ); + check( + r#" +//- minicore: copy, option + +fn do_char(c: char) {} + +fn main() { + let x = None; + let y = |$0| { + match x { + Some(c) => do_char(c), + None => x = None, + } + }; +} +"#, + expect![[r#" + *|* + ```rust + {closure#0} // size = 8, align = 8 + impl FnMut() + ``` + + ## Captures + * `x` by mutable borrow + "#]], + ); } #[test] |