Skip to content

Frivolous private_in_public lint when shadowing an imported crate using #[bench] #36768

Closed
@lambda-fairy

Description

@lambda-fairy

I've encountered an issue with the private_in_public lint (#34537). If I create a #[bench] function that has the same name as an extern crate, then rustc claims that "extern crate foo is private".

Here's a minimal example that reproduces this bug:

// ducks.rs
#![feature(test)]
extern crate test;
extern crate geese;

#[bench]
fn geese(_: &mut test::Bencher) {}

geese.rs is an empty file.

$ rustc geese.rs --crate-type rlib
$ rustc ducks.rs --test --extern geese=libgeese.rlib
warning: extern crate `geese` is private, and cannot be reexported (error E0364), consider declaring with `pub`, #[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>

The warning disappears if I either (a) rename the bench function, or (b) remove the #[bench] attribute.

Using rustc 1.13.0-nightly (4f9812a59 2016-09-21), installed on Arch Linux x64 via rustup. (The official nightly hasn't been updated for a while, which is why my version is out of date. Apologies if the issue has already been fixed.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions