@@ -609,6 +609,32 @@ that it refers to `_Bar` and not `Foo`. To be consistent with the desugared
609
609
form, the sugared variant should have the same meaning and so ` Self ` refers
610
610
to ` Bar ` there.
611
611
612
+ Let's now consider an alternative possible syntax:
613
+
614
+ ``` rust
615
+ impl Trait for Foo {
616
+ type Bar = struct /* there is no ident here */ {
617
+ outer : Option <Box <Self >>,
618
+ inner : Option <Box <Self :: Item >>,
619
+ }
620
+ }
621
+ ```
622
+
623
+ Notice here in particular that there is no identifier after the keyword
624
+ ` struct ` . Because of this, it is reasonable to say that the ` struct `
625
+ assigned to the associated type ` Bar ` is not directly nameable as ` Bar ` .
626
+ Instead, a user must qualify ` Bar ` with ` Self::Bar ` . With this in mind,
627
+ we arrive at the following interpretation:
628
+
629
+ ``` rust
630
+ impl Trait for Foo {
631
+ type Bar = struct /* there is no ident here */ {
632
+ outer : Option <Box <Foo >>,
633
+ inner : Option <Box <Foo :: Bar >>,
634
+ }
635
+ }
636
+ ```
637
+
612
638
### Conclusion
613
639
614
640
We've now examined a few cases and seen that indeed, the meaning of ` Self ` is
@@ -696,4 +722,8 @@ is preferred.
696
722
# Unresolved questions
697
723
[ unresolved ] : #unresolved-questions
698
724
699
- There are no unresolved questions.
725
+ + This syntax creates ambiguity if we ever permit types to be declared directly
726
+ within impls (for example, as the value for an associated type). Do we ever want
727
+ to support that, and if so, how should we resolve the ambiguity? ** A** possible,
728
+ interpretation and way to solve the ambiguity consistently is discussed in the
729
+ rationale.
0 commit comments