Skip to content

impl trait in type aliases does not trigger "private type in public interface" errors #63169

Description

@Nemo157

The current implementation of existential_type does not trigger any "private type in public interface" errors, for the following code (playground):

#![feature(existential_type)]

existential type Foo: std::fmt::Debug;

pub fn foo() -> Foo {
    5usize
}

I would expect it to give an error like

error[E0446]: private type alias `Foo` in public interface
  --> src/lib.rs:8:1
   |
5  |   existential type Foo: std::fmt::Debug
   |   - `Foo` declared as private
...
8  | / pub fn foo() -> Foo {
9  | |     5usize
10 | | }
   | |_^ can't leak private type alias

(although, because normal type aliases are transparent to the visibility checking, I'm not certain exactly what the error message should say; it just seems bad to introduce another way to accidentally forget to make part of your API publicly nameable)

cc #63063

No activity

Activity on this issue will appear here.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyA-visibilityArea: Visibility / privacyF-type_alias_impl_trait`#[feature(type_alias_impl_trait)]`I-needs-decisionIssue: In need of a decision.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamrequires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions