Skip to content

Commit

Permalink
Remove unstable_offset_of
Browse files Browse the repository at this point in the history
  • Loading branch information
coolreader18 committed Mar 26, 2024
1 parent e646678 commit 638ee9c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 33 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## Unreleased
- Clarify documentation about macro indirection
- Added changelog
- Turn the crate into a thin stdlib wrapper on rustc>=1.77
- Remove `unstable_offset_of`

## v0.9.0 (18/05/2023)
### Added
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ doc-comment = "0.3"
[features]
default = []
unstable_const = []
unstable_offset_of = []
4 changes: 0 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@
feature(const_ptr_offset_from)
)]
#![cfg_attr(feature = "unstable_const", feature(const_refs_to_cell))]
#![cfg_attr(
all(feature = "unstable_offset_of", not(stable_offset_of)),
feature(allow_internal_unstable)
)]

#[macro_use]
#[cfg(doctests)]
Expand Down
36 changes: 8 additions & 28 deletions src/offset_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ macro_rules! _memoffset_offset_from_unsafe {
($field as usize) - ($base as usize)
};
}
#[cfg(not(any(feature = "unstable_offset_of", stable_offset_of)))]
#[cfg(not(stable_offset_of))]
#[macro_export(local_inner_macros)]
#[doc(hidden)]
macro_rules! _memoffset__offset_of_impl {
Expand All @@ -80,13 +80,9 @@ macro_rules! _memoffset__offset_of_impl {
_memoffset_offset_from_unsafe!(field_ptr, base_ptr)
}};
}
#[cfg(any(feature = "unstable_offset_of", stable_offset_of))]
#[cfg(stable_offset_of)]
#[macro_export]
#[doc(hidden)]
#[cfg_attr(
all(feature = "unstable_offset_of", not(stable_offset_of)),
allow_internal_unstable(offset_of)
)]
macro_rules! _memoffset__offset_of_impl {
($parent:path, $field:tt) => {{
$crate::__priv::mem::offset_of!($parent, $field)
Expand Down Expand Up @@ -129,7 +125,7 @@ macro_rules! offset_of {
}

#[cfg(tuple_ty)]
#[cfg(not(any(feature = "unstable_offset_of", stable_offset_of)))]
#[cfg(not(stable_offset_of))]
#[macro_export(local_inner_macros)]
#[doc(hidden)]
macro_rules! _memoffset__offset_of_tuple_impl {
Expand All @@ -144,13 +140,9 @@ macro_rules! _memoffset__offset_of_tuple_impl {
}

#[cfg(tuple_ty)]
#[cfg(any(feature = "unstable_offset_of", stable_offset_of))]
#[cfg(stable_offset_of)]
#[macro_export(local_inner_macros)]
#[doc(hidden)]
#[cfg_attr(
all(feature = "unstable_offset_of", not(stable_offset_of)),
allow_internal_unstable(offset_of)
)]
macro_rules! _memoffset__offset_of_tuple_impl {
($parent:ty, $field:tt) => {{
$crate::__priv::mem::offset_of!($parent, $field)
Expand All @@ -175,7 +167,7 @@ macro_rules! offset_of_tuple {
}};
}

#[cfg(not(any(feature = "unstable_offset_of", stable_offset_of)))]
#[cfg(not(stable_offset_of))]
#[macro_export(local_inner_macros)]
#[doc(hidden)]
macro_rules! _memoffset__offset_of_union_impl {
Expand All @@ -189,13 +181,9 @@ macro_rules! _memoffset__offset_of_union_impl {
}};
}

#[cfg(any(feature = "unstable_offset_of", stable_offset_of))]
#[cfg(stable_offset_of)]
#[macro_export(local_inner_macros)]
#[doc(hidden)]
#[cfg_attr(
all(feature = "unstable_offset_of", not(stable_offset_of)),
allow_internal_unstable(offset_of)
)]
macro_rules! _memoffset__offset_of_union_impl {
($parent:path, $field:tt) => {{
$crate::__priv::mem::offset_of!($parent, $field)
Expand Down Expand Up @@ -380,11 +368,7 @@ mod tests {
assert_eq!(f_ptr as usize + 0, raw_field_union!(f_ptr, Foo, c) as usize);
}

#[cfg(any(
feature = "unstable_const",
any(feature = "unstable_offset_of", stable_offset_of),
stable_const
))]
#[cfg(any(feature = "unstable_const", stable_offset_of, stable_const))]
#[test]
fn const_offset() {
#[repr(C)]
Expand All @@ -409,11 +393,7 @@ mod tests {
assert_eq!([0; offset_of!(Foo, b)].len(), 4);
}

#[cfg(any(
feature = "unstable_const",
any(feature = "unstable_offset_of", stable_offset_of),
stable_const
))]
#[cfg(any(feature = "unstable_const", stable_offset_of, stable_const))]
#[test]
fn const_fn_offset() {
const fn test_fn() -> usize {
Expand Down

0 comments on commit 638ee9c

Please sign in to comment.