diff options
| author | onestacked <chrisi.schrefl@gmail.com> | 2022-11-07 17:41:58 +0100 |
|---|---|---|
| committer | onestacked <chrisi.schrefl@gmail.com> | 2022-11-07 17:41:58 +0100 |
| commit | 0c9896bfaa6c7bfd5d34119b7aecffbcc036b201 (patch) | |
| tree | 15389963f70e50dfde8f3f6950680cc46bcc66f5 /src/test | |
| parent | 391ba78ab442610a63310b9a3d24646082628081 (diff) | |
| download | rust-0c9896bfaa6c7bfd5d34119b7aecffbcc036b201.tar.gz rust-0c9896bfaa6c7bfd5d34119b7aecffbcc036b201.zip | |
Fix `const_fn_trait_ref_impl`, add test for it
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/consts/fn_trait_refs.rs | 35 |
1 files changed, 35 insertions, 0 deletions
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<F: ~const FnMut(i32) -> i32 + ~const Destruct>(mut f: F) -> F::Output { + f(5) +} + +const fn use_fn<F: ~const FnMut(i32) -> i32 + ~const Destruct>(mut f: F) -> F::Output { + call(&mut f) +} + +const fn test_fn() {} + +const fn tester<T>(_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); +} |
