File tree Expand file tree Collapse file tree 1 file changed +18
-18
lines changed Expand file tree Collapse file tree 1 file changed +18
-18
lines changed Original file line number Diff line number Diff line change @@ -406,8 +406,20 @@ example:
406406```
407407
408408The `Self` keyword represents the current type, which explains why it
409- can only be used inside an impl or a trait. For example, it is used
410- to solve conflicts like this one:
409+ can only be used inside an impl or a trait. It gives access to
410+ associated items of a type:
411+
412+ ```
413+ trait Foo {
414+ type Bar;
415+ }
416+
417+ trait Baz : Foo {
418+ fn bar() -> Self::Bar; // like this
419+ }
420+ ```
421+
422+ However, be careful when two types has a common associated type:
411423
412424```
413425trait Foo {
@@ -424,26 +436,14 @@ trait Baz : Foo + Foo2 {
424436}
425437```
426438
427- Which can be solved by specifying from which trait we want to use
428- the `Bar` type:
439+ It can be solved by specifying from which trait we want to use the
440+ `Bar` type:
429441
430442```
431443trait Baz : Foo + Foo2 {
432444 fn bar() -> <Self as Foo>::Bar; // ok!
433445}
434446```
435-
436- A more simple example gives:
437-
438- ```
439- trait Foo {
440- type Bar;
441- }
442-
443- trait Baz : Foo {
444- fn bar() -> <Self as Foo>::Bar; // ok!
445- }
446- ```
447447"## ,
448448
449449E0412 : r##"
@@ -872,8 +872,8 @@ impl Foo for i32 {}
872872}
873873
874874register_diagnostics ! {
875- E0153 , // called no where
876- E0157 , // called from no where
875+ // E0153,
876+ // E0157,
877877 E0254 , // import conflicts with imported crate in this module
878878 E0257 ,
879879 E0258 ,
You can’t perform that action at this time.
0 commit comments