1 // This is just like unreachable_pub.rs, but without the
2 // `crate_visibility_modifier` feature (so that we can test the suggestions to
3 // use `pub(crate)` that are given when that feature is off, as opposed to the
4 // suggestions to use `crate` given when it is on). When that feature becomes
5 // stable, this test can be deleted.
10 #![warn(unreachable_pub)]
13 // non-leaked `pub` items in private module should be linted
14 pub use std
::fmt
; //~ WARNING unreachable_pub
15 pub use std
::env
::{Args}
; // braced-use has different item spans than unbraced
16 //~^ WARNING unreachable_pub
18 pub struct Hydrogen
{ //~ WARNING unreachable_pub
19 // `pub` struct fields, too
20 pub neutrons
: usize, //~ WARNING unreachable_pub
21 // (... but not more-restricted fields)
22 pub(crate) electrons
: usize
26 pub fn count_neutrons(&self) -> usize { self.neutrons }
//~ WARNING unreachable_pub
27 pub(crate) fn count_electrons(&self) -> usize { self.electrons }
30 pub enum Helium {}
//~ WARNING unreachable_pub
31 pub union Lithium { c1: usize, c2: u8 }
//~ WARNING unreachable_pub
32 pub fn beryllium() {}
//~ WARNING unreachable_pub
33 pub trait Boron {}
//~ WARNING unreachable_pub
34 pub const CARBON
: usize = 1; //~ WARNING unreachable_pub
35 pub static NITROGEN
: usize = 2; //~ WARNING unreachable_pub
36 pub type Oxygen
= bool
; //~ WARNING unreachable_pub
38 macro_rules
! define_empty_struct_with_visibility
{
39 ($visibility
: vis
, $name
: ident
) => { $visibility struct $name {}
}
40 //~^ WARNING unreachable_pub
42 define_empty_struct_with_visibility
!(pub, Fluorine
);
45 pub fn catalyze() -> bool
; //~ WARNING unreachable_pub
48 // items leaked through signatures (see `get_neon` below) are OK
51 // crate-visible items are OK
52 pub(crate) struct Sodium {}
56 // module is public: these are OK, too
57 pub struct Magnesium {}
58 pub(crate) struct Aluminum {}
61 pub fn get_neon() -> private_mod
::Neon
{