Skip to content

Commit 1605af0

Browse files
committed
libtest: Fix unwrap panic on duplicate TestDesc.
It is possible for different tests to collide to the same TestDesc when macros are involved. That is a bug, but it didn’t cause a panic until rust-lang#81367. For now, change the code to ignore this problem. Fixes rust-lang#81852. Signed-off-by: Anders Kaseorg <[email protected]>
1 parent b05788e commit 1605af0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

library/test/src/lib.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,13 @@ where
353353
}
354354

355355
let mut completed_test = res.unwrap();
356-
let running_test = running_tests.remove(&completed_test.desc).unwrap();
357-
if let Some(join_handle) = running_test.join_handle {
358-
if let Err(_) = join_handle.join() {
359-
if let TrOk = completed_test.result {
360-
completed_test.result =
361-
TrFailedMsg("panicked after reporting success".to_string());
356+
if let Some(running_test) = running_tests.remove(&completed_test.desc) {
357+
if let Some(join_handle) = running_test.join_handle {
358+
if let Err(_) = join_handle.join() {
359+
if let TrOk = completed_test.result {
360+
completed_test.result =
361+
TrFailedMsg("panicked after reporting success".to_string());
362+
}
362363
}
363364
}
364365
}

0 commit comments

Comments
 (0)