From 0c9896bfaa6c7bfd5d34119b7aecffbcc036b201 Mon Sep 17 00:00:00 2001 From: onestacked Date: Mon, 7 Nov 2022 17:41:58 +0100 Subject: Fix `const_fn_trait_ref_impl`, add test for it --- src/test/ui/consts/fn_trait_refs.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/test/ui/consts/fn_trait_refs.rs (limited to 'src/test') diff --git a/src/test/ui/consts/fn_trait_refs.rs b/src/test/ui/consts/fn_trait_refs.rs new file mode 100644 index 00000000000..57465c55925 --- /dev/null +++ b/src/test/ui/consts/fn_trait_refs.rs @@ -0,0 +1,35 @@ +// run-pass +#![feature(const_fn_trait_ref_impls)] +#![feature(fn_traits)] +#![feature(unboxed_closures)] +#![feature(const_trait_impl)] +#![feature(const_mut_refs)] + +use std::marker::Destruct; + +const fn test(i: i32) -> i32 { + i + 1 +} + +const fn call i32 + ~const Destruct>(mut f: F) -> F::Output { + f(5) +} + +const fn use_fn i32 + ~const Destruct>(mut f: F) -> F::Output { + call(&mut f) +} + +const fn test_fn() {} + +const fn tester(_fn: T) +where + T: ~const Fn() + ~const Destruct, +{ +} + +const fn main() { + tester(test_fn); + let test_ref = &test_fn; + tester(test_ref); + assert!(use_fn(test) == 6); +} -- cgit 1.4.1-3-g733a5