Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/tests/simple.rs')
-rw-r--r--crates/hir-ty/src/tests/simple.rs41
1 files changed, 39 insertions, 2 deletions
diff --git a/crates/hir-ty/src/tests/simple.rs b/crates/hir-ty/src/tests/simple.rs
index 6c7dbe1db6..ffd6a6051b 100644
--- a/crates/hir-ty/src/tests/simple.rs
+++ b/crates/hir-ty/src/tests/simple.rs
@@ -2190,9 +2190,9 @@ fn main() {
149..151 'Ok': extern "rust-call" Ok<(), ()>(()) -> Result<(), ()>
149..155 'Ok(())': Result<(), ()>
152..154 '()': ()
- 167..171 'test': fn test<(), (), impl Fn() -> impl Future<Output = Result<(), ()>>, impl Future<Output = Result<(), ()>>>(impl Fn() -> impl Future<Output = Result<(), ()>>)
+ 167..171 'test': fn test<(), (), impl FnMut() -> impl Future<Output = Result<(), ()>>, impl Future<Output = Result<(), ()>>>(impl FnMut() -> impl Future<Output = Result<(), ()>>)
167..228 'test(|... })': ()
- 172..227 '|| asy... }': impl Fn() -> impl Future<Output = Result<(), ()>>
+ 172..227 '|| asy... }': impl FnMut() -> impl Future<Output = Result<(), ()>>
175..227 'async ... }': impl Future<Output = Result<(), ()>>
191..205 'return Err(())': !
198..201 'Err': extern "rust-call" Err<(), ()>(()) -> Result<(), ()>
@@ -2887,6 +2887,43 @@ fn f() {
}
#[test]
+fn closure_kind_with_predicates() {
+ check_types(
+ r#"
+//- minicore: fn
+#![feature(unboxed_closures)]
+
+struct X<T: FnOnce()>(T);
+
+fn f1() -> impl FnOnce() {
+ || {}
+ // ^^^^^ impl FnOnce()
+}
+
+fn f2(c: impl FnOnce<(), Output = i32>) {}
+
+fn test {
+ let x1 = X(|| {});
+ let c1 = x1.0;
+ // ^^ impl FnOnce()
+
+ let c2 = || {};
+ // ^^ impl Fn()
+ let x2 = X(c2);
+ let c3 = x2.0
+ // ^^ impl Fn()
+
+ let c4 = f1();
+ // ^^ impl FnOnce() + ?Sized
+
+ f2(|| { 0 });
+ // ^^^^^^^^ impl FnOnce() -> i32
+}
+ "#,
+ )
+}
+
+#[test]
fn derive_macro_should_work_for_associated_type() {
check_types(
r#"