Repository: rust
Issue: Tracking issue for lazy type aliases
Labels: T-compiler,B-unstable,C-tracking-issue,A-maybe-future-edition,S-tracking-impl-incomplete,T-types,F-lazy_type_alias,S-tracking-needs-migration-lint

This is a tracking issue for the feature lazy type aliases.
It's considered to be a “sophisticated bug fix” for #21903, hence no RFC.
The feature gate for the issue is `#![feature(lazy_type_alias)]`.

The feature implements the expected semantics for type aliases:

* Where-clauses and bounds on type parameters of type aliases are enforced.
* Type aliases are checked for well-formedness.
* Where-clauses are trailing instead of leading [just like they are for associated types][https://github.com/rust-lang/rust/issues/89122].
* Privacy: Private type aliases cannot be used in public signatures anymore,
  the type alias must also be made public (see also [#114213](https://github.com/rust-lang/rust/issues/114213)).

It can only be stabilized as part of a new edition since the new semantics are incompatible with the status quo.

The core idea (weak alias types) was originally proposed in [MCP 504](https://github.com/rust-lang/compiler-team/issues/504).

### 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.

### Steps

- [x] Implement the feature (see *Implementation history*)
- [ ] Address any open issues and drive the feature to *completeness*
- [ ] Make the feature part of Rust 202X
- [ ] Adjust documentation ([see instructions on rustc-dev-guide][doc-guide])
- [x] Formatting for new syntax has been added to the [Style Guide] ([nightly-style-procedure])
  * #114901
- [ ] 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
[nightly-style-procedure]: https://github.com/rust-lang/style-team/blob/master/nightly-style-procedure.md 
[Style Guide]: https://github.com/rust-lang/rust/tree/master/src/doc/style-guide

### Unresolved questions

*None*.

### Resolved questions

<details>

* We currently don't imply any outlives-bounds on lazy type aliases to prevent introducing unsoundness which as it stands implied bounds would theoretically bring along. With this in mind, when is the best time to add implied bounds to lazy type aliases?
  * [Zulip discussion][implied-bounds-zulip].
  * T-lang consensus: This should be added before stabilization.
  * Further progress is tracked in [#118479](https://github.com/rust-lang/rust/issues/118479).
  * Implementation: [#119350](https://github.com/rust-lang/rust/pull/119350).

</details>

[implied-bounds-zulip]: https://rust-lang.zulipchat.com/#narrow/stream/144729-t-types/topic/implied.20bounds.20for.20the.20more.20recent.20features.3F

### Implementation history

* #108860
* #112853
* #113201
* #113755
* #114228
* #114253
* #114566
* #114594
* #114662
* rust-lang/rustfmt#5887
  * Formatting support for trailing where clauses on type aliases (and associated types)
* #117164
  * Among other things, this PR impls proper orphan checking for lazy type aliases (more precisely, weak alias types)
* #119350
* #120556
* #120780
* #121344
* #126575

#### Honorable Mentions

* #97974

---

Thanks to @fmease for writing this description. :)