# Recursive type representation in rustc

**URL:** <https://internals.rust-lang.org/t/recursive-type-representation-in-rustc/15235>\
**Category:** compiler\
**Created:** [August 29, 2021, 10:53am UTC](https://internals.rust-lang.org/t/recursive-type-representation-in-rustc/15235 "2021-08-29T10:53:31Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![camelid](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@camelid](https://internals.rust-lang.org/u/camelid)\
**Post date:** [November 3, 2021, 2:13am UTC](https://internals.rust-lang.org/t/recursive-type-representation-in-rustc/15235/4 "2021-11-03T02:13:07Z")

</div>

Like @bjorn3 said, `S` is represented as a `TyKind::Adt` using a `DefId`. Since the rustc representation of recursive types confused me recently, I'll mention that `TyKind::Adt`s do _not_ include the fields' types. Instead, a `TyKind::Adt` looks roughly like this pseudocode:

```rust
struct S {
    x
}

```

The type of `S` includes the `DefId` of `S.x`, which can then be used to look up the type of the field.

---

_[View the full topic](https://internals.rust-lang.org/t/recursive-type-representation-in-rustc/15235)._
