You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow null-pointer-optimized enums in FFI if their underlying representation is FFI safe
This allows types like Option<NonZeroU8> to be used in FFI without triggering the improper_ctypes lint. This works by changing the is_repr_nullable_ptr function to consider an enum E to be FFI-safe if:
- E has no explicit #[repr(...)].
- It only has two variants.
- One of those variants is empty (meaning it has no fields).
- The other variant has only one field.
- That field is one of the following:
- &T
- &mut T
- extern "C" fn
- core::num::NonZero*
- core::ptr::NonNull<T>
- #[repr(transparent)] struct wrapper around one of the types in this list.
- The size of E and its field are both known and are both the same size (implying E is participating in the nonnull optimization).
Copy file name to clipboardExpand all lines: src/test/ui/feature-gates/feature-gate-rustc-attrs-1.rs
+1
Original file line number
Diff line number
Diff line change
@@ -4,5 +4,6 @@
4
4
5
5
#[rustc_variance]//~ ERROR the `#[rustc_variance]` attribute is just used for rustc unit tests and will never be stable
6
6
#[rustc_error]//~ ERROR the `#[rustc_error]` attribute is just used for rustc unit tests and will never be stable
7
+
#[rustc_nonnull_optimization_guaranteed]//~ ERROR the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to enable niche optimizations in libcore and will never be stable
0 commit comments