]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0073.md
Rollup merge of #92310 - ehuss:rustdoc-ice, r=estebank
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0073.md
1 #### Note: this error code is no longer emitted by the compiler.
2
3 You cannot define a struct (or enum) `Foo` that requires an instance of `Foo`
4 in order to make a new `Foo` value. This is because there would be no way a
5 first instance of `Foo` could be made to initialize another instance!
6
7 Here's an example of a struct that has this problem:
8
9 ```
10 struct Foo { x: Box<Foo> } // error
11 ```
12
13 One fix is to use `Option`, like so:
14
15 ```
16 struct Foo { x: Option<Box<Foo>> }
17 ```
18
19 Now it's possible to create at least one instance of `Foo`: `Foo { x: None }`.