Make Thread::new_inner a safe function · model-checking/verify-rust-std@16bce8a (original) (raw)

`@@ -1337,21 +1337,19 @@ pub struct Thread {

`

1337

1337

`impl Thread {

`

1338

1338

`/// Used only internally to construct a thread object without spawning.

`

1339

1339

`pub(crate) fn new(name: ThreadNameString) -> Thread {

`

1340

``

`-

unsafe { Self::new_inner(ThreadName::Other(name)) }

`

``

1340

`+

Self::new_inner(ThreadName::Other(name))

`

1341

1341

`}

`

1342

1342

``

1343

1343

`pub(crate) fn new_unnamed() -> Thread {

`

1344

``

`-

unsafe { Self::new_inner(ThreadName::Unnamed) }

`

``

1344

`+

Self::new_inner(ThreadName::Unnamed)

`

1345

1345

`}

`

1346

1346

``

1347

1347

`// Used in runtime to construct main thread

`

1348

1348

`pub(crate) fn new_main() -> Thread {

`

1349

``

`-

unsafe { Self::new_inner(ThreadName::Main) }

`

``

1349

`+

Self::new_inner(ThreadName::Main)

`

1350

1350

`}

`

1351

1351

``

1352

``

`-

/// # Safety

`

1353

``

`` -

/// If name is ThreadName::Other(_), the contained string must be valid UTF-8.

``

1354

``

`-

unsafe fn new_inner(name: ThreadName) -> Thread {

`

``

1352

`+

fn new_inner(name: ThreadName) -> Thread {

`

1355

1353

`` // We have to use unsafe here to construct the Parker in-place,

``

1356

1354

`// which is required for the UNIX implementation.

`

1357

1355

`//

`