Skip to content

Commit fba954b

Browse files
authored
Rollup merge of #44651 - bluss:document-thread-name-no-nuls, r=steveklabnik
Document thread builder panics for nul bytes in thread names This seems to have been undocumented. Mention this where the name is set (Builder::name) and where the panic could happen (Builder::spawn). Thread::new is private and I think the builder is the only user where this matters. A short comment was added to "document" Thread::new too.
2 parents 054a46e + 7859c9e commit fba954b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/libstd/thread/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ impl Builder {
287287
/// Names the thread-to-be. Currently the name is used for identification
288288
/// only in panic messages.
289289
///
290+
/// The name must not contain null bytes (`\0`).
291+
///
290292
/// For more information about named threads, see
291293
/// [this module-level documentation][naming-threads].
292294
///
@@ -355,6 +357,10 @@ impl Builder {
355357
/// [`io::Result`]: ../../std/io/type.Result.html
356358
/// [`JoinHandle`]: ../../std/thread/struct.JoinHandle.html
357359
///
360+
/// # Panics
361+
///
362+
/// Panics if a thread name was set and it contained null bytes.
363+
///
358364
/// # Examples
359365
///
360366
/// ```
@@ -941,6 +947,7 @@ pub struct Thread {
941947

942948
impl Thread {
943949
// Used only internally to construct a thread object without spawning
950+
// Panics if the name contains nuls.
944951
pub(crate) fn new(name: Option<String>) -> Thread {
945952
let cname = name.map(|n| {
946953
CString::new(n).expect("thread name may not contain interior null bytes")

0 commit comments

Comments
 (0)