Closed
Description
error[E0282]: type annotations needed for `std::result::Result<(), E>`
--> sysroot_src/src/libtest/lib.rs:1627:42
|
16| let result = Ok(testfn());
| ------ consider giving `result` the explicit type `std::result::Result<(), E>`, with the type parameters specified
...
16| Err(e) => calc_result(&desc, Err(e.as_ref())),
| ^ cannot infer type
|
= note: type must be known at this point
Compare sysroot_src/src/libtest/lib.rs:1627:42
with 16| let result = Ok(testfn());
.
$ rustc -V
rustc 1.40.0-nightly (2daa404e9 2019-10-02)
$ git diff
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
index 8b76080..7d57460 100644
--- a/src/libtest/lib.rs
+++ b/src/libtest/lib.rs
@@ -1493,7 +1493,7 @@ pub fn run_test(
report_time: bool,
strategy: RunStrategy,
monitor_ch: Sender<MonitorMsg>,
- testfn: Box<dyn FnOnce() + Send>,
+ testfn: Box<impl FnOnce() + Send + 'static>,
concurrency: Concurrent,
) {
let name = desc.name.clone();
@@ -1509,7 +1509,7 @@ pub fn run_test(
// If the platform is single-threaded we're just going to run
// the test synchronously, regardless of the concurrency
// level.
- let supports_threads = !cfg!(target_os = "emscripten") && !cfg!(target_arch = "wasm32");
+ let supports_threads = false;
if concurrency == Concurrent::Yes && supports_threads {
let cfg = thread::Builder::new().name(name.as_slice().to_owned());
cfg.spawn(runtest).unwrap();
@@ -1531,20 +1531,8 @@ pub fn run_test(
(benchfn.clone())(harness)
});
}
- DynTestFn(f) => {
- match strategy {
- RunStrategy::InProcess => (),
- _ => panic!("Cannot run dynamic test fn out-of-process"),
- };
- run_test_inner(
- desc,
- opts.nocapture,
- opts.report_time,
- strategy,
- monitor_ch,
- Box::new(move || __rust_begin_short_backtrace(f)),
- concurrency
- );
+ DynTestFn(_f) => {
+ unimplemented!();
}
StaticTestFn(f) => run_test_inner(
desc,
@@ -1623,7 +1611,7 @@ fn run_test_in_process(desc: TestDesc,
} else {
None
};
- let result = catch_unwind(AssertUnwindSafe(testfn));
+ let result = Ok(testfn());
let exec_time = start.map(|start| {
let duration = start.elapsed();
TestExecTime(duration)