Skip to content

Commit

Permalink
Improve explanations for E0072, E0073, E0121, E0178.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Hamann committed May 17, 2015
1 parent d7a32b0 commit b7452ee
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ size of ListNode = 1 byte for head
+ size of ListNode
```
One way to fix this is by wrapping `ByteList` in a `Box`, like so:
One way to fix this is by wrapping `ListNode` in a `Box`, like so:
```
struct ByteList {
struct ListNode {
head: u8,
tail: Option<Box<ByteList>>,
tail: Option<Box<ListNode>>,
}
```
Expand All @@ -147,9 +147,8 @@ This works because `Box` is a pointer, so its size is well-known.

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

E0081: r##"
Expand Down Expand Up @@ -324,17 +323,8 @@ RFC. It is, however, [currently unimplemented][iss15872].
"##,

E0121: r##"
When `_` is in a type, it can act as a placeholder for another type. The
compiler interprets it as a request to infer the type. This enables partial
type hints, as in the following example:
```
// x is a Vec<T> for some T. The compiler infers T.
let x: Vec<_> = (0..4).collect();
```
However, in order to be consistent with Rust's lack of global type inference,
type placeholders are disallowed by design in item signatures.
In order to be consistent with Rust's lack of global type inference, type
placeholders are disallowed by design in item signatures.
Examples of this error include:
Expand Down Expand Up @@ -392,8 +382,7 @@ struct Bar<'a> {
More details can be found in [RFC 438].
[RFC 438]: https://github.com/rust-lang/rfcs/blob/master/text/0438-precedence-\
of-plus.md
[RFC 438]: https://github.com/rust-lang/rfcs/pull/438
"##,

E0184: r##"
Expand Down

0 comments on commit b7452ee

Please sign in to comment.