{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreihpxgbys5znapamsbmeuhzlvt2zm2645pyhsvns624lmlhfq4jlui",
    "uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mit4zivm4nk2"
  },
  "path": "/t/pre-rfc-bulk-visibility-syntax/24136#post_1",
  "publishedAt": "2026-04-05T18:50:42.000Z",
  "site": "https://internals.rust-lang.org",
  "textContent": "# Summary\n\nHaving to insert `pub(...)` in front of multiple declarations in a row is very cumbersome, repetitive, and ugly:\n\n\n    pub(crate) use foo::Something;\n    pub(crate) fn bar() { ... }\n    pub(crate) mod baz { ... }\n    // etc.\n\n\nOf course a way around this would be via `mod` wrapping and `use module::*`, but it's obviously a workaround rather than an idiom. And you still have to declare all inner declarations `pub` anyways, which mostly defeats the purpose.\n\nSo I propose syntax to do this in bulk:\n\n\n    pub crate {\n      use foo::Something;\n      fn bar() { ... }\n      mod baz { ... }\n    }\n\n\nOr alternatively, the following syntax\n\n\n    pub(crate) {\n      use foo::Something;\n      fn bar() { ... }\n      mod baz { ... }\n    }\n\n\nIt would be essentially the same as bulk `extern \"X\" { ... }`.\n\n# Open to discussion\n\nA list of points that I was able to name off the top of my head that I think are worth discussing. By no means a complete list!\n\n## How would the compiler handle conflicting visibility qualifiers?\n\nAs mentioned earlier, bulk `extern` declarations already solve this by forbidding inner declarations from having an `extern` qualifier all together. Though this is open to discussion because `extern` and visibility qualifiers work in notably different ways internally.\n\n* * *\n\n## Should it also be allowed in `struct`/`impl` bodies?\n\nConsider the following examples in which this proposed syntax is used in `struct`/`impl` bodies.\n\n\n    struct Foo {\n      pub crate {\n        pub_crate_field0: u32,\n        pub_crate_field1: i32,\n      }\n      pub {\n        pub_field0: u32,\n        pub_field1: i32,\n      }\n      private_field: bool,\n    }\n\n    impl Foo {\n      pub crate {\n        fn pub_crate_method0() { ... }\n        fn pub_crate_method1() { ... }\n      }\n      pub {\n        fn pub_field0() { ... },\n        fn pub_field1() { ... },\n      }\n    }\n\n\n  * Will these create grammatical ambiguity?\n  * Do they adhere to Rust's core philosophy?\n  * Is the extra indentation worth it? (especially in `impl`)\n  * etc.\n\n\n\n* * *\n\n## rustdoc\n\nHow would this new syntax affect rustdoc? Would it make it difficult to document each sub-declaration?\n\n* * *\n\nAny and all feedback is appreciated, thank you in advance!",
  "title": "[Pre-RFC] Bulk visibility syntax"
}