Skip to content

Require impl Trait in associated types to appear in method signatures#110454

Merged
bors merged 6 commits intorust-lang:masterfrom
oli-obk:limited_impl_trait_in_assoc_type
May 13, 2023
Merged

Require impl Trait in associated types to appear in method signatures#110454
bors merged 6 commits intorust-lang:masterfrom
oli-obk:limited_impl_trait_in_assoc_type

Conversation

@oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Apr 17, 2023

This implements the limited version of TAIT that was proposed in #107645 (comment)

Similar to impl Trait in return types, impl Trait in associated types may only be used within the impl block which it is a part of. To make everything simpler and forward compatible to getting desugared to a plain type alias impl trait in the future, we're requiring that any associated functions or constants that want to register hidden types must be using the associated type in their signature (type of the constant or argument/return type of the associated method. Where bounds mentioning the associated type are ignored).

We have preexisting tests checking that this works transitively across multiple associated types in situations like

impl Foo for Bar {
    type A = impl Trait;
    type B = impl Iterator<Item = Self::A>;
    fn foo() -> Self::B { ...... }
}

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rustdoc-json Area: Rustdoc JSON backend A-testsuite Area: The testsuite used to check the correctness of rustc A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants