]>
Commit | Line | Data |
---|---|---|
abe05a73 XL |
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. | |
6 | ||
416331ca | 7 | // build-pass (FIXME(62277): could be check-pass?) |
ff7c6d11 | 8 | |
abe05a73 XL |
9 | |
10 | #![allow(unused)] | |
11 | #![warn(unreachable_pub)] | |
12 | ||
13 | mod private_mod { | |
14 | // non-leaked `pub` items in private module should be linted | |
15 | pub use std::fmt; | |
94b46f34 | 16 | pub use std::env::{Args}; // braced-use has different item spans than unbraced |
abe05a73 XL |
17 | |
18 | pub struct Hydrogen { | |
19 | // `pub` struct fields, too | |
20 | pub neutrons: usize, | |
21 | // (... but not more-restricted fields) | |
22 | pub(crate) electrons: usize | |
23 | } | |
24 | impl Hydrogen { | |
25 | // impls, too | |
26 | pub fn count_neutrons(&self) -> usize { self.neutrons } | |
27 | pub(crate) fn count_electrons(&self) -> usize { self.electrons } | |
28 | } | |
29 | ||
30 | pub enum Helium {} | |
31 | pub union Lithium { c1: usize, c2: u8 } | |
32 | pub fn beryllium() {} | |
33 | pub trait Boron {} | |
34 | pub const CARBON: usize = 1; | |
35 | pub static NITROGEN: usize = 2; | |
36 | pub type Oxygen = bool; | |
37 | ||
38 | macro_rules! define_empty_struct_with_visibility { | |
39 | ($visibility: vis, $name: ident) => { $visibility struct $name {} } | |
40 | } | |
41 | define_empty_struct_with_visibility!(pub, Fluorine); | |
42 | ||
43 | extern { | |
44 | pub fn catalyze() -> bool; | |
45 | } | |
46 | ||
47 | // items leaked through signatures (see `get_neon` below) are OK | |
48 | pub struct Neon {} | |
49 | ||
50 | // crate-visible items are OK | |
51 | pub(crate) struct Sodium {} | |
52 | } | |
53 | ||
54 | pub mod public_mod { | |
55 | // module is public: these are OK, too | |
56 | pub struct Magnesium {} | |
57 | pub(crate) struct Aluminum {} | |
58 | } | |
59 | ||
60 | pub fn get_neon() -> private_mod::Neon { | |
61 | private_mod::Neon {} | |
62 | } | |
63 | ||
64 | fn main() { | |
65 | let _ = get_neon(); | |
66 | } |