<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Self-Referential on ErrorVault — Developer Error Code Dictionary</title>
    <link>https://errorvault.dev/tags/self-referential/</link>
    <description>Recent content in Self-Referential on ErrorVault — Developer Error Code Dictionary</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 15 Jul 2026 05:32:04 +0800</lastBuildDate>
    <atom:link href="https://errorvault.dev/tags/self-referential/feed.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Fix E0640: Self-referential struct definition</title>
      <link>https://errorvault.dev/rust/rust-e0640-self-referential-struct/</link>
      <pubDate>Wed, 15 Jul 2026 05:32:04 +0800</pubDate>
      <guid>https://errorvault.dev/rust/rust-e0640-self-referential-struct/</guid>
      <description>&lt;h2 id=&#34;1-symptoms&#34;&gt;1. Symptoms&lt;/h2&gt;&#xA;&lt;p&gt;When you attempt to compile a Rust program containing a struct definition where one field directly references the struct type itself (outside of pointer wrappers), the compiler emits error E0640. The error message clearly indicates that the struct definition contains an unsupported self-referential pattern.&lt;/p&gt;&#xA;&lt;p&gt;Shell output demonstrating the error looks like the following:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;error[E0640]: self-referential struct&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  --&amp;gt; src/main.rs:5:5&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   |&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;5  |     name: String,&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;6  |     // ERROR: next points back to the containing struct&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;7  |     next: Option&amp;lt;Node&amp;gt;,&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   |           ^^^^^^^^^^^^^^ self-referential struct&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   |&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   = note: this error indicates that the struct is self-referential&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   = help: consider using `Box&amp;lt;Self&amp;gt;`, `Arc&amp;lt;Self&amp;gt;`, `Rc&amp;lt;Self&amp;gt;`, or a reference type&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   = help: for more information, see https://doc.rust-lang.org/reference/structures.html&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;A slightly different manifestation occurs when attempting to embed the struct directly within itself as a field rather than behind a smart pointer wrapper:&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
