1use crate::inherent::*;
2use crate::visit::Flags;
3use crate::{selfas ty, Const, Interner, Region};
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]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_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: &Self) -> bool { self.0 == other.0 }
}
#[automatically_derived]impl ::core::cmp::Eq for TypeFlags {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_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]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
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::Alias`?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_CONST_ALIAS: Self = Self::from_bits_retain(1 << 14);
#[doc = r" Does this have `Alias` or `ConstKind::Alias`?"]
#[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_CONST_ALIAS.bits());
#[doc = r" Is a type or const error reachable?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_NON_REGION_ERROR: Self = Self::from_bits_retain(1 << 15);
#[doc = r" Is a region error reachable?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_RE_ERROR: Self = Self::from_bits_retain(1 << 16);
#[doc = r" Is an error type/lifetime/const reachable?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_ERROR: Self =
Self::from_bits_retain(TypeFlags::HAS_NON_REGION_ERROR.bits() |
TypeFlags::HAS_RE_ERROR.bits());
#[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 << 17);
#[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 << 18);
#[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 << 19);
#[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 << 20);
#[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 << 21);
#[doc = r" Does this have any regions of any kind?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_REGIONS: Self =
Self::from_bits_retain(TypeFlags::HAS_FREE_REGIONS.bits() |
TypeFlags::HAS_RE_BOUND.bits() |
TypeFlags::HAS_RE_ERASED.bits());
#[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 << 22);
#[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 << 23);
#[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 << 24);
#[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 << 25);
#[doc = r" Does this have a `Bound(BoundVarIndexKind::Canonical, _)`?"]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_CANONICAL_BOUND: Self = Self::from_bits_retain(1 << 26);
#[doc = r" Does this have any aliases with `IsRigid::Yes`?"]
#[doc = r""]
#[doc =
r" We have both rigid and non-rigid flags because both can be true for a single"]
#[doc =
r" subject. E.g. one arg is rigid while another is non-rigid for some ADTs."]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_RIGID_ALIAS: Self = Self::from_bits_retain(1 << 27);
#[doc = r" Does this have any aliases with `IsRigid::No`?"]
#[doc = r""]
#[doc =
r" We have a separate flag from `HAS_ALIAS` because `HAS_ALIAS` doesn't care"]
#[doc =
r" about rigidness while we rely on rigidness to skip renormalization."]
#[allow(deprecated, non_upper_case_globals,)]
pub const HAS_NON_RIGID_ALIAS: Self = Self::from_bits_retain(1 << 28);
}
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_CONST_ALIAS",
TypeFlags::HAS_CONST_ALIAS)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_ALIAS", TypeFlags::HAS_ALIAS)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_NON_REGION_ERROR",
TypeFlags::HAS_NON_REGION_ERROR)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_RE_ERROR",
TypeFlags::HAS_RE_ERROR)
},
{
#[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("HAS_REGIONS", TypeFlags::HAS_REGIONS)
},
{
#[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)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_RIGID_ALIAS",
TypeFlags::HAS_RIGID_ALIAS)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("HAS_NON_RIGID_ALIAS",
TypeFlags::HAS_NON_RIGID_ALIAS)
}];
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]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
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: &Self) -> bool { self.0 == other.0 }
}
#[automatically_derived]
impl ::core::cmp::Eq for InternalBitFlags {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<u32>;
}
}
#[automatically_derived]
impl ::core::cmp::PartialOrd for InternalBitFlags {
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self,
other))
}
}
#[automatically_derived]
impl ::core::cmp::Ord for InternalBitFlags {
#[inline]
fn cmp(&self, other: &Self) -> ::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 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_CONST_ALIAS" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_CONST_ALIAS.bits()));
}
};
;
{
if name == "HAS_ALIAS" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_ALIAS.bits()));
}
};
;
{
if name == "HAS_NON_REGION_ERROR" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_NON_REGION_ERROR.bits()));
}
};
;
{
if name == "HAS_RE_ERROR" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_RE_ERROR.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 == "HAS_REGIONS" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_REGIONS.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()));
}
};
;
{
if name == "HAS_RIGID_ALIAS" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_RIGID_ALIAS.bits()));
}
};
;
{
if name == "HAS_NON_RIGID_ALIAS" {
return ::bitflags::__private::core::option::Option::Some(Self(TypeFlags::HAS_NON_RIGID_ALIAS.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::Alias`?
83const HAS_CONST_ALIAS = 1 << 14;
8485/// Does this have `Alias` or `ConstKind::Alias`?
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_CONST_ALIAS.bits();
9394/// Is a type or const error reachable?
95const HAS_NON_REGION_ERROR = 1 << 15;
96/// Is a region error reachable?
97const HAS_RE_ERROR = 1 << 16;
98/// Is an error type/lifetime/const reachable?
99const HAS_ERROR = TypeFlags::HAS_NON_REGION_ERROR.bits()
100 | TypeFlags::HAS_RE_ERROR.bits();
101102/// Does this have any region that "appears free" in the type?
103 /// Basically anything but `ReBound` and `ReErased`.
104const HAS_FREE_REGIONS = 1 << 17;
105106/// Does this have any `ReBound` regions?
107const HAS_RE_BOUND = 1 << 18;
108/// Does this have any `Bound` types?
109const HAS_TY_BOUND = 1 << 19;
110/// Does this have any `ConstKind::Bound` consts?
111const HAS_CT_BOUND = 1 << 20;
112/// Does this have any bound variables?
113 /// Used to check if a global bound is safe to evaluate.
114const HAS_BOUND_VARS = TypeFlags::HAS_RE_BOUND.bits()
115 | TypeFlags::HAS_TY_BOUND.bits()
116 | TypeFlags::HAS_CT_BOUND.bits();
117118/// Does this have any `ReErased` regions?
119const HAS_RE_ERASED = 1 << 21;
120121/// Does this have any regions of any kind?
122const HAS_REGIONS = TypeFlags::HAS_FREE_REGIONS.bits()
123 | TypeFlags::HAS_RE_BOUND.bits()
124 | TypeFlags::HAS_RE_ERASED.bits();
125126/// Does this value have parameters/placeholders/inference variables which could be
127 /// replaced later, in a way that would change the results of `impl` specialization?
128const STILL_FURTHER_SPECIALIZABLE = TypeFlags::HAS_TY_PARAM.bits()
129 | TypeFlags::HAS_TY_PLACEHOLDER.bits()
130 | TypeFlags::HAS_TY_INFER.bits()
131 | TypeFlags::HAS_CT_PARAM.bits()
132 | TypeFlags::HAS_CT_PLACEHOLDER.bits()
133 | TypeFlags::HAS_CT_INFER.bits();
134135/// Does this value have `InferTy::FreshTy/FreshIntTy/FreshFloatTy`?
136const HAS_TY_FRESH = 1 << 22;
137138/// Does this value have `InferConst::Fresh`?
139const HAS_CT_FRESH = 1 << 23;
140141/// Does this have any binders with bound vars (e.g. that need to be anonymized)?
142const HAS_BINDER_VARS = 1 << 24;
143144/// Does this type have any coroutines in it?
145const HAS_TY_CORO = 1 << 25;
146147/// Does this have a `Bound(BoundVarIndexKind::Canonical, _)`?
148const HAS_CANONICAL_BOUND = 1 << 26;
149150/// Does this have any aliases with `IsRigid::Yes`?
151 ///
152 /// We have both rigid and non-rigid flags because both can be true for a single
153 /// subject. E.g. one arg is rigid while another is non-rigid for some ADTs.
154const HAS_RIGID_ALIAS = 1 << 27;
155156/// Does this have any aliases with `IsRigid::No`?
157 ///
158 /// We have a separate flag from `HAS_ALIAS` because `HAS_ALIAS` doesn't care
159 /// about rigidness while we rely on rigidness to skip renormalization.
160const HAS_NON_RIGID_ALIAS = 1 << 28;
161 }
162}163164#[derive(#[automatically_derived]impl<I: ::core::fmt::Debug> ::core::fmt::Debug for
FlagComputation<I> {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"FlagComputation flags outer_exclusive_binder interner",
&self.flags, &self.outer_exclusive_binder, &&self.interner)
}
}Debug)]
165pub struct FlagComputation<I> {
166pub flags: TypeFlags,
167168/// see `Ty::outer_exclusive_binder` for details
169pub outer_exclusive_binder: ty::DebruijnIndex,
170171 interner: std::marker::PhantomData<I>,
172}
173174impl<I: Interner> FlagComputation<I> {
175fn new() -> FlagComputation<I> {
176FlagComputation {
177 flags: TypeFlags::empty(),
178 outer_exclusive_binder: ty::INNERMOST,
179 interner: std::marker::PhantomData,
180 }
181 }
182183#[allow(rustc::usage_of_ty_tykind)]
184pub fn for_kind(kind: &ty::TyKind<I>) -> FlagComputation<I> {
185match *kind {
186 ty::Bool187 | ty::Char188 | ty::Int(_)
189 | ty::Float(_)
190 | ty::Uint(_)
191 | ty::Never192 | ty::Str193 | ty::Foreign(..) => Self::new(),
194 ty::Error(_) => Self::for_flags(TypeFlags::HAS_NON_REGION_ERROR),
195 ty::Param(_) => Self::for_flags(TypeFlags::HAS_TY_PARAM),
196 ty::Placeholder(..) => Self::for_flags(TypeFlags::HAS_TY_PLACEHOLDER),
197 ty::Closure(_, args)
198 | ty::CoroutineClosure(_, args)
199 | ty::CoroutineWitness(_, args)
200 | ty::Adt(_, args) => Self::for_args(args),
201 ty::Coroutine(_, args) => Self::for_coroutine(args),
202 ty::Bound(index, _) => Self::for_bound(index),
203 ty::Infer(infer) => Self::for_infer(infer),
204 ty::Alias(is_rigid, alias) => Self::for_alias(is_rigid, alias),
205 ty::Dynamic(obj, region) => Self::for_dynamic(obj, region),
206 ty::Array(ty, len) => Self::for_array(ty, len),
207 ty::Pat(ty, pat) => Self::for_pat(ty, pat),
208 ty::Slice(ty) | ty::RawPtr(ty, _) => Self::for_ty(ty),
209 ty::Ref(region, ty, _) => Self::for_ref(region, ty),
210 ty::Tuple(types) => Self::for_tys(types),
211 ty::FnDef(_, args) => Self::for_fn_def(args),
212 ty::FnPtr(sig_tys, _) => Self::for_fn_ptr(sig_tys),
213 ty::UnsafeBinder(bound_ty) => Self::for_unsafe_binder(bound_ty),
214 ty::View(_, args, fields) => Self::for_view(args, fields),
215 }
216 }
217218pub fn for_view(args: I::GenericArgs, fields: I::Ty) -> FlagComputation<I> {
219let mut result = FlagComputation::new();
220result.add_args(args.as_slice());
221result.add_ty(fields);
222result223 }
224225pub fn for_predicate(binder: ty::Binder<I, ty::PredicateKind<I>>) -> FlagComputation<I> {
226let mut result = FlagComputation::new();
227result.add_predicate(binder);
228result229 }
230231pub fn for_const_kind(kind: &ty::ConstKind<I>) -> FlagComputation<I> {
232let mut result = FlagComputation::new();
233result.add_const_kind(kind);
234result235 }
236237pub fn for_clauses(clauses: &[I::Clause]) -> FlagComputation<I> {
238let mut result = FlagComputation::new();
239for c in clauses {
240 result.add_flags(c.flags());
241 result.add_exclusive_binder(c.outer_exclusive_binder());
242 }
243result244 }
245246fn add_flags(&mut self, flags: TypeFlags) {
247self.flags |= flags;
248 }
249250/// indicates that `self` refers to something at binding level `binder`
251fn add_bound_var(&mut self, binder: ty::DebruijnIndex) {
252let exclusive_binder = binder.shifted_in(1);
253self.add_exclusive_binder(exclusive_binder);
254 }
255256/// indicates that `self` refers to something *inside* binding
257 /// level `binder` -- not bound by `binder`, but bound by the next
258 /// binder internal to it
259fn add_exclusive_binder(&mut self, exclusive_binder: ty::DebruijnIndex) {
260self.outer_exclusive_binder = self.outer_exclusive_binder.max(exclusive_binder);
261 }
262263/// Adds the flags/depth from a set of types that appear within the current type, but within a
264 /// region binder.
265fn bound_computation<T, F>(&mut self, value: ty::Binder<I, T>, f: F)
266where
267F: FnOnce(&mut Self, T),
268 {
269let mut computation = FlagComputation::new();
270271if !value.bound_vars().is_empty() {
272computation.add_flags(TypeFlags::HAS_BINDER_VARS);
273 }
274275f(&mut computation, value.skip_binder());
276277self.add_flags(computation.flags);
278279// The types that contributed to `computation` occurred within
280 // a region binder, so subtract one from the region depth
281 // within when adding the depth to `self`.
282let outer_exclusive_binder = computation.outer_exclusive_binder;
283if outer_exclusive_binder > ty::INNERMOST {
284self.add_exclusive_binder(outer_exclusive_binder.shifted_out(1));
285 } // otherwise, this binder captures nothing
286}
287288/// Flags for a type with no nested types, constants, regions, or binders.
289pub fn for_flags(flags: TypeFlags) -> Self {
290Self { flags, ..Self::new() }
291 }
292293pub fn for_args(args: I::GenericArgs) -> Self {
294let mut result = Self::new();
295result.add_args(args.as_slice());
296result297 }
298299pub fn for_coroutine(args: I::GenericArgs) -> Self {
300let mut result = Self::for_args(args);
301result.add_flags(TypeFlags::HAS_TY_CORO);
302result303 }
304305pub fn for_bound(index: ty::BoundVarIndexKind) -> Self {
306let mut result = Self::for_flags(TypeFlags::HAS_TY_BOUND);
307match index {
308 ty::BoundVarIndexKind::Canonical => result.add_flags(TypeFlags::HAS_CANONICAL_BOUND),
309 ty::BoundVarIndexKind::Bound(debruijn) => result.add_bound_var(debruijn),
310 }
311312result313 }
314315pub fn for_infer(infer: ty::InferTy) -> Self {
316Self::for_flags(match infer {
317 ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_) => TypeFlags::HAS_TY_FRESH,
318 ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_) => TypeFlags::HAS_TY_INFER,
319 })
320 }
321322pub fn for_alias(is_rigid: ty::IsRigid, alias: ty::AliasTy<I>) -> Self {
323let mut result = Self::new();
324result.add_is_rigid(is_rigid);
325result.add_flags(match alias.kind {
326 ty::Projection { .. } => TypeFlags::HAS_TY_PROJECTION,
327 ty::Free { .. } => TypeFlags::HAS_TY_FREE_ALIAS,
328 ty::Opaque { .. } => TypeFlags::HAS_TY_OPAQUE,
329 ty::Inherent { .. } => TypeFlags::HAS_TY_INHERENT,
330 });
331result.add_alias_ty(alias);
332result333 }
334335pub fn for_dynamic(obj: I::BoundExistentialPredicates, region: Region<I>) -> Self {
336let mut result = Self::new();
337for predicate in obj.iter() {
338 result.bound_computation(predicate, |computation, predicate| match predicate {
339 ty::ExistentialPredicate::Trait(tr) => computation.add_args(tr.args.as_slice()),
340 ty::ExistentialPredicate::Projection(p) => {
341 computation.add_existential_projection(&p)
342 }
343 ty::ExistentialPredicate::AutoTrait(_) => {}
344 });
345 }
346result.add_region(region);
347result348 }
349350pub fn for_array(ty: I::Ty, len: Const<I>) -> Self {
351let mut result = Self::for_ty(ty);
352result.add_const(len);
353result354 }
355356pub fn for_pat(ty: I::Ty, pat: I::Pat) -> Self {
357let mut result = Self::for_ty(ty);
358result.add_ty_pat(pat);
359result360 }
361362pub fn for_ty(ty: I::Ty) -> Self {
363let mut result = Self::new();
364result.add_ty(ty);
365result366 }
367368pub fn for_ref(region: Region<I>, ty: I::Ty) -> Self {
369let mut result = Self::new();
370result.add_region(region);
371result.add_ty(ty);
372result373 }
374375pub fn for_tys(types: I::Tys) -> Self {
376let mut result = Self::new();
377result.add_tys(types);
378result379 }
380381pub fn for_fn_def(args: ty::Binder<I, I::GenericArgs>) -> Self {
382let mut result = Self::new();
383result.add_binder_args(args);
384result385 }
386387pub fn for_fn_ptr(sig_tys: ty::Binder<I, ty::FnSigTys<I>>) -> Self {
388let mut result = Self::new();
389result.bound_computation(sig_tys, |computation, sig_tys| {
390computation.add_tys(sig_tys.inputs_and_output);
391 });
392result393 }
394395pub fn for_unsafe_binder(bound_ty: ty::UnsafeBinderInner<I>) -> Self {
396let mut result = Self::new();
397result.bound_computation(bound_ty.into(), |computation, ty| {
398computation.add_ty(ty);
399 });
400result401 }
402403fn add_ty_pat(&mut self, pat: <I as Interner>::Pat) {
404self.add_flags(pat.flags());
405self.add_exclusive_binder(pat.outer_exclusive_binder());
406 }
407408fn add_predicate(&mut self, binder: ty::Binder<I, ty::PredicateKind<I>>) {
409self.bound_computation(binder, |computation, atom| computation.add_predicate_atom(atom));
410 }
411412fn add_predicate_atom(&mut self, atom: ty::PredicateKind<I>) {
413match atom {
414 ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_pred)) => {
415self.add_args(trait_pred.trait_ref.args.as_slice());
416 }
417 ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(ty::HostEffectClause {
418 trait_ref,
419 constness: _,
420 })) => {
421self.add_args(trait_ref.args.as_slice());
422 }
423 ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(ty::OutlivesClause(a, b))) => {
424self.add_region(a);
425self.add_region(b);
426 }
427 ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(ty::OutlivesClause(
428 ty,
429 region,
430 ))) => {
431self.add_ty(ty);
432self.add_region(region);
433 }
434 ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
435self.add_const(ct);
436self.add_ty(ty);
437 }
438 ty::PredicateKind::Subtype(ty::SubtypePredicate { a_is_expected: _, a, b }) => {
439self.add_ty(a);
440self.add_ty(b);
441 }
442 ty::PredicateKind::Coerce(ty::CoercePredicate { a, b }) => {
443self.add_ty(a);
444self.add_ty(b);
445 }
446 ty::PredicateKind::Clause(ty::ClauseKind::Projection(ty::ProjectionClause {
447 projection_term,
448 term,
449 })) => {
450self.add_alias_term(projection_term);
451self.add_term(term);
452 }
453 ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term)) => {
454self.add_term(term);
455 }
456 ty::PredicateKind::DynCompatible(_def_id) => {}
457 ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(alias_const)) => {
458self.add_const(alias_const);
459 }
460 ty::PredicateKind::ConstEquate(expected, found) => {
461self.add_const(expected);
462self.add_const(found);
463 }
464 ty::PredicateKind::NormalizesTo(ty::NormalizesTo { alias, term }) => {
465self.add_alias_term(alias);
466self.add_term(term);
467 }
468 ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(_sym)) => {}
469 ty::PredicateKind::Ambiguous => {}
470471 ty::PredicateKind::Clause(ty::ClauseKind::CompressedTrait(c)) => {
472// NOTE: this is correct as long as compressed trait clauses represent trait clauses
473 // that don't have generic parameters other than the self_ty, in which case only computing
474 // flags of the self_ty is correct.
475self.add_args(c.self_ty.as_slice());
476 }
477 }
478 }
479480fn add_ty(&mut self, ty: I::Ty) {
481self.add_flags(ty.flags());
482self.add_exclusive_binder(ty.outer_exclusive_binder());
483 }
484485fn add_tys(&mut self, tys: I::Tys) {
486for ty in tys.iter() {
487self.add_ty(ty);
488 }
489 }
490491fn add_region(&mut self, r: Region<I>) {
492self.add_flags(r.flags());
493if let ty::ReBound(ty::BoundVarIndexKind::Bound(debruijn), _) = r.kind() {
494self.add_bound_var(debruijn);
495 }
496 }
497498fn add_const(&mut self, c: Const<I>) {
499self.add_flags(c.flags());
500self.add_exclusive_binder(c.outer_exclusive_binder());
501 }
502503fn add_const_kind(&mut self, c: &ty::ConstKind<I>) {
504match *c {
505 ty::ConstKind::Alias(is_rigid, alias_const) => {
506self.add_is_rigid(is_rigid);
507self.add_args(alias_const.args.as_slice());
508self.add_flags(TypeFlags::HAS_CONST_ALIAS);
509 }
510 ty::ConstKind::Infer(infer) => match infer {
511 ty::InferConst::Fresh(_) => self.add_flags(TypeFlags::HAS_CT_FRESH),
512 ty::InferConst::Var(_) => self.add_flags(TypeFlags::HAS_CT_INFER),
513 },
514 ty::ConstKind::Bound(ty::BoundVarIndexKind::Bound(debruijn), _) => {
515self.add_bound_var(debruijn);
516self.add_flags(TypeFlags::HAS_CT_BOUND);
517 }
518 ty::ConstKind::Bound(ty::BoundVarIndexKind::Canonical, _) => {
519self.add_flags(TypeFlags::HAS_CT_BOUND);
520self.add_flags(TypeFlags::HAS_CANONICAL_BOUND);
521 }
522 ty::ConstKind::Param(_) => {
523self.add_flags(TypeFlags::HAS_CT_PARAM);
524 }
525 ty::ConstKind::Placeholder(_) => {
526self.add_flags(TypeFlags::HAS_CT_PLACEHOLDER);
527 }
528 ty::ConstKind::Value(cv) => {
529self.add_ty(cv.ty());
530match cv.valtree().kind() {
531 ty::ValTreeKind::Leaf(_) => (),
532 ty::ValTreeKind::Branch(cts) => {
533for ct in cts.iter() {
534self.add_const(ct);
535 }
536 }
537 }
538 }
539 ty::ConstKind::Expr(e) => self.add_args(e.args().as_slice()),
540 ty::ConstKind::Error(_) => self.add_flags(TypeFlags::HAS_NON_REGION_ERROR),
541 }
542 }
543544fn add_existential_projection(&mut self, projection: &ty::ExistentialProjection<I>) {
545self.add_args(projection.args.as_slice());
546match projection.term.kind() {
547 ty::TermKind::Ty(ty) => self.add_ty(ty),
548 ty::TermKind::Const(ct) => self.add_const(ct),
549 }
550 }
551552fn add_alias_ty(&mut self, alias_ty: ty::AliasTy<I>) {
553self.add_args(alias_ty.args.as_slice());
554 }
555556fn add_alias_term(&mut self, alias_term: ty::AliasTerm<I>) {
557self.add_args(alias_term.args.as_slice());
558 }
559560fn add_args(&mut self, args: &[I::GenericArg]) {
561for arg in args {
562match arg.kind() {
563 ty::GenericArgKind::Type(ty) => self.add_ty(ty),
564 ty::GenericArgKind::Lifetime(lt) => self.add_region(lt),
565 ty::GenericArgKind::Const(ct) => self.add_const(ct),
566 }
567 }
568 }
569570fn add_binder_args(&mut self, args: ty::Binder<I, I::GenericArgs>) {
571self.bound_computation(args, |this, args| {
572for arg in args.iter() {
573match arg.kind() {
574 ty::GenericArgKind::Type(ty) => this.add_ty(ty),
575 ty::GenericArgKind::Lifetime(r) => this.add_region(r),
576 ty::GenericArgKind::Const(ct) => this.add_const(ct),
577 }
578 }
579 });
580 }
581582fn add_is_rigid(&mut self, is_rigid: ty::IsRigid) {
583match is_rigid {
584 ty::IsRigid::Yes => self.add_flags(TypeFlags::HAS_RIGID_ALIAS),
585 ty::IsRigid::No => self.add_flags(TypeFlags::HAS_NON_RIGID_ALIAS),
586 }
587 }
588589fn add_term(&mut self, term: I::Term) {
590match term.kind() {
591 ty::TermKind::Ty(ty) => self.add_ty(ty),
592 ty::TermKind::Const(ct) => self.add_const(ct),
593 }
594 }
595}