about summary refs log tree commit diff
diff options
context:
space:
mode:
authorShoyu Vanilla <modulo641@gmail.com>2024-02-22 00:43:50 +0900
committerShoyu Vanilla <modulo641@gmail.com>2024-02-27 00:15:25 +0900
commit763714145a867f520d76eb64d7c80afdf0112b49 (patch)
tree645703303b96fea752bcbc7039380473761f84c1
parent96505787b40d2cb2288f7da56b511e99eb272cf4 (diff)
downloadrust-763714145a867f520d76eb64d7c80afdf0112b49.tar.gz
rust-763714145a867f520d76eb64d7c80afdf0112b49.zip
Add a new failing test
-rw-r--r--crates/hir-ty/src/tests/simple.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/crates/hir-ty/src/tests/simple.rs b/crates/hir-ty/src/tests/simple.rs
index 6c7dbe1db6f..b272c2c28bb 100644
--- a/crates/hir-ty/src/tests/simple.rs
+++ b/crates/hir-ty/src/tests/simple.rs
@@ -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#"