diff --git a/src/offset_of.rs b/src/offset_of.rs index 98e7644..a1300af 100644 --- a/src/offset_of.rs +++ b/src/offset_of.rs @@ -26,6 +26,10 @@ macro_rules! let_base_ptr { ($name:ident, $type:tt) => { // No UB here, and the pointer does not dangle, either. + // But we have to make sure that `uninit` lives long enough, + // so it has to be in the same scope as `$name`. That's why + // `let_base_ptr` declares a variable (several, actually) + // instad of returning one. let uninit = $crate::mem::MaybeUninit::<$type>::uninit(); let $name = uninit.as_ptr(); };