Skip to content

Commit 36c9045

Browse files
committed
Add debug asserts in thread local cell set methods.
1 parent 93c409d commit 36c9045

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

library/std/src/thread/local.rs

+4
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ macro_rules! __thread_local_inner {
268268
if let $crate::option::Option::Some(init) = _init {
269269
if let $crate::option::Option::Some(value) = init.take() {
270270
return value;
271+
} else if $crate::cfg!(debug_assertions) {
272+
unreachable!("missing initial value");
271273
}
272274
}
273275
__init()
@@ -341,6 +343,8 @@ macro_rules! __thread_local_inner {
341343
if let $crate::option::Option::Some(init) = init {
342344
if let $crate::option::Option::Some(value) = init.take() {
343345
return value;
346+
} else if $crate::cfg!(debug_assertions) {
347+
unreachable!("missing default value");
344348
}
345349
}
346350
__init()

0 commit comments

Comments
 (0)