mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-28 03:07:24 +03:00
add an adt flag for MaybeDangling
This commit is contained in:
@@ -341,7 +341,8 @@ fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher) {
|
||||
|
||||
PhantomData, sym::phantom_data, phantom_data, Target::Struct, GenericRequirement::Exact(1);
|
||||
|
||||
ManuallyDrop, sym::manually_drop, manually_drop, Target::Struct, GenericRequirement::None;
|
||||
ManuallyDrop, sym::manually_drop, manually_drop, Target::Struct, GenericRequirement::Exact(1);
|
||||
MaybeDangling, sym::maybe_dangling, maybe_dangling, Target::Struct, GenericRequirement::Exact(1);
|
||||
BikeshedGuaranteedNoDrop, sym::bikeshed_guaranteed_no_drop, bikeshed_guaranteed_no_drop, Target::Trait, GenericRequirement::Exact(0);
|
||||
|
||||
MaybeUninit, sym::maybe_uninit, maybe_uninit, Target::Union, GenericRequirement::None;
|
||||
|
||||
@@ -62,6 +62,8 @@ impl AdtFlags: u16 {
|
||||
const IS_PIN_PROJECT = 1 << 12;
|
||||
/// Indicates whether the type is `FieldRepresentingType`.
|
||||
const IS_FIELD_REPRESENTING_TYPE = 1 << 13;
|
||||
/// Indicates whether the type is `MaybeDangling<_>`.
|
||||
const IS_MAYBE_DANGLING = 1 << 14;
|
||||
}
|
||||
}
|
||||
rustc_data_structures::external_bitflags_debug! { AdtFlags }
|
||||
@@ -373,6 +375,9 @@ pub(super) fn new(
|
||||
if tcx.is_lang_item(did, LangItem::ManuallyDrop) {
|
||||
flags |= AdtFlags::IS_MANUALLY_DROP;
|
||||
}
|
||||
if tcx.is_lang_item(did, LangItem::MaybeDangling) {
|
||||
flags |= AdtFlags::IS_MAYBE_DANGLING;
|
||||
}
|
||||
if tcx.is_lang_item(did, LangItem::UnsafeCell) {
|
||||
flags |= AdtFlags::IS_UNSAFE_CELL;
|
||||
}
|
||||
@@ -500,6 +505,12 @@ pub fn is_manually_drop(self) -> bool {
|
||||
self.flags().contains(AdtFlags::IS_MANUALLY_DROP)
|
||||
}
|
||||
|
||||
/// Returns `true` if this is `MaybeDangling<T>`.
|
||||
#[inline]
|
||||
pub fn is_maybe_dangling(self) -> bool {
|
||||
self.flags().contains(AdtFlags::IS_MAYBE_DANGLING)
|
||||
}
|
||||
|
||||
/// Returns `true` if this is `Pin<T>`.
|
||||
#[inline]
|
||||
pub fn is_pin(self) -> bool {
|
||||
|
||||
@@ -1230,6 +1230,7 @@
|
||||
maxnumf128,
|
||||
may_dangle,
|
||||
may_unwind,
|
||||
maybe_dangling,
|
||||
maybe_uninit,
|
||||
maybe_uninit_uninit,
|
||||
maybe_uninit_zeroed,
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
#[repr(transparent)]
|
||||
#[rustc_pub_transparent]
|
||||
#[derive(Debug, Copy, Clone, Default)]
|
||||
#[lang = "maybe_dangling"]
|
||||
pub struct MaybeDangling<P: ?Sized>(P);
|
||||
|
||||
impl<P: ?Sized> MaybeDangling<P> {
|
||||
|
||||
Reference in New Issue
Block a user