aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/tests')
-rw-r--r--crates/hir_ty/src/tests/traits.rs26
1 files changed, 24 insertions, 2 deletions
diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs
index 71905baeb..6cd8786ea 100644
--- a/crates/hir_ty/src/tests/traits.rs
+++ b/crates/hir_ty/src/tests/traits.rs
@@ -3078,7 +3078,7 @@ fn infer_fn_trait_arg() {
3078 3078
3079#[test] 3079#[test]
3080fn infer_box_fn_arg() { 3080fn infer_box_fn_arg() {
3081 // The type mismatch is a bug 3081 // The type mismatch is because we don't define Unsize and CoerceUnsized
3082 check_infer_with_mismatches( 3082 check_infer_with_mismatches(
3083 r#" 3083 r#"
3084//- /lib.rs deps:std 3084//- /lib.rs deps:std
@@ -3138,7 +3138,7 @@ fn foo() {
3138 555..557 'ps': {unknown} 3138 555..557 'ps': {unknown}
3139 559..561 '{}': () 3139 559..561 '{}': ()
3140 568..569 'f': Box<dyn FnOnce(&Option<i32>)> 3140 568..569 'f': Box<dyn FnOnce(&Option<i32>)>
3141 568..573 'f(&s)': FnOnce::Output<dyn FnOnce(&Option<i32>), (&Option<i32>,)> 3141 568..573 'f(&s)': ()
3142 570..572 '&s': &Option<i32> 3142 570..572 '&s': &Option<i32>
3143 571..572 's': Option<i32> 3143 571..572 's': Option<i32>
3144 549..562: expected Box<dyn FnOnce(&Option<i32>)>, got Box<|{unknown}| -> ()> 3144 549..562: expected Box<dyn FnOnce(&Option<i32>)>, got Box<|{unknown}| -> ()>
@@ -3608,3 +3608,25 @@ fn main() {
3608 "#]], 3608 "#]],
3609 ) 3609 )
3610} 3610}
3611
3612#[test]
3613fn fn_returning_unit() {
3614 check_infer_with_mismatches(
3615 r#"
3616#[lang = "fn_once"]
3617trait FnOnce<Args> {
3618 type Output;
3619}
3620
3621fn test<F: FnOnce()>(f: F) {
3622 let _: () = f();
3623}"#,
3624 expect![[r#"
3625 82..83 'f': F
3626 88..112 '{ ...f(); }': ()
3627 98..99 '_': ()
3628 106..107 'f': F
3629 106..109 'f()': ()
3630 "#]],
3631 );
3632}