Open
Description
The following code:
#![feature(custom_test_frameworks)]
#![test_runner(my_test_runner)]
fn my_test_runner(tests: &[&fn() -> ()]) {
for test in tests {
test();
}
}
#[test_case]
fn test_1() {}
#[test_case]
fn test_2() {}
results in
11 | fn test_1() {}
| ^^^^^^^^^^^^^^ expected fn pointer, found fn item
|
= note: expected type `&fn()`
found type `&fn() {test_1}`
The workaround mentioned in https://stackoverflow.com/questions/27895946/expected-fn-item-found-a-different-fn-item-when-working-with-function-pointer doesn't work, as these functions are passed in by the compiler, so we cannot do the coercion.
Other variants that don't work:
fn my_test_runner(tests: &[fn() -> ()]) {
fn my_test_runner<F: Fn() -> ()>(tests: &[F]) {
fn my_test_runner<F: Fn() -> ()>(tests: &[&F]) {
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status