From c6f53aaaa4d640cff809bba11af80051f29c6be5 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 11 Jul 2020 19:55:11 +0200 Subject: Add test for #4281 Fixes #4281. --- crates/ra_hir_ty/src/tests/traits.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'crates') diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs index 511ed8fe3..05a56215f 100644 --- a/crates/ra_hir_ty/src/tests/traits.rs +++ b/crates/ra_hir_ty/src/tests/traits.rs @@ -1991,6 +1991,29 @@ fn test() { ); } +#[test] +fn fn_item_fn_trait() { + check_types( + r#" +//- /main.rs +#[lang = "fn_once"] +trait FnOnce { + type Output; +} + +struct S; + +fn foo() -> S {} + +fn takes_closure U>(f: F) -> U { f() } + +fn test() { + takes_closure(foo); +} //^^^^^^^^^^^^^^^^^^ S +"#, + ); +} + #[test] fn unselected_projection_in_trait_env_1() { check_types( -- cgit v1.2.3