1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // This is just like unreachable_pub.rs, but without the
12 // `crate_visibility_modifier` feature (so that we can test the suggestions to
13 // use `pub(crate)` that are given when that feature is off, as opposed to the
14 // suggestions to use `crate` given when it is on). When that feature becomes
15 // stable, this test can be deleted.
21 #![warn(unreachable_pub)]
24 // non-leaked `pub` items in private module should be linted
26 pub use std::env::{Args}; // braced-use has different item spans than unbraced
29 // `pub` struct fields, too
31 // (... but not more-restricted fields)
32 pub(crate) electrons: usize
36 pub fn count_neutrons(&self) -> usize { self.neutrons }
37 pub(crate) fn count_electrons(&self) -> usize { self.electrons }
41 pub union Lithium { c1: usize, c2: u8 }
44 pub const CARBON: usize = 1;
45 pub static NITROGEN: usize = 2;
46 pub type Oxygen = bool;
48 macro_rules! define_empty_struct_with_visibility {
49 ($visibility: vis, $name: ident) => { $visibility struct $name {} }
51 define_empty_struct_with_visibility!(pub, Fluorine);
54 pub fn catalyze() -> bool;
57 // items leaked through signatures (see `get_neon` below) are OK
60 // crate-visible items are OK
61 pub(crate) struct Sodium {}
65 // module is public: these are OK, too
66 pub struct Magnesium {}
67 pub(crate) struct Aluminum {}
70 pub fn get_neon() -> private_mod::Neon {