{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreicr37hqrvbkauq3sadu2ccrtoj7fh5wy3qqe574i352zq4ugfofbm",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mjviuoenmps2"
},
"path": "/t/pre-rfc-pub-api-visibility-and-static-enforcement-of-crate-internal-api-boundaries/24184#post_3",
"publishedAt": "2026-04-20T02:04:19.000Z",
"site": "https://internals.rust-lang.org",
"textContent": "`pub(in path)` had to have `in` added because `pub(not_a_keyword)` was ambiguous (in struct definitions? I don't remember the exact syntax quirk). It probably blocks `pub(api)` too. You might have something with a keyboard like variations of `pub(in mod)` or `pub(super api)`.\n\n> The `pub` visibility is only supposed to be used for items (types, traits, functions, etc.) that are part of the public API of the _crate_ , not the module.\n\nThat's not accurate. `pub` is for the module. It is unfortunately ambiguous (not locally explicit) whether `pub` means it's part of the crate's public-public API or not.\n\nAnd I'm disappointed that your proposal isn't the `pub` to clarify that reachability for `pub` items. I'd expect `pub(api)` to be that \"absolutely definitely externally `pub` from outside of the crate\", rather than a syntax sugar for internal non-public `pub(in path)` with a new invention for avoiding repeating the path.\n\nCouldn't you replace `!#[api]` with `use crate::something as api` and use `pub(in api)`?",
"title": "Pre-RFC: `pub(api)` visibility, and static enforcement of crate-internal API boundaries"
}