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_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]
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::Alias`?"]
#[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::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_CT_PROJECTION.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_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_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]
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_fields_are_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::option::Option::Some(::core::cmp::Ord::cmp(self,
other))
}
}
#[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 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_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_CT_PROJECTION = 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_CT_PROJECTION.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]
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)]
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> {
185let mut result = FlagComputation::new();
186result.add_kind(kind);
187result188 }
189190pub fn for_predicate(binder: ty::Binder<I, ty::PredicateKind<I>>) -> FlagComputation<I> {
191let mut result = FlagComputation::new();
192result.add_predicate(binder);
193result194 }
195196pub fn for_const_kind(kind: &ty::ConstKind<I>) -> FlagComputation<I> {
197let mut result = FlagComputation::new();
198result.add_const_kind(kind);
199result200 }
201202pub fn for_clauses(clauses: &[I::Clause]) -> FlagComputation<I> {
203let mut result = FlagComputation::new();
204for c in clauses {
205 result.add_flags(c.as_predicate().flags());
206 result.add_exclusive_binder(c.as_predicate().outer_exclusive_binder());
207 }
208result209 }
210211fn add_flags(&mut self, flags: TypeFlags) {
212self.flags |= flags;
213 }
214215/// indicates that `self` refers to something at binding level `binder`
216fn add_bound_var(&mut self, binder: ty::DebruijnIndex) {
217let exclusive_binder = binder.shifted_in(1);
218self.add_exclusive_binder(exclusive_binder);
219 }
220221/// indicates that `self` refers to something *inside* binding
222 /// level `binder` -- not bound by `binder`, but bound by the next
223 /// binder internal to it
224fn add_exclusive_binder(&mut self, exclusive_binder: ty::DebruijnIndex) {
225self.outer_exclusive_binder = self.outer_exclusive_binder.max(exclusive_binder);
226 }
227228/// Adds the flags/depth from a set of types that appear within the current type, but within a
229 /// region binder.
230fn bound_computation<T, F>(&mut self, value: ty::Binder<I, T>, f: F)
231where
232F: FnOnce(&mut Self, T),
233 {
234let mut computation = FlagComputation::new();
235236if !value.bound_vars().is_empty() {
237computation.add_flags(TypeFlags::HAS_BINDER_VARS);
238 }
239240f(&mut computation, value.skip_binder());
241242self.add_flags(computation.flags);
243244// The types that contributed to `computation` occurred within
245 // a region binder, so subtract one from the region depth
246 // within when adding the depth to `self`.
247let outer_exclusive_binder = computation.outer_exclusive_binder;
248if outer_exclusive_binder > ty::INNERMOST {
249self.add_exclusive_binder(outer_exclusive_binder.shifted_out(1));
250 } // otherwise, this binder captures nothing
251}
252253#[allow(rustc::usage_of_ty_tykind)]
254fn add_kind(&mut self, kind: &ty::TyKind<I>) {
255match *kind {
256 ty::Bool257 | ty::Char258 | ty::Int(_)
259 | ty::Float(_)
260 | ty::Uint(_)
261 | ty::Never262 | ty::Str263 | ty::Foreign(..) => {}
264265 ty::Error(_) => self.add_flags(TypeFlags::HAS_NON_REGION_ERROR),
266267 ty::Param(_) => {
268self.add_flags(TypeFlags::HAS_TY_PARAM);
269 }
270271 ty::Closure(_, args)
272 | ty::CoroutineClosure(_, args)
273 | ty::CoroutineWitness(_, args) => {
274self.add_args(args.as_slice());
275 }
276277 ty::Coroutine(_, args) => {
278self.add_flags(TypeFlags::HAS_TY_CORO);
279self.add_args(args.as_slice());
280 }
281282 ty::Bound(ty::BoundVarIndexKind::Canonical, _) => {
283self.add_flags(TypeFlags::HAS_TY_BOUND);
284self.add_flags(TypeFlags::HAS_CANONICAL_BOUND);
285 }
286287 ty::Bound(ty::BoundVarIndexKind::Bound(debruijn), _) => {
288self.add_bound_var(debruijn);
289self.add_flags(TypeFlags::HAS_TY_BOUND);
290 }
291292 ty::Placeholder(..) => {
293self.add_flags(TypeFlags::HAS_TY_PLACEHOLDER);
294 }
295296 ty::Infer(infer) => match infer {
297 ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_) => {
298self.add_flags(TypeFlags::HAS_TY_FRESH)
299 }
300301 ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_) => {
302self.add_flags(TypeFlags::HAS_TY_INFER)
303 }
304 },
305306 ty::Adt(_, args) => {
307self.add_args(args.as_slice());
308 }
309310 ty::Alias(is_rigid, alias) => {
311self.add_is_rigid(is_rigid);
312self.add_flags(match alias.kind {
313 ty::Projection { .. } => TypeFlags::HAS_TY_PROJECTION,
314 ty::Free { .. } => TypeFlags::HAS_TY_FREE_ALIAS,
315 ty::Opaque { .. } => TypeFlags::HAS_TY_OPAQUE,
316 ty::Inherent { .. } => TypeFlags::HAS_TY_INHERENT,
317 });
318self.add_alias_ty(alias);
319 }
320321 ty::Dynamic(obj, r) => {
322for predicate in obj.iter() {
323self.bound_computation(predicate, |computation, predicate| match predicate {
324 ty::ExistentialPredicate::Trait(tr) => {
325 computation.add_args(tr.args.as_slice())
326 }
327 ty::ExistentialPredicate::Projection(p) => {
328 computation.add_existential_projection(&p);
329 }
330 ty::ExistentialPredicate::AutoTrait(_) => {}
331 });
332 }
333334self.add_region(r);
335 }
336337 ty::Array(tt, len) => {
338self.add_ty(tt);
339self.add_const(len);
340 }
341342 ty::Pat(ty, pat) => {
343self.add_ty(ty);
344self.add_ty_pat(pat);
345 }
346347 ty::Slice(tt) => self.add_ty(tt),
348349 ty::RawPtr(ty, _) => {
350self.add_ty(ty);
351 }
352353 ty::Ref(r, ty, _) => {
354self.add_region(r);
355self.add_ty(ty);
356 }
357358 ty::Tuple(types) => {
359self.add_tys(types);
360 }
361362 ty::FnDef(_, args) => {
363self.add_args(args.as_slice());
364 }
365366 ty::FnPtr(sig_tys, _) => self.bound_computation(sig_tys, |computation, sig_tys| {
367computation.add_tys(sig_tys.inputs_and_output);
368 }),
369370 ty::UnsafeBinder(bound_ty) => {
371self.bound_computation(bound_ty.into(), |computation, ty| {
372computation.add_ty(ty);
373 })
374 }
375 }
376 }
377378fn add_ty_pat(&mut self, pat: <I as Interner>::Pat) {
379self.add_flags(pat.flags());
380self.add_exclusive_binder(pat.outer_exclusive_binder());
381 }
382383fn add_predicate(&mut self, binder: ty::Binder<I, ty::PredicateKind<I>>) {
384self.bound_computation(binder, |computation, atom| computation.add_predicate_atom(atom));
385 }
386387fn add_predicate_atom(&mut self, atom: ty::PredicateKind<I>) {
388match atom {
389 ty::PredicateKind::Clause(ty::ClauseKind::Trait(trait_pred)) => {
390self.add_args(trait_pred.trait_ref.args.as_slice());
391 }
392 ty::PredicateKind::Clause(ty::ClauseKind::HostEffect(ty::HostEffectPredicate {
393 trait_ref,
394 constness: _,
395 })) => {
396self.add_args(trait_ref.args.as_slice());
397 }
398 ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(
399 a,
400 b,
401 ))) => {
402self.add_region(a);
403self.add_region(b);
404 }
405 ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(
406 ty,
407 region,
408 ))) => {
409self.add_ty(ty);
410self.add_region(region);
411 }
412 ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
413self.add_const(ct);
414self.add_ty(ty);
415 }
416 ty::PredicateKind::Subtype(ty::SubtypePredicate { a_is_expected: _, a, b }) => {
417self.add_ty(a);
418self.add_ty(b);
419 }
420 ty::PredicateKind::Coerce(ty::CoercePredicate { a, b }) => {
421self.add_ty(a);
422self.add_ty(b);
423 }
424 ty::PredicateKind::Clause(ty::ClauseKind::Projection(ty::ProjectionPredicate {
425 projection_term,
426 term,
427 })) => {
428self.add_alias_term(projection_term);
429self.add_term(term);
430 }
431 ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(term)) => {
432self.add_term(term);
433 }
434 ty::PredicateKind::DynCompatible(_def_id) => {}
435 ty::PredicateKind::Clause(ty::ClauseKind::ConstEvaluatable(alias_const)) => {
436self.add_const(alias_const);
437 }
438 ty::PredicateKind::ConstEquate(expected, found) => {
439self.add_const(expected);
440self.add_const(found);
441 }
442 ty::PredicateKind::NormalizesTo(ty::NormalizesTo { alias, term }) => {
443self.add_alias_term(alias);
444self.add_term(term);
445 }
446 ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(_sym)) => {}
447 ty::PredicateKind::Ambiguous => {}
448 }
449 }
450451fn add_ty(&mut self, ty: I::Ty) {
452self.add_flags(ty.flags());
453self.add_exclusive_binder(ty.outer_exclusive_binder());
454 }
455456fn add_tys(&mut self, tys: I::Tys) {
457for ty in tys.iter() {
458self.add_ty(ty);
459 }
460 }
461462fn add_region(&mut self, r: I::Region) {
463self.add_flags(r.flags());
464if let ty::ReBound(ty::BoundVarIndexKind::Bound(debruijn), _) = r.kind() {
465self.add_bound_var(debruijn);
466 }
467 }
468469fn add_const(&mut self, c: I::Const) {
470self.add_flags(c.flags());
471self.add_exclusive_binder(c.outer_exclusive_binder());
472 }
473474fn add_const_kind(&mut self, c: &ty::ConstKind<I>) {
475match *c {
476 ty::ConstKind::Alias(is_rigid, alias_const) => {
477self.add_is_rigid(is_rigid);
478self.add_args(alias_const.args.as_slice());
479self.add_flags(TypeFlags::HAS_CT_PROJECTION);
480 }
481 ty::ConstKind::Infer(infer) => match infer {
482 ty::InferConst::Fresh(_) => self.add_flags(TypeFlags::HAS_CT_FRESH),
483 ty::InferConst::Var(_) => self.add_flags(TypeFlags::HAS_CT_INFER),
484 },
485 ty::ConstKind::Bound(ty::BoundVarIndexKind::Bound(debruijn), _) => {
486self.add_bound_var(debruijn);
487self.add_flags(TypeFlags::HAS_CT_BOUND);
488 }
489 ty::ConstKind::Bound(ty::BoundVarIndexKind::Canonical, _) => {
490self.add_flags(TypeFlags::HAS_CT_BOUND);
491self.add_flags(TypeFlags::HAS_CANONICAL_BOUND);
492 }
493 ty::ConstKind::Param(_) => {
494self.add_flags(TypeFlags::HAS_CT_PARAM);
495 }
496 ty::ConstKind::Placeholder(_) => {
497self.add_flags(TypeFlags::HAS_CT_PLACEHOLDER);
498 }
499 ty::ConstKind::Value(cv) => {
500self.add_ty(cv.ty());
501match cv.valtree().kind() {
502 ty::ValTreeKind::Leaf(_) => (),
503 ty::ValTreeKind::Branch(cts) => {
504for ct in cts.iter() {
505self.add_const(ct);
506 }
507 }
508 }
509 }
510 ty::ConstKind::Expr(e) => self.add_args(e.args().as_slice()),
511 ty::ConstKind::Error(_) => self.add_flags(TypeFlags::HAS_NON_REGION_ERROR),
512 }
513 }
514515fn add_existential_projection(&mut self, projection: &ty::ExistentialProjection<I>) {
516self.add_args(projection.args.as_slice());
517match projection.term.kind() {
518 ty::TermKind::Ty(ty) => self.add_ty(ty),
519 ty::TermKind::Const(ct) => self.add_const(ct),
520 }
521 }
522523fn add_alias_ty(&mut self, alias_ty: ty::AliasTy<I>) {
524self.add_args(alias_ty.args.as_slice());
525 }
526527fn add_alias_term(&mut self, alias_term: ty::AliasTerm<I>) {
528self.add_args(alias_term.args.as_slice());
529 }
530531fn add_args(&mut self, args: &[I::GenericArg]) {
532for arg in args {
533match arg.kind() {
534 ty::GenericArgKind::Type(ty) => self.add_ty(ty),
535 ty::GenericArgKind::Lifetime(lt) => self.add_region(lt),
536 ty::GenericArgKind::Const(ct) => self.add_const(ct),
537 }
538 }
539 }
540541fn add_is_rigid(&mut self, is_rigid: ty::IsRigid) {
542match is_rigid {
543 ty::IsRigid::Yes => self.add_flags(TypeFlags::HAS_RIGID_ALIAS),
544 ty::IsRigid::No => self.add_flags(TypeFlags::HAS_NON_RIGID_ALIAS),
545 }
546 }
547548fn add_term(&mut self, term: I::Term) {
549match term.kind() {
550 ty::TermKind::Ty(ty) => self.add_ty(ty),
551 ty::TermKind::Const(ct) => self.add_const(ct),
552 }
553 }
554}