1use crate::inherent::*;
2use crate::visit::Flags;
3use crate::{selfas ty, Interner};
45#[doc = r" Flags that we track on types. These flags are propagated upwards"]
#[doc =
r" through the type during type construction, so that we can quickly check"]
#[doc =
r" whether the type has various kinds of types in it without recursing"]
#[doc = r" over the type itself."]
pub struct TypeFlags(<TypeFlags as
::bitflags::__private::PublicFlags>::Internal);
#[automatically_derived]
impl ::core::fmt::Debug for TypeFlags {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f, "TypeFlags",
&&self.0)
}
}
#[automatically_derived]
impl ::core::marker::StructuralPartialEq for TypeFlags { }
#[automatically_derived]
impl ::core::cmp::PartialEq for TypeFlags {
#[inline]
fn eq(&self, other: &TypeFlags) -> bool { self.0 == other.0 }
}
#[automatically_derived]
impl ::core::cmp::Eq for TypeFlags {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) {
let _:
::core::cmp::AssertParamIsEq<<TypeFlags as
::bitflags::__private::PublicFlags>::Internal>;
}
}
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for TypeFlags { }
#[automatically_derived]
impl ::core::clone::Clone for TypeFlags {
#[inline]
fn clone(&self) -> TypeFlags {
let _:
::core::clone::AssertParamIsClone<<TypeFlags as
::bitflags::__private::PublicFlags>::Internal>;
*self
}
}
#[automatically_derived]
impl ::core::marker::Copy for TypeFlags { }
impl TypeFlags {
#[doc = r" Does this have `Param`?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_TY_PARAM: Self = Self::from_bits_retain(1 << 0);
#[doc = r" Does this have `ReEarlyParam`?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_RE_PARAM: Self = Self::from_bits_retain(1 << 1);
#[doc = r" Does this have `ConstKind::Param`?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_CT_PARAM: Self = Self::from_bits_retain(1 << 2);
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_PARAM: Self =
Self::from_bits_retain(TypeFlags::HAS_TY_PARAM.bits() |
TypeFlags::HAS_RE_PARAM.bits() |
TypeFlags::HAS_CT_PARAM.bits());
#[doc = r" Does this have `Infer`?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_TY_INFER: Self = Self::from_bits_retain(1 << 3);
#[doc = r" Does this have `ReVar`?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_RE_INFER: Self = Self::from_bits_retain(1 << 4);
#[doc = r" Does this have `ConstKind::Infer`?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_CT_INFER: Self = Self::from_bits_retain(1 << 5);
#[doc = r" Does this have inference variables? Used to determine whether"]
#[doc = r" inference is required."]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_INFER: Self =
Self::from_bits_retain(TypeFlags::HAS_TY_INFER.bits() |
TypeFlags::HAS_RE_INFER.bits() |
TypeFlags::HAS_CT_INFER.bits());
#[doc = r" Does this have `Placeholder`?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_TY_PLACEHOLDER: Self = Self::from_bits_retain(1 << 6);
#[doc = r" Does this have `RePlaceholder`?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_RE_PLACEHOLDER: Self = Self::from_bits_retain(1 << 7);
#[doc = r" Does this have `ConstKind::Placeholder`?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_CT_PLACEHOLDER: Self = Self::from_bits_retain(1 << 8);
#[doc = r" Does this have placeholders?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_PLACEHOLDER: Self =
Self::from_bits_retain(TypeFlags::HAS_TY_PLACEHOLDER.bits() |
TypeFlags::HAS_RE_PLACEHOLDER.bits() |
TypeFlags::HAS_CT_PLACEHOLDER.bits());
#[doc = r#" `true` if there are "names" of regions and so forth"#]
#[doc = r" that are local to a particular fn/inferctxt"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_FREE_LOCAL_REGIONS: Self = Self::from_bits_retain(1 << 9);
#[doc =
r#" `true` if there are "names" of types and regions and so forth"#]
#[doc = r" that are local to a particular fn"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_FREE_LOCAL_NAMES: Self =
Self::from_bits_retain(TypeFlags::HAS_TY_PARAM.bits() |
TypeFlags::HAS_CT_PARAM.bits() |
TypeFlags::HAS_TY_INFER.bits() |
TypeFlags::HAS_CT_INFER.bits() |
TypeFlags::HAS_TY_PLACEHOLDER.bits() |
TypeFlags::HAS_CT_PLACEHOLDER.bits() |
TypeFlags::HAS_TY_FRESH.bits() |
TypeFlags::HAS_CT_FRESH.bits() |
TypeFlags::HAS_FREE_LOCAL_REGIONS.bits() |
TypeFlags::HAS_RE_ERASED.bits());
#[doc = r" Does this have `Projection`?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_TY_PROJECTION: Self = Self::from_bits_retain(1 << 10);
#[doc = r" Does this have `Free` aliases?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_TY_FREE_ALIAS: Self = Self::from_bits_retain(1 << 11);
#[doc = r" Does this have `Opaque`?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_TY_OPAQUE: Self = Self::from_bits_retain(1 << 12);
#[doc = r" Does this have `Inherent`?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_TY_INHERENT: Self = Self::from_bits_retain(1 << 13);
#[doc = r" Does this have `ConstKind::Unevaluated`?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_CT_PROJECTION: Self = Self::from_bits_retain(1 << 14);
#[doc = r" Does this have `Alias` or `ConstKind::Unevaluated`?"]
#[doc = r""]
#[doc = r" Rephrased, could this term be normalized further?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_ALIAS: Self =
Self::from_bits_retain(TypeFlags::HAS_TY_PROJECTION.bits() |
TypeFlags::HAS_TY_FREE_ALIAS.bits() |
TypeFlags::HAS_TY_OPAQUE.bits() |
TypeFlags::HAS_TY_INHERENT.bits() |
TypeFlags::HAS_CT_PROJECTION.bits());
#[doc = r" Is an error type/lifetime/const reachable?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_ERROR: Self = Self::from_bits_retain(1 << 15);
#[doc = r#" Does this have any region that "appears free" in the type?"#]
#[doc = r" Basically anything but `ReBound` and `ReErased`."]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_FREE_REGIONS: Self = Self::from_bits_retain(1 << 16);
#[doc = r" Does this have any `ReBound` regions?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_RE_BOUND: Self = Self::from_bits_retain(1 << 17);
#[doc = r" Does this have any `Bound` types?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_TY_BOUND: Self = Self::from_bits_retain(1 << 18);
#[doc = r" Does this have any `ConstKind::Bound` consts?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_CT_BOUND: Self = Self::from_bits_retain(1 << 19);
#[doc = r" Does this have any bound variables?"]
#[doc = r" Used to check if a global bound is safe to evaluate."]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_BOUND_VARS: Self =
Self::from_bits_retain(TypeFlags::HAS_RE_BOUND.bits() |
TypeFlags::HAS_TY_BOUND.bits() |
TypeFlags::HAS_CT_BOUND.bits());
#[doc = r" Does this have any `ReErased` regions?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_RE_ERASED: Self = Self::from_bits_retain(1 << 20);
#[doc =
r" Does this value have parameters/placeholders/inference variables which could be"]
#[doc =
r" replaced later, in a way that would change the results of `impl` specialization?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const STILL_FURTHER_SPECIALIZABLE: Self =
Self::from_bits_retain(TypeFlags::HAS_TY_PARAM.bits() |
TypeFlags::HAS_TY_PLACEHOLDER.bits() |
TypeFlags::HAS_TY_INFER.bits() |
TypeFlags::HAS_CT_PARAM.bits() |
TypeFlags::HAS_CT_PLACEHOLDER.bits() |
TypeFlags::HAS_CT_INFER.bits());
#[doc =
r" Does this value have `InferTy::FreshTy/FreshIntTy/FreshFloatTy`?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_TY_FRESH: Self = Self::from_bits_retain(1 << 21);
#[doc = r" Does this value have `InferConst::Fresh`?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_CT_FRESH: Self = Self::from_bits_retain(1 << 22);
#[doc =
r" Does this have any binders with bound vars (e.g. that need to be anonymized)?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_BINDER_VARS: Self = Self::from_bits_retain(1 << 23);
#[doc = r" Does this type have any coroutines in it?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_TY_CORO: Self = Self::from_bits_retain(1 << 24);
#[doc =
r" Does this have have a `Bound(BoundVarIndexKind::Canonical, _)`?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_CANONICAL_BOUND: Self = Self::from_bits_retain(1 << 25);
}
impl ::bitflags::Flags for TypeFlags {
const FLAGS: &'static [::bitflags::Flag<TypeFlags>] =
&[{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_TY_PARAM",
TypeFlags::HAS_TY_PARAM)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_RE_PARAM",
TypeFlags::HAS_RE_PARAM)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_CT_PARAM",
TypeFlags::HAS_CT_PARAM)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_PARAM", TypeFlags::HAS_PARAM)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_TY_INFER",
TypeFlags::HAS_TY_INFER)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_RE_INFER",
TypeFlags::HAS_RE_INFER)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_CT_INFER",
TypeFlags::HAS_CT_INFER)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_INFER", TypeFlags::HAS_INFER)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_TY_PLACEHOLDER",
TypeFlags::HAS_TY_PLACEHOLDER)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_RE_PLACEHOLDER",
TypeFlags::HAS_RE_PLACEHOLDER)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_CT_PLACEHOLDER",
TypeFlags::HAS_CT_PLACEHOLDER)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_PLACEHOLDER",
TypeFlags::HAS_PLACEHOLDER)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_FREE_LOCAL_REGIONS",
TypeFlags::HAS_FREE_LOCAL_REGIONS)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_FREE_LOCAL_NAMES",
TypeFlags::HAS_FREE_LOCAL_NAMES)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_TY_PROJECTION",
TypeFlags::HAS_TY_PROJECTION)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_TY_FREE_ALIAS",
TypeFlags::HAS_TY_FREE_ALIAS)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_TY_OPAQUE",
TypeFlags::HAS_TY_OPAQUE)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_TY_INHERENT",
TypeFlags::HAS_TY_INHERENT)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_CT_PROJECTION",
TypeFlags::HAS_CT_PROJECTION)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_ALIAS", TypeFlags::HAS_ALIAS)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_ERROR", TypeFlags::HAS_ERROR)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_FREE_REGIONS",
TypeFlags::HAS_FREE_REGIONS)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_RE_BOUND",
TypeFlags::HAS_RE_BOUND)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_TY_BOUND",
TypeFlags::HAS_TY_BOUND)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_CT_BOUND",
TypeFlags::HAS_CT_BOUND)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_BOUND_VARS",
TypeFlags::HAS_BOUND_VARS)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_RE_ERASED",
TypeFlags::HAS_RE_ERASED)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("STILL_FURTHER_SPECIALIZABLE",
TypeFlags::STILL_FURTHER_SPECIALIZABLE)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_TY_FRESH",
TypeFlags::HAS_TY_FRESH)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_CT_FRESH",
TypeFlags::HAS_CT_FRESH)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_BINDER_VARS",
TypeFlags::HAS_BINDER_VARS)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_TY_CORO", TypeFlags::HAS_TY_CORO)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_CANONICAL_BOUND",
TypeFlags::HAS_CANONICAL_BOUND)
}];
type Bits = u32;
fn bits(&self) -> u32 { TypeFlags::bits(self) }
fn from_bits_retain(bits: u32) -> TypeFlags {
TypeFlags::from_bits_retain(bits)
}
}
#[allow(dead_code, deprecated, unused_doc_comments, unused_attributes,
unused_mut, unused_imports, non_upper_case_globals, clippy ::
assign_op_pattern, clippy :: indexing_slicing, clippy :: same_name_method,
clippy :: iter_without_into_iter,)]
const _: () =
{
#[repr(transparent)]
pub struct InternalBitFlags(u32);
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for InternalBitFlags { }
#[automatically_derived]
impl ::core::clone::Clone for InternalBitFlags {
#[inline]
fn clone(&self) -> InternalBitFlags {
let _: ::core::clone::AssertParamIsClone<u32>;
*self
}
}
#[automatically_derived]
impl ::core::marker::Copy for InternalBitFlags { }
#[automatically_derived]
impl ::core::marker::StructuralPartialEq for InternalBitFlags { }
#[automatically_derived]
impl ::core::cmp::PartialEq for InternalBitFlags {
#[inline]
fn eq(&self, other: &InternalBitFlags) -> bool {
self.0 == other.0
}
}
#[automatically_derived]
impl ::core::cmp::Eq for InternalBitFlags {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<u32>;
}
}
#[automatically_derived]
impl ::core::cmp::PartialOrd for InternalBitFlags {
#[inline]
fn partial_cmp(&self, other: &InternalBitFlags)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::cmp::PartialOrd::partial_cmp(&self.0, &other.0)
}
}
#[automatically_derived]
impl ::core::cmp::Ord for InternalBitFlags {
#[inline]
fn cmp(&self, other: &InternalBitFlags) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&self.0, &other.0)
}
}
#[automatically_derived]
impl ::core::hash::Hash for InternalBitFlags {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.0, state)
}
}
impl ::bitflags::__private::PublicFlags for TypeFlags {
type Primitive = u32;
type Internal = InternalBitFlags;
}
impl ::bitflags::__private::core::default::Default for
InternalBitFlags {
#[inline]
fn default() -> Self { InternalBitFlags::empty() }
}
impl ::bitflags::__private::core::fmt::Debug for InternalBitFlags {
fn fmt(&self,
f: &mut ::bitflags::__private::core::fmt::Formatter<'_>)
-> ::bitflags::__private::core::fmt::Result {
if self.is_empty() {
f.write_fmt(format_args!("{0:#x}",
<u32 as ::bitflags::Bits>::EMPTY))
} else {
::bitflags::__private::core::fmt::Display::fmt(self, f)
}
}
}
impl ::bitflags::__private::core::fmt::Display for InternalBitFlags {
fn fmt(&self,
f: &mut ::bitflags::__private::core::fmt::Formatter<'_>)
-> ::bitflags::__private::core::fmt::Result {
::bitflags::parser::to_writer(&TypeFlags(*self), f)
}
}
impl ::bitflags::__private::core::str::FromStr for InternalBitFlags {
type Err = ::bitflags::parser::ParseError;
fn from_str(s: &str)
->
::bitflags::__private::core::result::Result<Self,
Self::Err> {
::bitflags::parser::from_str::<TypeFlags>(s).map(|flags|
flags.0)
}
}
impl ::bitflags::__private::core::convert::AsRef<u32> for
InternalBitFlags {
fn as_ref(&self) -> &u32 { &self.0 }
}
impl ::bitflags::__private::core::convert::From<u32> for
InternalBitFlags {
fn from(bits: u32) -> Self { Self::from_bits_retain(bits) }
}
#[allow(dead_code, deprecated, unused_attributes)]
impl InternalBitFlags {
/// Get a flags value with all bits unset.
#[inline]
pub const fn empty() -> Self {
Self(<u32 as ::bitflags::Bits>::EMPTY)
}
/// Get a flags value with all known bits set.
#[inline]
pub const fn all() -> Self {
let mut truncated = <u32 as ::bitflags::Bits>::EMPTY;
let mut i = 0;
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<TypeFlags as ::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
let _ = i;
Self(truncated)
}
/// Get the underlying bits value.
///
/// The returned value is exactly the bits set in this flags value.
#[inline]
pub const fn bits(&self) -> u32 { self.0 }
/// Convert from a bits value.
///
/// This method will return `None` if any unknown bits are set.
#[inline]
pub const fn from_bits(bits: u32)
-> ::bitflags::__private::core::option::Option<Self> {
let truncated = Self::from_bits_truncate(bits).0;
if truncated == bits {
::bitflags::__private::core::option::Option::Some(Self(bits))
} else { ::bitflags::__private::core::option::Option::None }
}
/// Convert from a bits value, unsetting any unknown bits.
#[inline]
pub const fn from_bits_truncate(bits: u32) -> Self {
Self(bits & Self::all().0)
}
/// Convert from a bits value exactly.
#[inline]
pub const fn from_bits_retain(bits: u32) -> Self { Self(bits) }
/// Get a flags value with the bits of a flag with the given name set.
///
/// This method will return `None` if `name` is empty or doesn't
/// correspond to any named flag.
#[inline]
pub fn from_name(name: &str)
-> ::bitflags::__private::core::option::Option<Self> {
{
if name == "HAS_TY_PARAM" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_TY_PARAM.bits()));
}
};
;
{
if name == "HAS_RE_PARAM" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_RE_PARAM.bits()));
}
};
;
{
if name == "HAS_CT_PARAM" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_CT_PARAM.bits()));
}
};
;
{
if name == "HAS_PARAM" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_PARAM.bits()));
}
};
;
{
if name == "HAS_TY_INFER" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_TY_INFER.bits()));
}
};
;
{
if name == "HAS_RE_INFER" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_RE_INFER.bits()));
}
};
;
{
if name == "HAS_CT_INFER" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_CT_INFER.bits()));
}
};
;
{
if name == "HAS_INFER" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_INFER.bits()));
}
};
;
{
if name == "HAS_TY_PLACEHOLDER" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_TY_PLACEHOLDER.bits()));
}
};
;
{
if name == "HAS_RE_PLACEHOLDER" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_RE_PLACEHOLDER.bits()));
}
};
;
{
if name == "HAS_CT_PLACEHOLDER" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_CT_PLACEHOLDER.bits()));
}
};
;
{
if name == "HAS_PLACEHOLDER" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_PLACEHOLDER.bits()));
}
};
;
{
if name == "HAS_FREE_LOCAL_REGIONS" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_FREE_LOCAL_REGIONS.bits()));
}
};
;
{
if name == "HAS_FREE_LOCAL_NAMES" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_FREE_LOCAL_NAMES.bits()));
}
};
;
{
if name == "HAS_TY_PROJECTION" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_TY_PROJECTION.bits()));
}
};
;
{
if name == "HAS_TY_FREE_ALIAS" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_TY_FREE_ALIAS.bits()));
}
};
;
{
if name == "HAS_TY_OPAQUE" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_TY_OPAQUE.bits()));
}
};
;
{
if name == "HAS_TY_INHERENT" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_TY_INHERENT.bits()));
}
};
;
{
if name == "HAS_CT_PROJECTION" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_CT_PROJECTION.bits()));
}
};
;
{
if name == "HAS_ALIAS" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_ALIAS.bits()));
}
};
;
{
if name == "HAS_ERROR" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_ERROR.bits()));
}
};
;
{
if name == "HAS_FREE_REGIONS" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_FREE_REGIONS.bits()));
}
};
;
{
if name == "HAS_RE_BOUND" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_RE_BOUND.bits()));
}
};
;
{
if name == "HAS_TY_BOUND" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_TY_BOUND.bits()));
}
};
;
{
if name == "HAS_CT_BOUND" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_CT_BOUND.bits()));
}
};
;
{
if name == "HAS_BOUND_VARS" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_BOUND_VARS.bits()));
}
};
;
{
if name == "HAS_RE_ERASED" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_RE_ERASED.bits()));
}
};
;
{
if name == "STILL_FURTHER_SPECIALIZABLE" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::STILL_FURTHER_SPECIALIZABLE.bits()));
}
};
;
{
if name == "HAS_TY_FRESH" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_TY_FRESH.bits()));
}
};
;
{
if name == "HAS_CT_FRESH" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_CT_FRESH.bits()));
}
};
;
{
if name == "HAS_BINDER_VARS" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_BINDER_VARS.bits()));
}
};
;
{
if name == "HAS_TY_CORO" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_TY_CORO.bits()));
}
};
;
{
if name == "HAS_CANONICAL_BOUND" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_CANONICAL_BOUND.bits()));
}
};
;
let _ = name;
::bitflags::__private::core::option::Option::None
}
/// Whether all bits in this flags value are unset.
#[inline]
pub const fn is_empty(&self) -> bool {
self.0 == <u32 as ::bitflags::Bits>::EMPTY
}
/// Whether all known bits in this flags value are set.
#[inline]
pub const fn is_all(&self) -> bool {
Self::all().0 | self.0 == self.0
}
/// Whether any set bits in a source flags value are also set in a target flags value.
#[inline]
pub const fn intersects(&self, other: Self) -> bool {
self.0 & other.0 != <u32 as ::bitflags::Bits>::EMPTY
}
/// Whether all set bits in a source flags value are also set in a target flags value.
#[inline]
pub const fn contains(&self, other: Self) -> bool {
self.0 & other.0 == other.0
}
/// The bitwise or (`|`) of the bits in two flags values.
#[inline]
pub fn insert(&mut self, other: Self) {
*self = Self(self.0).union(other);
}
/// The intersection of a source flags value with the complement of a target flags
/// value (`&!`).
///
/// This method is not equivalent to `self & !other` when `other` has unknown bits set.
/// `remove` won't truncate `other`, but the `!` operator will.
#[inline]
pub fn remove(&mut self, other: Self) {
*self = Self(self.0).difference(other);
}
/// The bitwise exclusive-or (`^`) of the bits in two flags values.
#[inline]
pub fn toggle(&mut self, other: Self) {
*self = Self(self.0).symmetric_difference(other);
}
/// Call `insert` when `value` is `true` or `remove` when `value` is `false`.
#[inline]
pub fn set(&mut self, other: Self, value: bool) {
if value { self.insert(other); } else { self.remove(other); }
}
/// The bitwise and (`&`) of the bits in two flags values.
#[inline]
#[must_use]
pub const fn intersection(self, other: Self) -> Self {
Self(self.0 & other.0)
}
/// The bitwise or (`|`) of the bits in two flags values.
#[inline]
#[must_use]
pub const fn union(self, other: Self) -> Self {
Self(self.0 | other.0)
}
/// The intersection of a source flags value with the complement of a target flags
/// value (`&!`).
///
/// This method is not equivalent to `self & !other` when `other` has unknown bits set.
/// `difference` won't truncate `other`, but the `!` operator will.
#[inline]
#[must_use]
pub const fn difference(self, other: Self) -> Self {
Self(self.0 & !other.0)
}
/// The bitwise exclusive-or (`^`) of the bits in two flags values.
#[inline]
#[must_use]
pub const fn symmetric_difference(self, other: Self) -> Self {
Self(self.0 ^ other.0)
}
/// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
#[inline]
#[must_use]
pub const fn complement(self) -> Self {
Self::from_bits_truncate(!self.0)
}
}
impl ::bitflags::__private::core::fmt::Binary for InternalBitFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Binary::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::Octal for InternalBitFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Octal::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::LowerHex for InternalBitFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::LowerHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::UpperHex for InternalBitFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::UpperHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::ops::BitOr for InternalBitFlags {
type Output = Self;
/// The bitwise or (`|`) of the bits in two flags values.
#[inline]
fn bitor(self, other: InternalBitFlags) -> Self {
self.union(other)
}
}
impl ::bitflags::__private::core::ops::BitOrAssign for
InternalBitFlags {
/// The bitwise or (`|`) of the bits in two flags values.
#[inline]
fn bitor_assign(&mut self, other: Self) { self.insert(other); }
}
impl ::bitflags::__private::core::ops::BitXor for InternalBitFlags {
type Output = Self;
/// The bitwise exclusive-or (`^`) of the bits in two flags values.
#[inline]
fn bitxor(self, other: Self) -> Self {
self.symmetric_difference(other)
}
}
impl ::bitflags::__private::core::ops::BitXorAssign for
InternalBitFlags {
/// The bitwise exclusive-or (`^`) of the bits in two flags values.
#[inline]
fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
}
impl ::bitflags::__private::core::ops::BitAnd for InternalBitFlags {
type Output = Self;
/// The bitwise and (`&`) of the bits in two flags values.
#[inline]
fn bitand(self, other: Self) -> Self { self.intersection(other) }
}
impl ::bitflags::__private::core::ops::BitAndAssign for
InternalBitFlags {
/// The bitwise and (`&`) of the bits in two flags values.
#[inline]
fn bitand_assign(&mut self, other: Self) {
*self =
Self::from_bits_retain(self.bits()).intersection(other);
}
}
impl ::bitflags::__private::core::ops::Sub for InternalBitFlags {
type Output = Self;
/// The intersection of a source flags value with the complement of a target flags value (`&!`).
///
/// This method is not equivalent to `self & !other` when `other` has unknown bits set.
/// `difference` won't truncate `other`, but the `!` operator will.
#[inline]
fn sub(self, other: Self) -> Self { self.difference(other) }
}
impl ::bitflags::__private::core::ops::SubAssign for InternalBitFlags
{
/// The intersection of a source flags value with the complement of a target flags value (`&!`).
///
/// This method is not equivalent to `self & !other` when `other` has unknown bits set.
/// `difference` won't truncate `other`, but the `!` operator will.
#[inline]
fn sub_assign(&mut self, other: Self) { self.remove(other); }
}
impl ::bitflags::__private::core::ops::Not for InternalBitFlags {
type Output = Self;
/// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
#[inline]
fn not(self) -> Self { self.complement() }
}
impl ::bitflags::__private::core::iter::Extend<InternalBitFlags> for
InternalBitFlags {
/// The bitwise or (`|`) of the bits in each flags value.
fn extend<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(&mut self, iterator: T) {
for item in iterator { self.insert(item) }
}
}
impl ::bitflags::__private::core::iter::FromIterator<InternalBitFlags>
for InternalBitFlags {
/// The bitwise or (`|`) of the bits in each flags value.
fn from_iter<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(iterator: T) -> Self {
use ::bitflags::__private::core::iter::Extend;
let mut result = Self::empty();
result.extend(iterator);
result
}
}
impl InternalBitFlags {
/// Yield a set of contained flags values.
///
/// Each yielded flags value will correspond to a defined named flag. Any unknown bits
/// will be yielded together as a final flags value.
#[inline]
pub const fn iter(&self) -> ::bitflags::iter::Iter<TypeFlags> {
::bitflags::iter::Iter::__private_const_new(<TypeFlags as
::bitflags::Flags>::FLAGS,
TypeFlags::from_bits_retain(self.bits()),
TypeFlags::from_bits_retain(self.bits()))
}
/// Yield a set of contained named flags values.
///
/// This method is like [`iter`](#method.iter), except only yields bits in contained named flags.
/// Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
#[inline]
pub const fn iter_names(&self)
-> ::bitflags::iter::IterNames<TypeFlags> {
::bitflags::iter::IterNames::__private_const_new(<TypeFlags as
::bitflags::Flags>::FLAGS,
TypeFlags::from_bits_retain(self.bits()),
TypeFlags::from_bits_retain(self.bits()))
}
}
impl ::bitflags::__private::core::iter::IntoIterator for
InternalBitFlags {
type Item = TypeFlags;
type IntoIter = ::bitflags::iter::Iter<TypeFlags>;
fn into_iter(self) -> Self::IntoIter { self.iter() }
}
impl InternalBitFlags {
/// Returns a mutable reference to the raw value of the flags currently stored.
#[inline]
pub fn bits_mut(&mut self) -> &mut u32 { &mut self.0 }
}
#[allow(dead_code, deprecated, unused_attributes)]
impl TypeFlags {
/// Get a flags value with all bits unset.
#[inline]
pub const fn empty() -> Self { Self(InternalBitFlags::empty()) }
/// Get a flags value with all known bits set.
#[inline]
pub const fn all() -> Self { Self(InternalBitFlags::all()) }
/// Get the underlying bits value.
///
/// The returned value is exactly the bits set in this flags value.
#[inline]
pub const fn bits(&self) -> u32 { self.0.bits() }
/// Convert from a bits value.
///
/// This method will return `None` if any unknown bits are set.
#[inline]
pub const fn from_bits(bits: u32)
-> ::bitflags::__private::core::option::Option<Self> {
match InternalBitFlags::from_bits(bits) {
::bitflags::__private::core::option::Option::Some(bits) =>
::bitflags::__private::core::option::Option::Some(Self(bits)),
::bitflags::__private::core::option::Option::None =>
::bitflags::__private::core::option::Option::None,
}
}
/// Convert from a bits value, unsetting any unknown bits.
#[inline]
pub const fn from_bits_truncate(bits: u32) -> Self {
Self(InternalBitFlags::from_bits_truncate(bits))
}
/// Convert from a bits value exactly.
#[inline]
pub const fn from_bits_retain(bits: u32) -> Self {
Self(InternalBitFlags::from_bits_retain(bits))
}
/// Get a flags value with the bits of a flag with the given name set.
///
/// This method will return `None` if `name` is empty or doesn't
/// correspond to any named flag.
#[inline]
pub fn from_name(name: &str)
-> ::bitflags::__private::core::option::Option<Self> {
match InternalBitFlags::from_name(name) {
::bitflags::__private::core::option::Option::Some(bits) =>
::bitflags::__private::core::option::Option::Some(Self(bits)),
::bitflags::__private::core::option::Option::None =>
::bitflags::__private::core::option::Option::None,
}
}
/// Whether all bits in this flags value are unset.
#[inline]
pub const fn is_empty(&self) -> bool { self.0.is_empty() }
/// Whether all known bits in this flags value are set.
#[inline]
pub const fn is_all(&self) -> bool { self.0.is_all() }
/// Whether any set bits in a source flags value are also set in a target flags value.
#[inline]
pub const fn intersects(&self, other: Self) -> bool {
self.0.intersects(other.0)
}
/// Whether all set bits in a source flags value are also set in a target flags value.
#[inline]
pub const fn contains(&self, other: Self) -> bool {
self.0.contains(other.0)
}
/// The bitwise or (`|`) of the bits in two flags values.
#[inline]
pub fn insert(&mut self, other: Self) { self.0.insert(other.0) }
/// The intersection of a source flags value with the complement of a target flags
/// value (`&!`).
///
/// This method is not equivalent to `self & !other` when `other` has unknown bits set.
/// `remove` won't truncate `other`, but the `!` operator will.
#[inline]
pub fn remove(&mut self, other: Self) { self.0.remove(other.0) }
/// The bitwise exclusive-or (`^`) of the bits in two flags values.
#[inline]
pub fn toggle(&mut self, other: Self) { self.0.toggle(other.0) }
/// Call `insert` when `value` is `true` or `remove` when `value` is `false`.
#[inline]
pub fn set(&mut self, other: Self, value: bool) {
self.0.set(other.0, value)
}
/// The bitwise and (`&`) of the bits in two flags values.
#[inline]
#[must_use]
pub const fn intersection(self, other: Self) -> Self {
Self(self.0.intersection(other.0))
}
/// The bitwise or (`|`) of the bits in two flags values.
#[inline]
#[must_use]
pub const fn union(self, other: Self) -> Self {
Self(self.0.union(other.0))
}
/// The intersection of a source flags value with the complement of a target flags
/// value (`&!`).
///
/// This method is not equivalent to `self & !other` when `other` has unknown bits set.
/// `difference` won't truncate `other`, but the `!` operator will.
#[inline]
#[must_use]
pub const fn difference(self, other: Self) -> Self {
Self(self.0.difference(other.0))
}
/// The bitwise exclusive-or (`^`) of the bits in two flags values.
#[inline]
#[must_use]
pub const fn symmetric_difference(self, other: Self) -> Self {
Self(self.0.symmetric_difference(other.0))
}
/// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
#[inline]
#[must_use]
pub const fn complement(self) -> Self {
Self(self.0.complement())
}
}
impl ::bitflags::__private::core::fmt::Binary for TypeFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Binary::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::Octal for TypeFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Octal::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::LowerHex for TypeFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::LowerHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::UpperHex for TypeFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::UpperHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::ops::BitOr for TypeFlags {
type Output = Self;
/// The bitwise or (`|`) of the bits in two flags values.
#[inline]
fn bitor(self, other: TypeFlags) -> Self { self.union(other) }
}
impl ::bitflags::__private::core::ops::BitOrAssign for TypeFlags {
/// The bitwise or (`|`) of the bits in two flags values.
#[inline]
fn bitor_assign(&mut self, other: Self) { self.insert(other); }
}
impl ::bitflags::__private::core::ops::BitXor for TypeFlags {
type Output = Self;
/// The bitwise exclusive-or (`^`) of the bits in two flags values.
#[inline]
fn bitxor(self, other: Self) -> Self {
self.symmetric_difference(other)
}
}
impl ::bitflags::__private::core::ops::BitXorAssign for TypeFlags {
/// The bitwise exclusive-or (`^`) of the bits in two flags values.
#[inline]
fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
}
impl ::bitflags::__private::core::ops::BitAnd for TypeFlags {
type Output = Self;
/// The bitwise and (`&`) of the bits in two flags values.
#[inline]
fn bitand(self, other: Self) -> Self { self.intersection(other) }
}
impl ::bitflags::__private::core::ops::BitAndAssign for TypeFlags {
/// The bitwise and (`&`) of the bits in two flags values.
#[inline]
fn bitand_assign(&mut self, other: Self) {
*self =
Self::from_bits_retain(self.bits()).intersection(other);
}
}
impl ::bitflags::__private::core::ops::Sub for TypeFlags {
type Output = Self;
/// The intersection of a source flags value with the complement of a target flags value (`&!`).
///
/// This method is not equivalent to `self & !other` when `other` has unknown bits set.
/// `difference` won't truncate `other`, but the `!` operator will.
#[inline]
fn sub(self, other: Self) -> Self { self.difference(other) }
}
impl ::bitflags::__private::core::ops::SubAssign for TypeFlags {
/// The intersection of a source flags value with the complement of a target flags value (`&!`).
///
/// This method is not equivalent to `self & !other` when `other` has unknown bits set.
/// `difference` won't truncate `other`, but the `!` operator will.
#[inline]
fn sub_assign(&mut self, other: Self) { self.remove(other); }
}
impl ::bitflags::__private::core::ops::Not for TypeFlags {
type Output = Self;
/// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
#[inline]
fn not(self) -> Self { self.complement() }
}
impl ::bitflags::__private::core::iter::Extend<TypeFlags> for
TypeFlags {
/// The bitwise or (`|`) of the bits in each flags value.
fn extend<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(&mut self, iterator: T) {
for item in iterator { self.insert(item) }
}
}
impl ::bitflags::__private::core::iter::FromIterator<TypeFlags> for
TypeFlags {
/// The bitwise or (`|`) of the bits in each flags value.
fn from_iter<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(iterator: T) -> Self {
use ::bitflags::__private::core::iter::Extend;
let mut result = Self::empty();
result.extend(iterator);
result
}
}
impl TypeFlags {
/// Yield a set of contained flags values.
///
/// Each yielded flags value will correspond to a defined named flag. Any unknown bits
/// will be yielded together as a final flags value.
#[inline]
pub const fn iter(&self) -> ::bitflags::iter::Iter<TypeFlags> {
::bitflags::iter::Iter::__private_const_new(<TypeFlags as
::bitflags::Flags>::FLAGS,
TypeFlags::from_bits_retain(self.bits()),
TypeFlags::from_bits_retain(self.bits()))
}
/// Yield a set of contained named flags values.
///
/// This method is like [`iter`](#method.iter), except only yields bits in contained named flags.
/// Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
#[inline]
pub const fn iter_names(&self)
-> ::bitflags::iter::IterNames<TypeFlags> {
::bitflags::iter::IterNames::__private_const_new(<TypeFlags as
::bitflags::Flags>::FLAGS,
TypeFlags::from_bits_retain(self.bits()),
TypeFlags::from_bits_retain(self.bits()))
}
}
impl ::bitflags::__private::core::iter::IntoIterator for TypeFlags {
type Item = TypeFlags;
type IntoIter = ::bitflags::iter::Iter<TypeFlags>;
fn into_iter(self) -> Self::IntoIter { self.iter() }
}
};bitflags::bitflags! {
6/// Flags that we track on types. These flags are propagated upwards
7 /// through the type during type construction, so that we can quickly check
8 /// whether the type has various kinds of types in it without recursing
9 /// over the type itself.
10#[derive(Debug, PartialEq, Eq, Clone, Copy)]
11pub struct TypeFlags: u32 {
12// Does this have parameters? Used to determine whether instantiation is
13 // required.
14/// Does this have `Param`?
15const HAS_TY_PARAM = 1 << 0;
16/// Does this have `ReEarlyParam`?
17const HAS_RE_PARAM = 1 << 1;
18/// Does this have `ConstKind::Param`?
19const HAS_CT_PARAM = 1 << 2;
2021const HAS_PARAM = TypeFlags::HAS_TY_PARAM.bits()
22 | TypeFlags::HAS_RE_PARAM.bits()
23 | TypeFlags::HAS_CT_PARAM.bits();
2425/// Does this have `Infer`?
26const HAS_TY_INFER = 1 << 3;
27/// Does this have `ReVar`?
28const HAS_RE_INFER = 1 << 4;
29/// Does this have `ConstKind::Infer`?
30const HAS_CT_INFER = 1 << 5;
3132/// Does this have inference variables? Used to determine whether
33 /// inference is required.
34const HAS_INFER = TypeFlags::HAS_TY_INFER.bits()
35 | TypeFlags::HAS_RE_INFER.bits()
36 | TypeFlags::HAS_CT_INFER.bits();
3738/// Does this have `Placeholder`?
39const HAS_TY_PLACEHOLDER = 1 << 6;
40/// Does this have `RePlaceholder`?
41const HAS_RE_PLACEHOLDER = 1 << 7;
42/// Does this have `ConstKind::Placeholder`?
43const HAS_CT_PLACEHOLDER = 1 << 8;
4445/// Does this have placeholders?
46const HAS_PLACEHOLDER = TypeFlags::HAS_TY_PLACEHOLDER.bits()
47 | TypeFlags::HAS_RE_PLACEHOLDER.bits()
48 | TypeFlags::HAS_CT_PLACEHOLDER.bits();
4950/// `true` if there are "names" of regions and so forth
51 /// that are local to a particular fn/inferctxt
52const HAS_FREE_LOCAL_REGIONS = 1 << 9;
5354/// `true` if there are "names" of types and regions and so forth
55 /// that are local to a particular fn
56const HAS_FREE_LOCAL_NAMES = TypeFlags::HAS_TY_PARAM.bits()
57 | TypeFlags::HAS_CT_PARAM.bits()
58 | TypeFlags::HAS_TY_INFER.bits()
59 | TypeFlags::HAS_CT_INFER.bits()
60 | TypeFlags::HAS_TY_PLACEHOLDER.bits()
61 | TypeFlags::HAS_CT_PLACEHOLDER.bits()
62// We consider 'freshened' types and constants
63 // to depend on a particular fn.
64 // The freshening process throws away information,
65 // which can make things unsuitable for use in a global
66 // cache. Note that there is no 'fresh lifetime' flag -
67 // freshening replaces all lifetimes with `ReErased`,
68 // which is different from how types/const are freshened.
69| TypeFlags::HAS_TY_FRESH.bits()
70 | TypeFlags::HAS_CT_FRESH.bits()
71 | TypeFlags::HAS_FREE_LOCAL_REGIONS.bits()
72 | TypeFlags::HAS_RE_ERASED.bits();
7374/// Does this have `Projection`?
75const HAS_TY_PROJECTION = 1 << 10;
76/// Does this have `Free` aliases?
77const HAS_TY_FREE_ALIAS = 1 << 11;
78/// Does this have `Opaque`?
79const HAS_TY_OPAQUE = 1 << 12;
80/// Does this have `Inherent`?
81const HAS_TY_INHERENT = 1 << 13;
82/// Does this have `ConstKind::Unevaluated`?
83const HAS_CT_PROJECTION = 1 << 14;
8485/// Does this have `Alias` or `ConstKind::Unevaluated`?
86 ///
87 /// Rephrased, could this term be normalized further?
88const HAS_ALIAS = TypeFlags::HAS_TY_PROJECTION.bits()
89 | TypeFlags::HAS_TY_FREE_ALIAS.bits()
90 | TypeFlags::HAS_TY_OPAQUE.bits()
91 | TypeFlags::HAS_TY_INHERENT.bits()
92 | TypeFlags::HAS_CT_PROJECTION.bits();
9394/// Is an error type/lifetime/const reachable?
95const HAS_ERROR = 1 << 15;
9697/// Does this have any region that "appears free" in the type?
98 /// Basically anything but `ReBound` and `ReErased`.
99const HAS_FREE_REGIONS = 1 << 16;
100101/// Does this have any `ReBound` regions?
102const HAS_RE_BOUND = 1 << 17;
103/// Does this have any `Bound` types?
104const HAS_TY_BOUND = 1 << 18;
105/// Does this have any `ConstKind::Bound` consts?
106const HAS_CT_BOUND = 1 << 19;
107/// Does this have any bound variables?
108 /// Used to check if a global bound is safe to evaluate.
109const HAS_BOUND_VARS = TypeFlags::HAS_RE_BOUND.bits()
110 | TypeFlags::HAS_TY_BOUND.bits()
111 | TypeFlags::HAS_CT_BOUND.bits();
112113/// Does this have any `ReErased` regions?
114const HAS_RE_ERASED = 1 << 20;
115116/// Does this value have parameters/placeholders/inference variables which could be
117 /// replaced later, in a way that would change the results of `impl` specialization?
118const STILL_FURTHER_SPECIALIZABLE = TypeFlags::HAS_TY_PARAM.bits()
119 | TypeFlags::HAS_TY_PLACEHOLDER.bits()
120 | TypeFlags::HAS_TY_INFER.bits()
121 | TypeFlags::HAS_CT_PARAM.bits()
122 | TypeFlags::HAS_CT_PLACEHOLDER.bits()
123 | TypeFlags::HAS_CT_INFER.bits();
124125/// Does this value have `InferTy::FreshTy/FreshIntTy/FreshFloatTy`?
126const HAS_TY_FRESH = 1 << 21;
127128/// Does this value have `InferConst::Fresh`?
129const HAS_CT_FRESH = 1 << 22;
130131/// Does this have any binders with bound vars (e.g. that need to be anonymized)?
132const HAS_BINDER_VARS = 1 << 23;
133134/// Does this type have any coroutines in it?
135const HAS_TY_CORO = 1 << 24;
136137/// Does this have have a `Bound(BoundVarIndexKind::Canonical, _)`?
138const HAS_CANONICAL_BOUND = 1 << 25;
139 }
140}141142#[derive(#[automatically_derived]
impl<I: ::core::fmt::Debug> ::core::fmt::Debug for FlagComputation<I> {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"FlagComputation", "flags", &self.flags, "outer_exclusive_binder",
&self.outer_exclusive_binder, "interner", &&self.interner)
}
}Debug)]
143pub struct FlagComputation<I> {
144pub flags: TypeFlags,
145146/// see `Ty::outer_exclusive_binder` for details
147pub outer_exclusive_binder: ty::DebruijnIndex,
148149 interner: std::marker::PhantomData<I>,
150}
151152impl<I: Interner> FlagComputation<I> {
153fn new() -> FlagComputation<I> {
154FlagComputation {
155 flags: TypeFlags::empty(),
156 outer_exclusive_binder: ty::INNERMOST,
157 interner: std::marker::PhantomData,
158 }
159 }
160161#[allow(rustc::usage_of_ty_tykind)]
162pub fn for_kind(kind: &ty::TyKind<I>) -> FlagComputation<I> {
163let mut result = FlagComputation::new();
164result.add_kind(kind);
165result166 }
167168pub fn for_predicate(binder: ty::Binder<I, ty::PredicateKind<I>>) -> FlagComputation<I> {
169let mut result = FlagComputation::new();
170result.add_predicate(binder);
171result172 }
173174pub fn for_const_kind(kind: &ty::ConstKind<I>) -> FlagComputation<I> {
175let mut result = FlagComputation::new();
176result.add_const_kind(kind);
177result178 }
179180pub fn for_clauses(clauses: &[I::Clause]) -> FlagComputation<I> {
181let mut result = FlagComputation::new();
182for c in clauses {
183 result.add_flags(c.as_predicate().flags());
184 result.add_exclusive_binder(c.as_predicate().outer_exclusive_binder());
185 }
186result187 }
188189fn add_flags(&mut self, flags: TypeFlags) {
190self.flags = self.flags | flags;
191 }
192193/// indicates that `self` refers to something at binding level `binder`
194fn add_bound_var(&mut self, binder: ty::DebruijnIndex) {
195let exclusive_binder = binder.shifted_in(1);
196self.add_exclusive_binder(exclusive_binder);
197 }
198199/// indicates that `self` refers to something *inside* binding
200 /// level `binder` -- not bound by `binder`, but bound by the next
201 /// binder internal to it
202fn add_exclusive_binder(&mut self, exclusive_binder: ty::DebruijnIndex) {
203self.outer_exclusive_binder = self.outer_exclusive_binder.max(exclusive_binder);
204 }
205206/// Adds the flags/depth from a set of types that appear within the current type, but within a
207 /// region binder.
208fn bound_computation<T, F>(&mut self, value: ty::Binder<I, T>, f: F)
209where
210F: FnOnce(&mut Self, T),
211 {
212let mut computation = FlagComputation::new();
213214if !value.bound_vars().is_empty() {
215computation.add_flags(TypeFlags::HAS_BINDER_VARS);
216 }
217218f(&mut computation, value.skip_binder());
219220self.add_flags(computation.flags);
221222// The types that contributed to `computation` occurred within
223 // a region binder, so subtract one from the region depth
224 // within when adding the depth to `self`.
225let outer_exclusive_binder = computation.outer_exclusive_binder;
226if outer_exclusive_binder > ty::INNERMOST {
227self.add_exclusive_binder(outer_exclusive_binder.shifted_out(1));
228 } // otherwise, this binder captures nothing
229}
230231#[allow(rustc::usage_of_ty_tykind)]
232fn add_kind(&mut self, kind: &ty::TyKind<I>) {
233match *kind {
234 ty::Bool235 | ty::Char236 | ty::Int(_)
237 | ty::Float(_)
238 | ty::Uint(_)
239 | ty::Never240 | ty::Str241 | ty::Foreign(..) => {}
242243 ty::Error(_) => self.add_flags(TypeFlags::HAS_ERROR),
244245 ty::Param(_) => {
246self.add_flags(TypeFlags::HAS_TY_PARAM);
247 }
248249 ty::Closure(_, args)
250 | ty::CoroutineClosure(_, args)
251 | ty::CoroutineWitness(_, args) => {
252self.add_args(args.as_slice());
253 }
254255 ty::Coroutine(_, args) => {
256self.add_flags(TypeFlags::HAS_TY_CORO);
257self.add_args(args.as_slice());
258 }
259260 ty::Bound(ty::BoundVarIndexKind::Canonical, _) => {
261self.add_flags(TypeFlags::HAS_TY_BOUND);
262self.add_flags(TypeFlags::HAS_CANONICAL_BOUND);
263 }
264265 ty::Bound(ty::BoundVarIndexKind::Bound(debruijn), _) => {
266self.add_bound_var(debruijn);
267self.add_flags(TypeFlags::HAS_TY_BOUND);
268 }
269270 ty::Placeholder(..) => {
271self.add_flags(TypeFlags::HAS_TY_PLACEHOLDER);
272 }
273274 ty::Infer(infer) => match infer {
275 ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_) => {
276self.add_flags(TypeFlags::HAS_TY_FRESH)
277 }
278279 ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_) => {
280self.add_flags(TypeFlags::HAS_TY_INFER)
281 }
282 },
283284 ty::Adt(_, args) => {
285self.add_args(args.as_slice());
286 }
287288 ty::Alias(kind, data) => {
289self.add_flags(match kind {
290 ty::Projection => TypeFlags::HAS_TY_PROJECTION,
291 ty::Free => TypeFlags::HAS_TY_FREE_ALIAS,
292 ty::Opaque => TypeFlags::HAS_TY_OPAQUE,
293 ty::Inherent => TypeFlags::HAS_TY_INHERENT,
294 });
295296self.add_alias_ty(data);
297 }
298299 ty::Dynamic(obj, r) => {
300for predicate in obj.iter() {
301self.bound_computation(predicate, |computation, predicate| match predicate {
302 ty::ExistentialPredicate::Trait(tr) => {
303 computation.add_args(tr.args.as_slice())
304 }
305 ty::ExistentialPredicate::Projection(p) => {
306 computation.add_existential_projection(&p);
307 }
308 ty::ExistentialPredicate::AutoTrait(_) => {}
309 });
310 }
311312self.add_region(r);
313 }
314315 ty::Array(tt, len) => {
316self.add_ty(tt);
317self.add_const(len);
318 }
319320 ty::Pat(ty, pat) => {
321self.add_ty(ty);
322self.add_ty_pat(pat);
323 }
324325 ty::Slice(tt) => self.add_ty(tt),
326327 ty::RawPtr(ty, _) => {
328self.add_ty(ty);
329 }
330331 ty::Ref(r, ty, _) => {
332self.add_region(r);
333self.add_ty(ty);
334 }
335336 ty::Tuple(types) => {
337self.add_tys(types);
338 }
339340 ty::FnDef(_, args) => {
341self.add_args(args.as_slice());
342 }
343344 ty::FnPtr(sig_tys, _) => self.bound_computation(sig_tys, |computation, sig_tys| {
345computation.add_tys(sig_tys.inputs_and_output);
346 }),
347348 ty::UnsafeBinder(bound_ty) => {
349self.bound_computation(bound_ty.into(), |computation, ty| {
350computation.add_ty(ty);
351 })
352 }
353 }
354 }
355356fn add_ty_pat(&mut self, pat: <I as Interner>::Pat) {
357self.add_flags(pat.flags());
358self.add_exclusive_binder(pat.outer_exclusive_binder());
359 }
360361fn add_predicate(&mut self, binder: ty::Binder<I, ty::PredicateKind<I>>) {
362self.bound_computation(binder, |computation, atom| computation.add_predicate_atom(atom));
363 }
364365fn add_predicate_atom(&mut self, atom: ty::PredicateKind<I>) {
366match atom {
367 ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_pred)) => {
368self.add_args(trait_pred.trait_ref.args.as_slice());
369 }
370 ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(ty::HostEffectPredicate {
371 trait_ref,
372 constness: _,
373 })) => {
374self.add_args(trait_ref.args.as_slice());
375 }
376 ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(
377 a,
378 b,
379 ))) => {
380self.add_region(a);
381self.add_region(b);
382 }
383 ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(
384 ty,
385 region,
386 ))) => {
387self.add_ty(ty);
388self.add_region(region);
389 }
390 ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
391self.add_const(ct);
392self.add_ty(ty);
393 }
394 ty::PredicateKind::Subtype(ty::SubtypePredicate { a_is_expected: _, a, b }) => {
395self.add_ty(a);
396self.add_ty(b);
397 }
398 ty::PredicateKind::Coerce(ty::CoercePredicate { a, b }) => {
399self.add_ty(a);
400self.add_ty(b);
401 }
402 ty::PredicateKind::Clause(ty::ClauseKind::Projection(ty::ProjectionPredicate {
403 projection_term,
404 term,
405 })) => {
406self.add_alias_term(projection_term);
407self.add_term(term);
408 }
409 ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term)) => {
410self.add_term(term);
411 }
412 ty::PredicateKind::DynCompatible(_def_id) => {}
413 ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(uv)) => {
414self.add_const(uv);
415 }
416 ty::PredicateKind::ConstEquate(expected, found) => {
417self.add_const(expected);
418self.add_const(found);
419 }
420 ty::PredicateKind::NormalizesTo(ty::NormalizesTo { alias, term }) => {
421self.add_alias_term(alias);
422self.add_term(term);
423 }
424 ty::PredicateKind::AliasRelate(t1, t2, _) => {
425self.add_term(t1);
426self.add_term(t2);
427 }
428 ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(_sym)) => {}
429 ty::PredicateKind::Ambiguous => {}
430 }
431 }
432433fn add_ty(&mut self, ty: I::Ty) {
434self.add_flags(ty.flags());
435self.add_exclusive_binder(ty.outer_exclusive_binder());
436 }
437438fn add_tys(&mut self, tys: I::Tys) {
439for ty in tys.iter() {
440self.add_ty(ty);
441 }
442 }
443444fn add_region(&mut self, r: I::Region) {
445self.add_flags(r.flags());
446if let ty::ReBound(ty::BoundVarIndexKind::Bound(debruijn), _) = r.kind() {
447self.add_bound_var(debruijn);
448 }
449 }
450451fn add_const(&mut self, c: I::Const) {
452self.add_flags(c.flags());
453self.add_exclusive_binder(c.outer_exclusive_binder());
454 }
455456fn add_const_kind(&mut self, c: &ty::ConstKind<I>) {
457match *c {
458 ty::ConstKind::Unevaluated(uv) => {
459self.add_args(uv.args.as_slice());
460self.add_flags(TypeFlags::HAS_CT_PROJECTION);
461 }
462 ty::ConstKind::Infer(infer) => match infer {
463 ty::InferConst::Fresh(_) => self.add_flags(TypeFlags::HAS_CT_FRESH),
464 ty::InferConst::Var(_) => self.add_flags(TypeFlags::HAS_CT_INFER),
465 },
466 ty::ConstKind::Bound(ty::BoundVarIndexKind::Bound(debruijn), _) => {
467self.add_bound_var(debruijn);
468self.add_flags(TypeFlags::HAS_CT_BOUND);
469 }
470 ty::ConstKind::Bound(ty::BoundVarIndexKind::Canonical, _) => {
471self.add_flags(TypeFlags::HAS_CT_BOUND);
472self.add_flags(TypeFlags::HAS_CANONICAL_BOUND);
473 }
474 ty::ConstKind::Param(_) => {
475self.add_flags(TypeFlags::HAS_CT_PARAM);
476 }
477 ty::ConstKind::Placeholder(_) => {
478self.add_flags(TypeFlags::HAS_CT_PLACEHOLDER);
479 }
480 ty::ConstKind::Value(cv) => {
481self.add_ty(cv.ty());
482match cv.valtree().kind() {
483 ty::ValTreeKind::Leaf(_) => (),
484 ty::ValTreeKind::Branch(cts) => {
485for ct in cts {
486self.add_const(*ct);
487 }
488 }
489 }
490 }
491 ty::ConstKind::Expr(e) => self.add_args(e.args().as_slice()),
492 ty::ConstKind::Error(_) => self.add_flags(TypeFlags::HAS_ERROR),
493 }
494 }
495496fn add_existential_projection(&mut self, projection: &ty::ExistentialProjection<I>) {
497self.add_args(projection.args.as_slice());
498match projection.term.kind() {
499 ty::TermKind::Ty(ty) => self.add_ty(ty),
500 ty::TermKind::Const(ct) => self.add_const(ct),
501 }
502 }
503504fn add_alias_ty(&mut self, alias_ty: ty::AliasTy<I>) {
505self.add_args(alias_ty.args.as_slice());
506 }
507508fn add_alias_term(&mut self, alias_term: ty::AliasTerm<I>) {
509self.add_args(alias_term.args.as_slice());
510 }
511512fn add_args(&mut self, args: &[I::GenericArg]) {
513for arg in args {
514match arg.kind() {
515 ty::GenericArgKind::Type(ty) => self.add_ty(ty),
516 ty::GenericArgKind::Lifetime(lt) => self.add_region(lt),
517 ty::GenericArgKind::Const(ct) => self.add_const(ct),
518 }
519 }
520 }
521522fn add_term(&mut self, term: I::Term) {
523match term.kind() {
524 ty::TermKind::Ty(ty) => self.add_ty(ty),
525 ty::TermKind::Const(ct) => self.add_const(ct),
526 }
527 }
528}