|
| 1 | +//@ edition: 2024 |
| 2 | +//@ aux-crate: helper=doc_hidden_helper.rs |
| 3 | + |
| 4 | +// Test that `#[doc(hidden)]` items in other crates do not disqualify another |
| 5 | +// item with the same name from path trimming in diagnostics. |
| 6 | + |
| 7 | +// Declare several modules and types whose short names match those in the aux crate. |
| 8 | +// |
| 9 | +// Of these, only `ActuallyPub` and `ActuallyPubInPubMod` should be disqualified |
| 10 | +// from path trimming, because the other names only collide with `#[doc(hidden)]` |
| 11 | +// names. |
| 12 | +mod local { |
| 13 | + pub(crate) struct ActuallyPub {} |
| 14 | + pub(crate) struct DocHidden {} |
| 15 | + |
| 16 | + pub(crate) mod pub_mod { |
| 17 | + pub(crate) struct ActuallyPubInPubMod {} |
| 18 | + pub(crate) struct DocHiddenInPubMod {} |
| 19 | + } |
| 20 | + |
| 21 | + pub(crate) mod hidden_mod { |
| 22 | + pub(crate) struct ActuallyPubInHiddenMod {} |
| 23 | + pub(crate) struct DocHiddenInHiddenMod {} |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +fn main() { |
| 28 | + uses_local(); |
| 29 | + uses_helper(); |
| 30 | +} |
| 31 | + |
| 32 | +fn uses_local() { |
| 33 | + use local::{ActuallyPub, DocHidden}; |
| 34 | + use local::pub_mod::{ActuallyPubInPubMod, DocHiddenInPubMod}; |
| 35 | + use local::hidden_mod::{ActuallyPubInHiddenMod, DocHiddenInHiddenMod}; |
| 36 | + |
| 37 | + let _: ( |
| 38 | + //~^ NOTE expected due to this |
| 39 | + ActuallyPub, |
| 40 | + DocHidden, |
| 41 | + ActuallyPubInPubMod, |
| 42 | + DocHiddenInPubMod, |
| 43 | + ActuallyPubInHiddenMod, |
| 44 | + DocHiddenInHiddenMod, |
| 45 | + ) = 3u32; |
| 46 | + //~^ ERROR mismatched types [E0308] |
| 47 | + //~| NOTE expected `(ActuallyPub, ..., ..., ..., ..., ...)`, found `u32` |
| 48 | + //~| NOTE expected tuple `(local::ActuallyPub, local::DocHidden, local::pub_mod::ActuallyPubInPubMod, local::pub_mod::DocHiddenInPubMod, local::hidden_mod::ActuallyPubInHiddenMod, local::hidden_mod::DocHiddenInHiddenMod)` |
| 49 | +} |
| 50 | + |
| 51 | +fn uses_helper() { |
| 52 | + use helper::{ActuallyPub, DocHidden}; |
| 53 | + use helper::pub_mod::{ActuallyPubInPubMod, DocHiddenInPubMod}; |
| 54 | + use helper::hidden_mod::{ActuallyPubInHiddenMod, DocHiddenInHiddenMod}; |
| 55 | + |
| 56 | + let _: ( |
| 57 | + //~^ NOTE expected due to this |
| 58 | + ActuallyPub, |
| 59 | + DocHidden, |
| 60 | + ActuallyPubInPubMod, |
| 61 | + DocHiddenInPubMod, |
| 62 | + ActuallyPubInHiddenMod, |
| 63 | + DocHiddenInHiddenMod, |
| 64 | + ) = 3u32; |
| 65 | + //~^ ERROR mismatched types [E0308] |
| 66 | + //~| NOTE expected `(ActuallyPub, ..., ..., ..., ..., ...)`, found `u32` |
| 67 | + //~| NOTE expected tuple `(doc_hidden_helper::ActuallyPub, doc_hidden_helper::DocHidden, doc_hidden_helper::pub_mod::ActuallyPubInPubMod, doc_hidden_helper::pub_mod::DocHiddenInPubMod, doc_hidden_helper::hidden_mod::ActuallyPubInHiddenMod, doc_hidden_helper::hidden_mod::DocHiddenInHiddenMod)` |
| 68 | +} |
0 commit comments