-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-libtestArea: `#[test]` / the `test` libraryArea: `#[test]` / the `test` libraryC-bugCategory: This is a bug.Category: This is a bug.F-custom_test_frameworks`#![feature(custom_test_frameworks)]``#![feature(custom_test_frameworks)]`requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
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
A-libtestArea: `#[test]` / the `test` libraryArea: `#[test]` / the `test` libraryC-bugCategory: This is a bug.Category: This is a bug.F-custom_test_frameworks`#![feature(custom_test_frameworks)]``#![feature(custom_test_frameworks)]`requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
Type
Projects
Status
No status