@@ -212,7 +212,7 @@ match string {
212
212
E0033 : r##"
213
213
This error indicates that a pointer to a trait type cannot be implicitly
214
214
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.
216
216
Therefore, all accesses to trait types must be through pointers. If you
217
217
encounter this error you should try to avoid dereferencing the pointer.
218
218
@@ -2430,23 +2430,23 @@ This error indicates that the `self` parameter in a method has an invalid
2430
2430
"reciever type".
2431
2431
2432
2432
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`).
2439
2440
2440
2441
```
2441
2442
# struct Foo;
2442
2443
trait Trait {
2443
2444
fn foo(&self);
2444
- // ^^^^^ this let's you refer to the type that implements this trait
2445
2445
}
2446
+
2446
2447
impl Trait for Foo {
2447
- // ^^^ this is the "receiver type"
2448
2448
fn foo(&self) {}
2449
- // ^^^^^ this is of type `Foo`
2449
+ // ^^^^^ this the receiver type `& Foo`
2450
2450
}
2451
2451
```
2452
2452
@@ -2458,11 +2458,12 @@ The above is equivalent to:
2458
2458
# fn foo(&self);
2459
2459
# }
2460
2460
impl Trait for Foo {
2461
- fn foo(& self: &Foo) {}
2461
+ fn foo(self: &Foo) {}
2462
2462
}
2463
2463
```
2464
2464
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:
2466
2467
2467
2468
```compile_fail,E0307
2468
2469
# struct Foo;
@@ -2471,12 +2472,13 @@ When using an invalid reciver type, like in the following example,
2471
2472
# fn foo(&self);
2472
2473
# }
2473
2474
impl Trait for Struct {
2474
- fn foo(& self: &Bar) {}
2475
+ fn foo(self: &Bar) {}
2475
2476
}
2476
2477
```
2477
2478
2478
2479
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`:
2480
2482
2481
2483
```
2482
2484
#![feature(arbitrary_self_types)]
0 commit comments