4 #![warn(unreachable_pub)]
7 // non-leaked `pub` items in private module should be linted
8 pub use std
::fmt
; //~ WARNING unreachable_pub
9 pub use std
::env
::{Args}
; // braced-use has different item spans than unbraced
10 //~^ WARNING unreachable_pub
12 pub struct Hydrogen
{ //~ WARNING unreachable_pub
13 // `pub` struct fields, too
14 pub neutrons
: usize, //~ WARNING unreachable_pub
15 // (... but not more-restricted fields)
16 pub(crate) electrons
: usize
20 pub fn count_neutrons(&self) -> usize { self.neutrons }
//~ WARNING unreachable_pub
21 pub(crate) fn count_electrons(&self) -> usize { self.electrons }
23 impl Clone
for Hydrogen
{
24 fn clone(&self) -> Hydrogen
{
25 Hydrogen { neutrons: self.neutrons, electrons: self.electrons }
29 pub enum Helium {}
//~ WARNING unreachable_pub
30 pub union Lithium { c1: usize, c2: u8 }
//~ WARNING unreachable_pub
31 pub fn beryllium() {}
//~ WARNING unreachable_pub
32 pub trait Boron {}
//~ WARNING unreachable_pub
33 pub const CARBON
: usize = 1; //~ WARNING unreachable_pub
34 pub static NITROGEN
: usize = 2; //~ WARNING unreachable_pub
35 pub type Oxygen
= bool
; //~ WARNING unreachable_pub
37 macro_rules
! define_empty_struct_with_visibility
{
38 ($visibility
: vis
, $name
: ident
) => { $visibility struct $name {}
}
39 //~^ WARNING unreachable_pub
41 define_empty_struct_with_visibility
!(pub, Fluorine
);
44 pub fn catalyze() -> bool
; //~ WARNING unreachable_pub
47 // items leaked through signatures (see `get_neon` below) are OK
50 // crate-visible items are OK
51 pub(crate) struct Sodium {}
55 // module is public: these are OK, too
56 pub struct Magnesium {}
57 pub(crate) struct Aluminum {}
60 pub fn get_neon() -> private_mod
::Neon
{