Skip to content

Commit 340e590

Browse files
committed
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: explicit panic To something like this: thread '<unnamed>' (0xff9bf) panicked at src/main.rs:3:5: explicit panic Stack overflow messages are updated as well. This change applies to both named and unnamed threads. The ID printed is the OS integer thread ID rather than the Rust thread ID, which should also be what debuggers print.
1 parent a1cfe86 commit 340e590

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tests/rustfmt/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,11 @@ fn dont_emit_ICE() {
185185
"tests/target/issue-6105.rs",
186186
];
187187

188+
let panic_re = regex::Regex::new("thread.*panicked").unwrap();
188189
for file in files {
189190
let args = [file];
190191
let (_stdout, stderr) = rustfmt(&args);
191-
assert!(!stderr.contains("thread 'main' panicked"));
192+
assert!(!panic_re.is_match(&stderr));
192193
}
193194
}
194195

0 commit comments

Comments
 (0)