External Publication
Visit Post

[Pre-RFC] Bulk visibility syntax

Rust Internals [Unofficial] April 6, 2026
Source

This is a place where Aaron's reasoning footprint could help you analyze it, or some of the words in boat's not explicit post.

Thank you, I wish these were a part of the official guidelines. They're a lot more concrete and helpful to reason through whether if my proposal is warranted.

I would also suggest poking at exactly what you're trying to solve here. For example, is it as annoying if it's just pub rather than pub(in ...)? To me it feels not at all worth it for pub { ... }, for example. So there are alternatives like "what if we just have internal fn or something" to avoid the pub(crate).

Though not clear in the original post (that's my bad, I'm obviously new to proposing features), in my eyes this solves more than just poor aesthetics and unnecessary typing, it can also communicate relation (e.g. "these are the exports of this module") and actively help with refactoring adjacent visibility. Consider the following example:

mod a;
mod b;
mod c;
mod d;

Assuming these modules are related in some way (perhaps they are different kinds of AST nodes), if you wanted to publicize all of them you'd have to insert pub in front of each of them, but what if you change your mind and now have to make them pub(crate)? The syntax punishes you for iteration; by making your repeat yourself & forcing you to be explicit, for absolutely no underlying reason. Which is (from what I understand) against Rust's core philosophy, syntactic punishment is only appropriate in places where a practice should be actively discouraged. Obviously in this case it isn't intentional punishment, but punishment regardless.

You could argue that the punishment is actually warranted here because if it was easier to make everything in a module public, then people would abuse that. Which is a good point, however there is a real asymmetry in syntactic punishment involving pub. Because controlled publicity is even more punishing than full publicity, you could argue that it's grounds for people to use pub inappropriately in places where pub(crate) or similar would be more appropriate.

This happens [to me] quite a bit, especially while working on a complex crate that's also evolving. This syntax would definitely remedy the situation.

Of course you could argue that's a "you situation" and an extension of "I don't like typing", which is fair enough I suppose.

It is also worth considering the idea about allowing this syntax in struct/impl bodies as well, I think that could add more potential utility to the proposal.

Remember that extern "C" fn foo() { ... } and extern "C" { fn foo(); } are completely different. It's not that one is the bulk and the other isn't.

That's completely on me, I never used the extern "C" fn foo() { ... } syntax considering exporting symbols from rust is quite rare, so I wrongly deduced that it was the singular form of an extern "C" { ... } block. That's poor research on my part, my apologies. Though the use example still applies here.

Discussion in the ATmosphere

Loading comments...