Skip to content

exported_private_dependencies lint ignores const generics #161664

Description

@mladedav

Code

use ::priv_dep::NUM; // private dependency

pub struct U<const X: u8>;
pub fn foo(_: U<NUM>) {}

Current output

No lint generated

Desired output

error: constant `NUM` from private dependency 'priv_dep' in public interface
  --> $DIR/file.rs:0:0
   |
LL | pub fn foo(_: U<NUM>) {}
   |                 ^^^

Rationale and extra context

We're linting on the same thing if it's normal generic instead of const generic. I believe this exposes the private dependency because it could change the constant which would change our public interface.

Similar issue for const generics also exist in reexports of const generic structs, implementations on those structs, implementation of const generic traits and so on.

The re-export lint correctly identifies constants from private dependencies.

Other cases

Rust Version

master

Anything else?

Tracking issue for the lint #44663

@rustbot label +F-public_private_dependencies +L-exported_private_dependencies +A-lints +A-visibility

Changes to this lint are currently reviewed in #160726 but it doesn't change this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-visibilityArea: Visibility / privacyF-public_private_dependenciesfeature: public_private_dependenciesL-exported_private_dependenciesLint: exported_private_dependenciesT-compilerRelevant to the compiler 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