Skip to content

Commit bb99fc3

Browse files
committed
review comment: update error code descr
1 parent c1e5e5c commit bb99fc3

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/librustc_typeck/error_codes.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ match string {
212212
E0033: r##"
213213
This error indicates that a pointer to a trait type cannot be implicitly
214214
dereferenced by a pattern. Every trait defines a type, but because the
215-
size of trait implementors isn't fixed, this type has no compile-time size.
215+
size of trait implementers isn't fixed, this type has no compile-time size.
216216
Therefore, all accesses to trait types must be through pointers. If you
217217
encounter this error you should try to avoid dereferencing the pointer.
218218
@@ -2430,23 +2430,23 @@ This error indicates that the `self` parameter in a method has an invalid
24302430
"reciever type".
24312431
24322432
Methods take a special first parameter, of which there are three variants:
2433-
`self`, `&self`, and `&mut self`. The type `Self` acts as an alias to the
2434-
type of the current trait implementor, or "receiver type". Besides the
2435-
already mentioned `Self`, `&Self` and `&mut Self` valid receiver types, the
2436-
following are also valid, if less common: `self: Box<Self>`,
2437-
`self: Rc<Self>`, `self: Arc<Self>`, and `self: Pin<P>` (where P is one of
2438-
the previous types except `Self`).
2433+
`self`, `&self`, and `&mut self`. These are syntactic sugar for
2434+
`self: Self`, `self: &Self`, and `self: &mut Self` respectively. The type
2435+
`Self` acts as an alias to the type of the current trait implementer, or
2436+
"receiver type". Besides the already mentioned `Self`, `&Self` and
2437+
`&mut Self` valid receiver types, the following are also valid:
2438+
`self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, and `self: Pin<P>`
2439+
(where P is one of the previous types except `Self`).
24392440
24402441
```
24412442
# struct Foo;
24422443
trait Trait {
24432444
fn foo(&self);
2444-
// ^^^^^ this let's you refer to the type that implements this trait
24452445
}
2446+
24462447
impl Trait for Foo {
2447-
// ^^^ this is the "receiver type"
24482448
fn foo(&self) {}
2449-
// ^^^^^ this is of type `Foo`
2449+
// ^^^^^ this the receiver type `&Foo`
24502450
}
24512451
```
24522452
@@ -2458,11 +2458,12 @@ The above is equivalent to:
24582458
# fn foo(&self);
24592459
# }
24602460
impl Trait for Foo {
2461-
fn foo(&self: &Foo) {}
2461+
fn foo(self: &Foo) {}
24622462
}
24632463
```
24642464
2465-
When using an invalid reciver type, like in the following example,
2465+
E0307 will be emitted by the compiler when using an invalid reciver type,
2466+
like in the following example:
24662467
24672468
```compile_fail,E0307
24682469
# struct Foo;
@@ -2471,12 +2472,13 @@ When using an invalid reciver type, like in the following example,
24712472
# fn foo(&self);
24722473
# }
24732474
impl Trait for Struct {
2474-
fn foo(&self: &Bar) {}
2475+
fn foo(self: &Bar) {}
24752476
}
24762477
```
24772478
24782479
The nightly feature [Arbintrary self types][AST] extends the accepted
2479-
receiver type to also include any type that can dereference to `Self`:
2480+
set of receiver types to also include any type that can dereference to
2481+
`Self`:
24802482
24812483
```
24822484
#![feature(arbitrary_self_types)]

0 commit comments

Comments
 (0)