File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -2791,6 +2791,23 @@ pub const fn size_of<T>() -> usize;
27912791#[ rustc_intrinsic]
27922792pub const fn align_of < T > ( ) -> usize ;
27932793
2794+ /// The offset of a field inside a type.
2795+ ///
2796+ /// Note that, unlike most intrinsics, this is safe to call;
2797+ /// it does not require an `unsafe` block.
2798+ /// Therefore, implementations must not require the user to uphold
2799+ /// any safety invariants.
2800+ ///
2801+ /// The stabilized version of this intrinsic is [`core::mem::offset_of`].
2802+ #[ rustc_nounwind]
2803+ #[ unstable( feature = "core_intrinsics" , issue = "none" ) ]
2804+ #[ rustc_const_unstable( feature = "core_intrinsics" , issue = "none" ) ]
2805+ #[ rustc_const_stable_indirect]
2806+ #[ rustc_intrinsic_const_stable_indirect]
2807+ #[ rustc_intrinsic]
2808+ #[ lang = "offset_of" ]
2809+ pub const fn offset_of < T : PointeeSized > ( variant : u32 , field : u32 ) -> usize ;
2810+
27942811/// Returns the number of variants of the type `T` cast to a `usize`;
27952812/// if `T` has no variants, returns `0`. Uninhabited variants will be counted.
27962813///
Original file line number Diff line number Diff line change @@ -1424,10 +1424,10 @@ impl<T> SizedTypeProperties for T {}
14241424/// [`offset_of_enum`]: https://doc.rust-lang.org/nightly/unstable-book/language-features/offset-of-enum.html
14251425/// [`offset_of_slice`]: https://doc.rust-lang.org/nightly/unstable-book/language-features/offset-of-slice.html
14261426#[ stable( feature = "offset_of" , since = "1.77.0" ) ]
1427- #[ allow_internal_unstable( builtin_syntax) ]
1427+ #[ allow_internal_unstable( builtin_syntax, core_intrinsics ) ]
14281428pub macro offset_of ( $Container: ty, $( $fields: expr) + $( , ) ?) {
14291429 // The `{}` is for better error messages
1430- { builtin # offset_of ( $Container, $( $fields) +) }
1430+ const { builtin # offset_of ( $Container, $( $fields) +) }
14311431}
14321432
14331433/// Create a fresh instance of the inhabited ZST type `T`.
You can’t perform that action at this time.
0 commit comments