Repository: rust
Issue: Tracking issue for inherent associated types
Labels: B-RFC-approved,A-associated-items,T-lang,C-tracking-issue,F-inherent_associated_types,S-tracking-impl-incomplete

This is a tracking issue for the ["inherent associate type" part of "inherent associated items" part of the RFC 195 "associated items"](https://github.com/rust-lang/rfcs/blob/master/text/0195-associated-items.md#inherent-associated-items)

### About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

### Original description

(This code is written in ancient version of Rust, and is not meant to be used directly.)

When developing a type-parametric impl, I found myself writing code somewhat like this:

``` rust
    struct Grammar<T, NT> { ... }

    impl<T:Clone,NT:Eq+Hash+Clone+Primable> Grammar<T,NT> {
        fn to_nt_map(&self) -> HashMap<NT, ~[Prod<T,NT>]>
        {
            type Rules = ~[Prod<T,NT>];
            type NTMap = HashMap<NT, Rules>;        
          ...
        }

        fn from_nt_map(start: &NT, rules: &HashMap<NT, ~[Prod<T,NT>]>)
            -> Grammar<T,NT>
        {
            type Rules = ~[Prod<T,NT>];
            type NTMap = HashMap<NT, Rules>;
          ...
        }

        pub fn eliminate_left_recursion(&self) -> Grammar<T,NT>
        {
          ...
        }

        ...

    }
```

I cannot make a `type` definition for `HashMap<NT, ~[Prod<T,NT>]>` outside of the `impl` because it then those free references to `NT` and `T` would be unbound.

And I cannot put a `type` definition within the impl, even an impl for a struct such as this (it simply does not parse with the current grammar).

(Being able to put type definitions within impls will probably arise naturally from #5033, when we get around to that.  But that is nonetheless a separate issue from this: Associated Types (and Associated Items) are about enabling certain patterns for the _user_ of a trait, while this ticket describes a convenience for the _implementor_ of a struct.)

### Steps
<!--
Include each step required to complete the feature. Typically this is a PR
implementing a feature, followed by a PR that stabilises the feature. However
for larger features an implementation could be broken up into multiple PRs.
-->

- [ ] Implement the RFC
- [ ] Adjust documentation ([see instructions on rustc-dev-guide][doc-guide])
- [ ] Stabilization PR ([see instructions on rustc-dev-guide][stabilization-guide])

[stabilization-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#stabilization-pr
[doc-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#documentation-prs

### Unresolved Questions
<!--
Include any open questions that need to be answered before the feature can be
stabilised.
-->

### Implementation history

* #82516
* #103621
* #104348
* #105224
* #105315
* #105768
* #105961
* #109410
* #110945
* #111486
* #114594
* #118118
* #118262