Rollup merge of #128745 - dtolnay:spawnunchecked, r=workingjubilee

Remove unused lifetime parameter from spawn_unchecked

Amanieu caught this when reviewing the stabilization proposal in https://github.com/rust-lang/rust/issues/55132.

The `'a` lifetime here is useless. The signature is asking the caller of `spawn_unchecked` to "give me any lifetime that is shorter than your F's and T's lifetime", which they can always to with no effect, because arbitrarily short lifetimes exist.
This commit is contained in:
Matthias Krüger 2024-08-13 12:12:23 +02:00 committed by GitHub
commit 37b956787a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 8 deletions

View File

@ -434,25 +434,24 @@ impl Builder {
///
/// [`io::Result`]: crate::io::Result
#[unstable(feature = "thread_spawn_unchecked", issue = "55132")]
pub unsafe fn spawn_unchecked<'a, F, T>(self, f: F) -> io::Result<JoinHandle<T>>
pub unsafe fn spawn_unchecked<F, T>(self, f: F) -> io::Result<JoinHandle<T>>
where
F: FnOnce() -> T,
F: Send + 'a,
T: Send + 'a,
F: Send,
T: Send,
{
Ok(JoinHandle(unsafe { self.spawn_unchecked_(f, None) }?))
}
unsafe fn spawn_unchecked_<'a, 'scope, F, T>(
unsafe fn spawn_unchecked_<'scope, F, T>(
self,
f: F,
scope_data: Option<Arc<scoped::ScopeData>>,
) -> io::Result<JoinInner<'scope, T>>
where
F: FnOnce() -> T,
F: Send + 'a,
T: Send + 'a,
'scope: 'a,
F: Send,
T: Send,
{
let Builder { name, stack_size } = self;
@ -532,7 +531,7 @@ impl Builder {
// will call `decrement_num_running_threads` and therefore signal that this thread is
// done.
drop(their_packet);
// Here, the lifetime `'a` and even `'scope` can end. `main` keeps running for a bit
// Here, the lifetime `'scope` can end. `main` keeps running for a bit
// after that before returning itself.
};