1use crate::any::TypeId;
5use crate::fmt;
6use crate::intrinsics::{self, type_id, type_of};
7use crate::marker::PointeeSized;
8use crate::ptr::DynMetadata;
9
10#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Type {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field1_finish(f, "Type", "kind",
&&self.kind)
}
}Debug)]
12#[non_exhaustive]
13#[lang = "type_info"]
14#[unstable(feature = "type_info", issue = "146922")]
15pub struct Type {
16 pub kind: TypeKind,
18}
19
20#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl<T: crate::fmt::Debug + PointeeSized> crate::fmt::Debug for TraitImpl<T> {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field1_finish(f, "TraitImpl",
"vtable", &&self.vtable)
}
}Debug, #[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl<T: crate::cmp::PartialEq + PointeeSized> crate::cmp::PartialEq for
TraitImpl<T> {
#[inline]
fn eq(&self, other: &TraitImpl<T>) -> bool { self.vtable == other.vtable }
}PartialEq, #[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl<T: crate::cmp::Eq + PointeeSized> crate::cmp::Eq for TraitImpl<T> {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: crate::cmp::AssertParamIsEq<DynMetadata<T>>;
}
}Eq)]
22#[unstable(feature = "type_info", issue = "146922")]
23#[non_exhaustive]
24pub struct TraitImpl<T: PointeeSized> {
25 pub(crate) vtable: DynMetadata<T>,
26}
27
28impl<T: PointeeSized> TraitImpl<T> {
29 pub const fn get_vtable(&self) -> DynMetadata<T> {
31 self.vtable
32 }
33}
34
35impl TypeId {
36 #[unstable(feature = "type_info", issue = "146922")]
39 #[rustc_const_unstable(feature = "type_info", issue = "146922")]
40 #[rustc_comptime]
41 pub fn info(self) -> Type {
42 type_of(self)
43 }
44}
45
46impl Type {
47 #[unstable(feature = "type_info", issue = "146922")]
56 #[rustc_const_unstable(feature = "type_info", issue = "146922")]
57 pub const fn of<T: ?Sized>() -> Self {
58 const { type_id::<T>().info() }
59 }
60}
61
62#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for TypeKind {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
match self {
TypeKind::Tuple(__self_0) =>
crate::fmt::Formatter::debug_tuple_field1_finish(f, "Tuple",
&__self_0),
TypeKind::Array(__self_0) =>
crate::fmt::Formatter::debug_tuple_field1_finish(f, "Array",
&__self_0),
TypeKind::Slice(__self_0) =>
crate::fmt::Formatter::debug_tuple_field1_finish(f, "Slice",
&__self_0),
TypeKind::DynTrait(__self_0) =>
crate::fmt::Formatter::debug_tuple_field1_finish(f,
"DynTrait", &__self_0),
TypeKind::Struct(__self_0) =>
crate::fmt::Formatter::debug_tuple_field1_finish(f, "Struct",
&__self_0),
TypeKind::Enum(__self_0) =>
crate::fmt::Formatter::debug_tuple_field1_finish(f, "Enum",
&__self_0),
TypeKind::Union(__self_0) =>
crate::fmt::Formatter::debug_tuple_field1_finish(f, "Union",
&__self_0),
TypeKind::Bool(__self_0) =>
crate::fmt::Formatter::debug_tuple_field1_finish(f, "Bool",
&__self_0),
TypeKind::Char(__self_0) =>
crate::fmt::Formatter::debug_tuple_field1_finish(f, "Char",
&__self_0),
TypeKind::Int(__self_0) =>
crate::fmt::Formatter::debug_tuple_field1_finish(f, "Int",
&__self_0),
TypeKind::Float(__self_0) =>
crate::fmt::Formatter::debug_tuple_field1_finish(f, "Float",
&__self_0),
TypeKind::Str(__self_0) =>
crate::fmt::Formatter::debug_tuple_field1_finish(f, "Str",
&__self_0),
TypeKind::Reference(__self_0) =>
crate::fmt::Formatter::debug_tuple_field1_finish(f,
"Reference", &__self_0),
TypeKind::Pointer(__self_0) =>
crate::fmt::Formatter::debug_tuple_field1_finish(f, "Pointer",
&__self_0),
TypeKind::FnPtr(__self_0) =>
crate::fmt::Formatter::debug_tuple_field1_finish(f, "FnPtr",
&__self_0),
TypeKind::Other => crate::fmt::Formatter::write_str(f, "Other"),
}
}
}Debug)]
64#[non_exhaustive]
65#[unstable(feature = "type_info", issue = "146922")]
66pub enum TypeKind {
67 Tuple(Tuple),
69 Array(Array),
71 Slice(Slice),
73 DynTrait(DynTrait),
75 Struct(Struct),
77 Enum(Enum),
79 Union(Union),
81 Bool(Bool),
83 Char(Char),
85 Int(Int),
87 Float(Float),
89 Str(Str),
91 Reference(Reference),
93 Pointer(Pointer),
95 FnPtr(FnPtr),
97 Other,
99}
100
101#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Tuple {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field1_finish(f, "Tuple",
"fields", &&self.fields)
}
}Debug)]
103#[non_exhaustive]
104#[unstable(feature = "type_info", issue = "146922")]
105pub struct Tuple {
106 pub fields: &'static [Field],
108}
109
110#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Field {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field3_finish(f, "Field", "name",
&self.name, "ty", &self.ty, "offset", &&self.offset)
}
}Debug)]
112#[non_exhaustive]
113#[unstable(feature = "type_info", issue = "146922")]
114pub struct Field {
115 pub name: &'static str,
117 pub ty: TypeId,
119 pub offset: usize,
121}
122
123#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Array {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field2_finish(f, "Array",
"element_ty", &self.element_ty, "len", &&self.len)
}
}Debug)]
125#[non_exhaustive]
126#[unstable(feature = "type_info", issue = "146922")]
127pub struct Array {
128 pub element_ty: TypeId,
130 pub len: usize,
132}
133
134#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Slice {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field1_finish(f, "Slice",
"element_ty", &&self.element_ty)
}
}Debug)]
136#[non_exhaustive]
137#[unstable(feature = "type_info", issue = "146922")]
138pub struct Slice {
139 pub element_ty: TypeId,
141}
142
143#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for DynTrait {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field1_finish(f, "DynTrait",
"predicates", &&self.predicates)
}
}Debug)]
146#[non_exhaustive]
147#[unstable(feature = "type_info", issue = "146922")]
148pub struct DynTrait {
149 pub predicates: &'static [DynTraitPredicate],
151}
152
153#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for DynTraitPredicate {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field1_finish(f,
"DynTraitPredicate", "trait_ty", &&self.trait_ty)
}
}Debug)]
155#[non_exhaustive]
156#[unstable(feature = "type_info", issue = "146922")]
157pub struct DynTraitPredicate {
158 pub trait_ty: Trait,
160}
161
162#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Trait {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field2_finish(f, "Trait", "ty",
&self.ty, "is_auto", &&self.is_auto)
}
}Debug)]
164#[non_exhaustive]
165#[unstable(feature = "type_info", issue = "146922")]
166pub struct Trait {
167 pub ty: TypeId,
169 pub is_auto: bool,
171}
172
173#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Struct {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field3_finish(f, "Struct",
"generics", &self.generics, "fields", &self.fields,
"non_exhaustive", &&self.non_exhaustive)
}
}Debug)]
175#[non_exhaustive]
176#[unstable(feature = "type_info", issue = "146922")]
177pub struct Struct {
178 pub generics: &'static [Generic],
180 pub fields: &'static [Field],
182 pub non_exhaustive: bool,
184}
185
186#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Union {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field2_finish(f, "Union",
"generics", &self.generics, "fields", &&self.fields)
}
}Debug)]
188#[non_exhaustive]
189#[unstable(feature = "type_info", issue = "146922")]
190pub struct Union {
191 pub generics: &'static [Generic],
193 pub fields: &'static [Field],
195}
196
197#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Enum {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field3_finish(f, "Enum",
"generics", &self.generics, "variants", &self.variants,
"non_exhaustive", &&self.non_exhaustive)
}
}Debug)]
199#[non_exhaustive]
200#[unstable(feature = "type_info", issue = "146922")]
201pub struct Enum {
202 pub generics: &'static [Generic],
204 pub variants: &'static [Variant],
206 pub non_exhaustive: bool,
208}
209
210#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Variant {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field3_finish(f, "Variant",
"name", &self.name, "fields", &self.fields, "non_exhaustive",
&&self.non_exhaustive)
}
}Debug)]
212#[non_exhaustive]
213#[unstable(feature = "type_info", issue = "146922")]
214pub struct Variant {
215 pub name: &'static str,
217 pub fields: &'static [Field],
219 pub non_exhaustive: bool,
221}
222
223#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Generic {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
match self {
Generic::Lifetime(__self_0) =>
crate::fmt::Formatter::debug_tuple_field1_finish(f,
"Lifetime", &__self_0),
Generic::Type(__self_0) =>
crate::fmt::Formatter::debug_tuple_field1_finish(f, "Type",
&__self_0),
Generic::Const(__self_0) =>
crate::fmt::Formatter::debug_tuple_field1_finish(f, "Const",
&__self_0),
}
}
}Debug)]
225#[non_exhaustive]
226#[unstable(feature = "type_info", issue = "146922")]
227#[lang = "type_info_generic"]
228pub enum Generic {
229 Lifetime(Lifetime),
231 Type(GenericType),
233 Const(Const),
235}
236
237#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Lifetime {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::write_str(f, "Lifetime")
}
}Debug)]
239#[non_exhaustive]
240#[unstable(feature = "type_info", issue = "146922")]
241pub struct Lifetime {
242 }
244
245#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for GenericType {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field1_finish(f, "GenericType",
"ty", &&self.ty)
}
}Debug)]
247#[non_exhaustive]
248#[unstable(feature = "type_info", issue = "146922")]
249pub struct GenericType {
250 pub ty: TypeId,
252}
253
254#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Const {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field1_finish(f, "Const", "ty",
&&self.ty)
}
}Debug)]
256#[non_exhaustive]
257#[unstable(feature = "type_info", issue = "146922")]
258pub struct Const {
259 pub ty: TypeId,
261}
262
263#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Bool {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::write_str(f, "Bool")
}
}Debug)]
265#[non_exhaustive]
266#[unstable(feature = "type_info", issue = "146922")]
267pub struct Bool {
268 }
270
271#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Char {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::write_str(f, "Char")
}
}Debug)]
273#[non_exhaustive]
274#[unstable(feature = "type_info", issue = "146922")]
275pub struct Char {
276 }
278
279#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Int {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field2_finish(f, "Int", "bits",
&self.bits, "signed", &&self.signed)
}
}Debug)]
281#[non_exhaustive]
282#[unstable(feature = "type_info", issue = "146922")]
283pub struct Int {
284 pub bits: u32,
286 pub signed: bool,
288}
289
290#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Float {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field1_finish(f, "Float", "bits",
&&self.bits)
}
}Debug)]
292#[non_exhaustive]
293#[unstable(feature = "type_info", issue = "146922")]
294pub struct Float {
295 pub bits: u32,
297}
298
299#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Str {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::write_str(f, "Str")
}
}Debug)]
301#[non_exhaustive]
302#[unstable(feature = "type_info", issue = "146922")]
303pub struct Str {
304 }
306
307#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Reference {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field2_finish(f, "Reference",
"pointee", &self.pointee, "mutable", &&self.mutable)
}
}Debug)]
309#[non_exhaustive]
310#[unstable(feature = "type_info", issue = "146922")]
311pub struct Reference {
312 pub pointee: TypeId,
314 pub mutable: bool,
316}
317
318#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Pointer {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
crate::fmt::Formatter::debug_struct_field2_finish(f, "Pointer",
"pointee", &self.pointee, "mutable", &&self.mutable)
}
}Debug)]
320#[non_exhaustive]
321#[unstable(feature = "type_info", issue = "146922")]
322pub struct Pointer {
323 pub pointee: TypeId,
325 pub mutable: bool,
327}
328
329#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for FnPtr {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
let names: &'static _ =
&["unsafety", "abi", "inputs", "output", "variadic",
"is_splatted", "splatted_index"];
let values: &[&dyn crate::fmt::Debug] =
&[&self.unsafety, &self.abi, &self.inputs, &self.output,
&self.variadic, &self.is_splatted, &&self.splatted_index];
crate::fmt::Formatter::debug_struct_fields_finish(f, "FnPtr", names,
values)
}
}Debug)]
330#[unstable(feature = "type_info", issue = "146922")]
331pub struct FnPtr {
333 pub unsafety: bool,
335
336 pub abi: Abi,
338
339 pub inputs: &'static [TypeId],
341
342 pub output: TypeId,
344
345 pub variadic: bool,
347
348 pub is_splatted: bool,
351
352 pub splatted_index: u8,
356}
357
358impl FnPtr {
359 pub const fn splatted(&self) -> Option<u8> {
361 if self.is_splatted { Some(self.splatted_index) } else { None }
362 }
363}
364
365#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::fmt::Debug for Abi {
#[inline]
fn fmt(&self, f: &mut crate::fmt::Formatter) -> crate::fmt::Result {
match self {
Abi::Named(__self_0) =>
crate::fmt::Formatter::debug_tuple_field1_finish(f, "Named",
&__self_0),
Abi::ExternRust =>
crate::fmt::Formatter::write_str(f, "ExternRust"),
Abi::ExternC => crate::fmt::Formatter::write_str(f, "ExternC"),
}
}
}Debug, #[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::default::Default for Abi {
#[inline]
fn default() -> Abi { Self::ExternRust }
}Default)]
366#[non_exhaustive]
367#[unstable(feature = "type_info", issue = "146922")]
368pub enum Abi {
370 Named(&'static str),
372
373 #[default]
375 ExternRust,
376
377 ExternC,
379}
380
381impl TypeId {
382 #[unstable(feature = "type_info", issue = "146922")]
394 #[rustc_const_unstable(feature = "type_info", issue = "146922")]
395 #[rustc_comptime]
396 pub fn size(self) -> Option<usize> {
397 intrinsics::size_of_type_id(self)
398 }
399
400 #[unstable(feature = "type_info", issue = "146922")]
420 #[rustc_const_unstable(feature = "type_info", issue = "146922")]
421 #[rustc_comptime]
422 pub fn variants(self) -> usize {
423 intrinsics::type_id_variants(self)
424 }
425
426 #[unstable(feature = "type_info", issue = "146922")]
483 #[rustc_const_unstable(feature = "type_info", issue = "146922")]
484 #[rustc_comptime]
485 pub fn fields(self, variant_index: usize) -> usize {
490 intrinsics::type_id_fields(self, variant_index)
491 }
492
493 #[unstable(feature = "type_info", issue = "146922")]
554 #[rustc_const_unstable(feature = "type_info", issue = "146922")]
555 #[rustc_comptime]
556 pub fn field(self, variant_index: usize, field_index: usize) -> FieldId {
557 FieldId {
558 frt_type_id: intrinsics::type_id_field_representing_type(
559 self,
560 variant_index,
561 field_index,
562 ),
563 }
564 }
565
566 #[unstable(feature = "type_info", issue = "146922")]
569 #[rustc_const_unstable(feature = "type_info", issue = "146922")]
570 #[rustc_comptime]
571 pub fn non_exhaustive(self) -> bool {
572 intrinsics::non_exhaustive(self)
573 }
574
575 #[unstable(feature = "type_info", issue = "146922")]
578 #[rustc_const_unstable(feature = "type_info", issue = "146922")]
579 #[rustc_comptime]
580 pub fn generics(self) -> &'static [Generic] {
581 intrinsics::type_id_generics(self)
582 }
583}
584
585#[derive(#[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::marker::Copy for FieldId { }Copy, #[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::cmp::PartialOrd for FieldId {
#[inline]
fn partial_cmp(&self, other: &FieldId)
-> crate::option::Option<crate::cmp::Ordering> {
crate::option::Option::Some(crate::cmp::Ord::cmp(self, other))
}
}PartialOrd, #[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::cmp::Ord for FieldId {
#[inline]
fn cmp(&self, other: &FieldId) -> crate::cmp::Ordering {
crate::cmp::Ord::cmp(&self.frt_type_id, &other.frt_type_id)
}
}Ord, #[automatically_derived]
#[unstable(feature = "type_info", issue = "146922")]
impl crate::hash::Hash for FieldId {
#[inline]
fn hash<__H: crate::hash::Hasher>(&self, state: &mut __H) {
crate::hash::Hash::hash(&self.frt_type_id, state)
}
}Hash)]
587#[derive_const(#[automatically_derived]
#[rustc_const_unstable(feature = "derive_const", issue = "118304")]
#[unstable(feature = "type_info", issue = "146922")]
const impl crate::clone::Clone for FieldId {
#[inline]
fn clone(&self) -> FieldId {
let _: crate::clone::AssertParamIsClone<TypeId>;
*self
}
}Clone, #[automatically_derived]
#[rustc_const_unstable(feature = "derive_const", issue = "118304")]
#[unstable(feature = "type_info", issue = "146922")]
const impl crate::cmp::PartialEq for FieldId {
#[inline]
fn eq(&self, other: &FieldId) -> bool {
self.frt_type_id == other.frt_type_id
}
}PartialEq, #[automatically_derived]
#[rustc_const_unstable(feature = "derive_const", issue = "118304")]
#[unstable(feature = "type_info", issue = "146922")]
const impl crate::cmp::Eq for FieldId {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: crate::cmp::AssertParamIsEq<TypeId>;
}
}Eq)]
588#[unstable(feature = "type_info", issue = "146922")]
589pub struct FieldId {
590 frt_type_id: TypeId,
591}
592
593#[unstable(feature = "type_info", issue = "146922")]
594impl fmt::Debug for FieldId {
595 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
596 f.write_fmt(format_args!("FieldId({0:#034x})", self.frt_type_id.as_u128()))write!(f, "FieldId({:#034x})", self.frt_type_id.as_u128())
597 }
598}
599
600impl FieldId {
601 #[unstable(feature = "type_info", issue = "146922")]
617 #[rustc_const_unstable(feature = "type_info", issue = "146922")]
618 #[rustc_comptime]
619 pub fn type_id(self) -> TypeId {
620 intrinsics::field_representing_type_actual_type_id(self.frt_type_id)
621 }
622
623 #[unstable(feature = "type_info", issue = "146922")]
639 #[rustc_const_unstable(feature = "type_info", issue = "146922")]
640 #[rustc_comptime]
641 pub fn name(self) -> &'static str {
642 intrinsics::field_representing_type_name(self.frt_type_id)
643 }
644 #[unstable(feature = "type_info", issue = "146922")]
661 #[rustc_const_unstable(feature = "type_info", issue = "146922")]
662 #[rustc_comptime]
663 pub fn offset(self) -> usize {
664 intrinsics::field_representing_type_offset(self.frt_type_id)
665 }
666}