summaryrefslogtreecommitdiffstats
path: root/vendor/memoffset
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/memoffset')
-rw-r--r--vendor/memoffset/.cargo-checksum.json2
-rw-r--r--vendor/memoffset/Cargo.toml2
-rw-r--r--vendor/memoffset/README.md32
-rw-r--r--vendor/memoffset/build.rs3
-rw-r--r--vendor/memoffset/src/lib.rs5
-rw-r--r--vendor/memoffset/src/offset_of.rs8
6 files changed, 38 insertions, 14 deletions
diff --git a/vendor/memoffset/.cargo-checksum.json b/vendor/memoffset/.cargo-checksum.json
index 60f2c0932..c8b72f989 100644
--- a/vendor/memoffset/.cargo-checksum.json
+++ b/vendor/memoffset/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"2122b76e5dff09497c7edf7f184155e456e44209c05e4f8abb01632be7241b56","LICENSE":"3234ac55816264ee7b6c7ee27efd61cf0a1fe775806870e3d9b4c41ea73c5cb1","README.md":"7a7935d96a1a40b56afeadca391c742f7ac3a6e0f1deab1d43430553f71b6d23","build.rs":"6d677e33a1c98d588c97ec7985d4d5c3b954683e0a73c3dc53d79db4fbb5e638","src/lib.rs":"e7976d295371a3c1e0cf31b0d50210cd6b1135caba3a5111403a97ec6175c0a2","src/offset_of.rs":"ea04e76e3ab1fa192618fffb0c6a047795c275f1deaf6c6617245badaba8660c","src/raw_field.rs":"ef54087d5f507c2b639a4f61f2881eb1e41a46e22191ffd0e23b2fe9e3f17c25","src/span_of.rs":"b900faef2b852b52c37c55a172c05c9144bfff7d84dbc06e943fb0453d68adfc"},"package":"5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4"} \ No newline at end of file
+{"files":{"Cargo.toml":"d1193e8d228ceb5aa5792b8170c0cec8802489d66eb590bae693ae0a009c3bb9","LICENSE":"3234ac55816264ee7b6c7ee27efd61cf0a1fe775806870e3d9b4c41ea73c5cb1","README.md":"a673f0b4b5ac46034590a670572bd1a87837fdedb5170dabbea08d392e6cfa4b","build.rs":"df34c830dbb08eba3474304eed481bc2c8a29e897bc50f46d37b5dbb6e443a2b","src/lib.rs":"cc7f53556da6f53e5818e31330b488ad0de8d58096edf05f9f27e7f1159d1bfe","src/offset_of.rs":"9a2f9e8a7739a615df214738302bb74df584a53485a7f3536c0aca17ce936db3","src/raw_field.rs":"ef54087d5f507c2b639a4f61f2881eb1e41a46e22191ffd0e23b2fe9e3f17c25","src/span_of.rs":"b900faef2b852b52c37c55a172c05c9144bfff7d84dbc06e943fb0453d68adfc"},"package":"d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1"} \ No newline at end of file
diff --git a/vendor/memoffset/Cargo.toml b/vendor/memoffset/Cargo.toml
index 1677446a8..5d71c6496 100644
--- a/vendor/memoffset/Cargo.toml
+++ b/vendor/memoffset/Cargo.toml
@@ -11,7 +11,7 @@
[package]
name = "memoffset"
-version = "0.7.1"
+version = "0.8.0"
authors = ["Gilad Naaman <gilad.naaman@gmail.com>"]
description = "offset_of functionality for Rust structs."
readme = "README.md"
diff --git a/vendor/memoffset/README.md b/vendor/memoffset/README.md
index e297b33d5..b0bfd1014 100644
--- a/vendor/memoffset/README.md
+++ b/vendor/memoffset/README.md
@@ -7,6 +7,7 @@ C-Like `offset_of` functionality for Rust structs.
Introduces the following macros:
* `offset_of!` for obtaining the offset of a member of a struct.
* `offset_of_tuple!` for obtaining the offset of a member of a tuple. (Requires Rust 1.20+)
+ * `offset_of_union!` for obtaining the offset of a member of a union.
* `span_of!` for obtaining the range that a field, or fields, span.
`memoffset` works under `no_std` environments.
@@ -16,7 +17,7 @@ Add the following dependency to your `Cargo.toml`:
```toml
[dependencies]
-memoffset = "0.7"
+memoffset = "0.8"
```
These versions will compile fine with rustc versions greater or equal to 1.19.
@@ -45,21 +46,40 @@ fn main() {
}
```
-## Feature flags ##
+## Usage in constants ##
+`memoffset` has support for compile-time `offset_of!` on rust>=1.65, or on older nightly compilers.
-### Usage in constants ###
-`memoffset` has **experimental** support for compile-time `offset_of!` on a nightly compiler.
+### Usage on stable Rust ###
+Constant evaluation is automatically enabled and avilable on stable compilers starting with rustc 1.65.
-In order to use it, you must enable the `unstable_const` crate feature and several compiler features.
+This is an incomplete implementation with one caveat:
+Due to dependence on [`#![feature(const_refs_to_cell)]`](https://github.com/rust-lang/rust/issues/80384), you cannot get the offset of a `Cell` field in a const-context.
+
+This means that if need to get the offset of a cell, you'll have to remain on nightly for now.
+
+### Usage on recent nightlies ###
+
+If you're using a new-enough nightly and you require the ability to get the offset of a `Cell`,
+you'll have to enable the `unstable_const` cargo feature, as well as enabling `const_refs_to_cell` in your crate root.
+
+Do note that `unstable_const` is an unstable feature that is set to be removed in a future version of `memoffset`.
Cargo.toml:
```toml
[dependencies.memoffset]
-version = "0.7"
+version = "0.8"
features = ["unstable_const"]
```
Your crate root: (`lib.rs`/`main.rs`)
```rust,ignore
+#![feature(const_refs_to_cell)]
+```
+
+### Usage on older nightlies ###
+In order to use it on an older nightly compiler, you must enable the `unstable_const` crate feature and several compiler features.
+
+Your crate root: (`lib.rs`/`main.rs`)
+```rust,ignore
#![feature(const_ptr_offset_from, const_refs_to_cell)]
```
diff --git a/vendor/memoffset/build.rs b/vendor/memoffset/build.rs
index 0604c1954..e18810f89 100644
--- a/vendor/memoffset/build.rs
+++ b/vendor/memoffset/build.rs
@@ -19,4 +19,7 @@ fn main() {
if ac.probe_rustc_version(1, 51) {
println!("cargo:rustc-cfg=raw_ref_macros");
}
+ if ac.probe_rustc_version(1, 65) {
+ println!("cargo:rustc-cfg=stable_const");
+ }
}
diff --git a/vendor/memoffset/src/lib.rs b/vendor/memoffset/src/lib.rs
index d80ff1743..72736aa09 100644
--- a/vendor/memoffset/src/lib.rs
+++ b/vendor/memoffset/src/lib.rs
@@ -57,9 +57,10 @@
#![no_std]
#![cfg_attr(
- feature = "unstable_const",
- feature(const_ptr_offset_from, const_refs_to_cell)
+ all(feature = "unstable_const", not(stable_const)),
+ feature(const_ptr_offset_from)
)]
+#![cfg_attr(feature = "unstable_const", feature(const_refs_to_cell))]
#[macro_use]
#[cfg(doctests)]
diff --git a/vendor/memoffset/src/offset_of.rs b/vendor/memoffset/src/offset_of.rs
index d070181ce..9ce4ae200 100644
--- a/vendor/memoffset/src/offset_of.rs
+++ b/vendor/memoffset/src/offset_of.rs
@@ -46,7 +46,7 @@ macro_rules! _memoffset__let_base_ptr {
}
/// Macro to compute the distance between two pointers.
-#[cfg(feature = "unstable_const")]
+#[cfg(any(feature = "unstable_const", stable_const))]
#[macro_export]
#[doc(hidden)]
macro_rules! _memoffset_offset_from_unsafe {
@@ -58,7 +58,7 @@ macro_rules! _memoffset_offset_from_unsafe {
unsafe { (field as *const u8).offset_from(base as *const u8) as usize }
}};
}
-#[cfg(not(feature = "unstable_const"))]
+#[cfg(not(any(feature = "unstable_const", stable_const)))]
#[macro_export]
#[doc(hidden)]
macro_rules! _memoffset_offset_from_unsafe {
@@ -312,7 +312,7 @@ mod tests {
assert_eq!(f_ptr as usize + 0, raw_field_union!(f_ptr, Foo, c) as usize);
}
- #[cfg(feature = "unstable_const")]
+ #[cfg(any(feature = "unstable_const", stable_const))]
#[test]
fn const_offset() {
#[repr(C)]
@@ -337,7 +337,7 @@ mod tests {
assert_eq!([0; offset_of!(Foo, b)].len(), 4);
}
- #[cfg(feature = "unstable_const")]
+ #[cfg(any(feature = "unstable_const", stable_const))]
#[test]
fn const_fn_offset() {
const fn test_fn() -> usize {