-
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.
Print thread ID in panic message if thread name is unknown
`panic!` does not print any identifying information for threads that are unnamed. However, in many cases, the thread ID can be determined. This changes the panic message from something like this: thread '<unnamed>' panicked at src/main.rs:3:5: message To something like this: thread '<unnamed>' (id 2) panicked at src/main.rs:3:5: message There is no change in output for named threads or for threads where an ID cannot be determined.
- Loading branch information
Showing
4 changed files
with
20 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 |
---|---|---|
@@ -1,14 +1,16 @@ | ||
// Test panic error messages for unnamed threads | ||
|
||
// run-fail | ||
// error-pattern:thread '<unnamed>' panicked | ||
// regex-error-pattern:thread '<unnamed>' \(id \d+\) panicked | ||
// error-pattern:test | ||
// ignore-emscripten Needs threads | ||
|
||
use std::thread; | ||
|
||
fn main() { | ||
let r: Result<(), _> = thread::spawn(move || { | ||
panic!("test"); | ||
}) | ||
.join(); | ||
assert!(r.is_ok()); | ||
let _: () = thread::spawn(move || { | ||
panic!("test"); | ||
}) | ||
.join() | ||
.unwrap(); | ||
} |
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