diff --git a/.travis.yml b/.travis.yml index 17ea05b..943176c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ sudo: false language: rust rust: - - 1.25.0 # Oldest supported (to make doc-comment not ICE) + - 1.20.0 # Oldest supported - 1.36.0 # Oldest supported with MaybeUninit - stable - beta diff --git a/README.md b/README.md index 93a65f3..d51cfd5 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Add the following dependency to your `Cargo.toml`: memoffset = "0.5" ``` -These versions will compile fine with rustc versions greater or equal to 1.25. +These versions will compile fine with rustc versions greater or equal to 1.20. Add the following lines at the top of your `main.rs` or `lib.rs` files. diff --git a/src/offset_of.rs b/src/offset_of.rs index 82a90d2..6b3f2bd 100644 --- a/src/offset_of.rs +++ b/src/offset_of.rs @@ -39,10 +39,9 @@ macro_rules! _memoffset__let_base_ptr { #[doc(hidden)] macro_rules! _memoffset__let_base_ptr { ($name:ident, $type:tt) => { - // No UB right here, but we will later offset into a field - // of this pointer, and that is UB when the pointer is dangling. - let non_null = $crate::ptr::NonNull::<$type>::dangling(); - let $name = non_null.as_ptr() as *const $type; + // No UB right here, but we will later dereference this pointer to + // offset into a field, and that is UB when the pointer is dangling. + let $name = $crate::mem::align_of::<$type>() as *const $type; }; }