no need to use NonNull

This commit is contained in:
Ralf Jung
2019-08-10 11:43:24 +02:00
parent b7e2959e55
commit f734f5bbad
3 changed files with 5 additions and 6 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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.
+3 -4
View File
@@ -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;
};
}