Skip to content

Existential type complains about private type in public interface if concrete type is not pub #53546

Closed
@Arnavion

Description

@Arnavion
#![feature(existential_type)]

pub mod foo {
    pub existential type Foo: ::std::fmt::Debug;
    pub fn foo() -> Foo {
        S
    }

    #[derive(Debug)] struct S;
}

gives

warning: private type `foo::S` in public interface (error E0446)
 --> src/lib.rs:4:5
  |
4 |     pub existential type Foo: ::std::fmt::Debug;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: #[warn(private_in_public)] on by default
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>

Returning impl ::std::fmt::Debug does not have this restriction.

Metadata

Metadata

Assignees

Labels

A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.A-visibilityArea: Visibility / privacy

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions