-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
const_fn_trait_ref_impl
, add test for it
- Loading branch information
1 parent
391ba78
commit 0c9896b
Showing
2 changed files
with
50 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |