diff options
| author | joboet <jonasboettiger@icloud.com> | 2023-10-09 15:08:49 +0200 |
|---|---|---|
| committer | joboet <jonasboettiger@icloud.com> | 2023-10-09 15:09:18 +0200 |
| commit | 88efb1bdefc61289ab55e0483e6af36eebf8e8b8 (patch) | |
| tree | 8b35a79cf0ac3202313b29dc6c5bea0087e55b16 | |
| parent | 65c66a15bf99efc75ea855733b94881953a6b9e8 (diff) | |
| download | rust-88efb1bdefc61289ab55e0483e6af36eebf8e8b8.tar.gz rust-88efb1bdefc61289ab55e0483e6af36eebf8e8b8.zip | |
std: explain unconventional choice of let-else binding over while-let loop
| -rw-r--r-- | library/std/src/sys/windows/thread_local_key.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/library/std/src/sys/windows/thread_local_key.rs b/library/std/src/sys/windows/thread_local_key.rs index 831f39817f4..5eee4a9667b 100644 --- a/library/std/src/sys/windows/thread_local_key.rs +++ b/library/std/src/sys/windows/thread_local_key.rs @@ -43,6 +43,9 @@ unsafe fn run_keyless_dtors() { // guarantee that a TLS key cannot be set after it is flagged for // destruction. loop { + // Use a let-else binding to ensure the `RefCell` guard is dropped + // immediately. Otherwise, a panic would occur if a TLS destructor + // tries to access the list. let Some((ptr, dtor)) = DESTRUCTORS.borrow_mut().pop() else { break; }; |
