Skip to content

const generic ty's do not get hard errors for privacy violations #111939

@BoxyUwU

Description

@BoxyUwU

I tried this code:

#![feature(adt_const_params)]

#[derive(Eq, PartialEq)]
struct Foo;

pub fn bar<const N: Foo>() {}

I expected to see this happen: it error, Foo is a private type in a public signature

Instead, this happened:
It just gives a warning, since adt_const_params is unstable we can make this a hard error

warning: private type `Foo` in public interface (error E0446)
 --> src/lib.rs:6:1
  |
6 | pub fn bar<const N: Foo>() {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = 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>](https://github.com/rust-lang/rust/issues/34537)
  = note: `#[warn(private_in_public)]` on by default

Meta

rustc --version --verbose:

Nightly channel

Build using the Nightly version: 1.71.0-nightly

(2023-05-23 5ea3f0ae08c07472239a)
Backtrace

<backtrace>

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.F-adt_const_params`#![feature(adt_const_params)]`T-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions