]> git.lizzy.rs Git - rust.git/commitdiff
review comments: error code text
authorEsteban Küber <esteban@kuber.com.ar>
Tue, 3 Sep 2019 15:03:09 +0000 (08:03 -0700)
committerEsteban Küber <esteban@kuber.com.ar>
Tue, 3 Sep 2019 15:03:09 +0000 (08:03 -0700)
src/librustc_typeck/error_codes.rs

index ebfa6acf23e00afba5a0ed0116cb4414a9b31551..a2b1f16ef3de7e41c9a1b24ff55580607d95d2b5 100644 (file)
@@ -2431,26 +2431,28 @@ struct Bar<S, T> { x: Foo<S, T> }
 
 Methods take a special first parameter, of which there are three variants:
 `self`, `&self`, and `&mut self`. These are syntactic sugar for
-`self: Self`, `self: &Self`, and `self: &mut Self` respectively. The type
-`Self` acts as an alias to the type of the current trait implementer, or
-"receiver type". Besides the already mentioned `Self`, `&Self` and
-`&mut Self` valid receiver types, the following are also valid:
-`self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, and `self: Pin<P>`
-(where P is one of the previous types except `Self`).
+`self: Self`, `self: &Self`, and `self: &mut Self` respectively.
 
 ```
 # struct Foo;
 trait Trait {
     fn foo(&self);
+//         ^^^^^ `self` here is a reference to the receiver object
 }
 
 impl Trait for Foo {
     fn foo(&self) {}
-//         ^^^^^ this the receiver type `&Foo`
+//         ^^^^^ the receiver type is `&Foo`
 }
 ```
 
-The above is equivalent to:
+The type `Self` acts as an alias to the type of the current trait
+implementer, or "receiver type". Besides the already mentioned `Self`,
+`&Self` and `&mut Self` valid receiver types, the following are also valid:
+`self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, and `self: Pin<P>`
+(where P is one of the previous types except `Self`). Note that `Self` can
+also be the underlying implementing type, like `Foo` in the following
+example:
 
 ```
 # struct Foo;