Skip to content

Commit b7452ee

Browse files
author
Nick Hamann
committed
Improve explanations for E0072, E0073, E0121, E0178.
1 parent d7a32b0 commit b7452ee

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

src/librustc_typeck/diagnostics.rs

+9-20
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ size of ListNode = 1 byte for head
133133
+ size of ListNode
134134
```
135135
136-
One way to fix this is by wrapping `ByteList` in a `Box`, like so:
136+
One way to fix this is by wrapping `ListNode` in a `Box`, like so:
137137
138138
```
139-
struct ByteList {
139+
struct ListNode {
140140
head: u8,
141-
tail: Option<Box<ByteList>>,
141+
tail: Option<Box<ListNode>>,
142142
}
143143
```
144144
@@ -147,9 +147,8 @@ This works because `Box` is a pointer, so its size is well-known.
147147

148148
E0073: r##"
149149
You cannot define a struct (or enum) `Foo` that requires an instance of `Foo`
150-
in order to make a new `Foo` value (think about it: if making an instance of
151-
`Foo` requires an already-existing instance of `Foo`, how does the first
152-
instance get made?).
150+
in order to make a new `Foo` value. This is because there would be no way a
151+
first instance of `Foo` could be made to initialize another instance!
153152
154153
Here's an example of a struct that has this problem:
155154
@@ -163,7 +162,7 @@ One fix is to use `Option`, like so:
163162
struct Foo { x: Option<Box<Foo>> }
164163
```
165164
166-
Now it's possible to create at least one instance of Foo: `Foo { x: None }`.
165+
Now it's possible to create at least one instance of `Foo`: `Foo { x: None }`.
167166
"##,
168167

169168
E0081: r##"
@@ -324,17 +323,8 @@ RFC. It is, however, [currently unimplemented][iss15872].
324323
"##,
325324

326325
E0121: r##"
327-
When `_` is in a type, it can act as a placeholder for another type. The
328-
compiler interprets it as a request to infer the type. This enables partial
329-
type hints, as in the following example:
330-
331-
```
332-
// x is a Vec<T> for some T. The compiler infers T.
333-
let x: Vec<_> = (0..4).collect();
334-
```
335-
336-
However, in order to be consistent with Rust's lack of global type inference,
337-
type placeholders are disallowed by design in item signatures.
326+
In order to be consistent with Rust's lack of global type inference, type
327+
placeholders are disallowed by design in item signatures.
338328
339329
Examples of this error include:
340330
@@ -392,8 +382,7 @@ struct Bar<'a> {
392382
393383
More details can be found in [RFC 438].
394384
395-
[RFC 438]: https://github.com/rust-lang/rfcs/blob/master/text/0438-precedence-\
396-
of-plus.md
385+
[RFC 438]: https://github.com/rust-lang/rfcs/pull/438
397386
"##,
398387

399388
E0184: r##"

0 commit comments

Comments
 (0)