Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider not preferring pub(super) #7121

Open
kpreid opened this issue Feb 13, 2025 · 0 comments
Open

Consider not preferring pub(super) #7121

kpreid opened this issue Feb 13, 2025 · 0 comments
Labels
kind: refactor Making existing function faster or nicer type: enhancement New feature or request

Comments

@kpreid
Copy link
Contributor

kpreid commented Feb 13, 2025

Copied from review discussion:

@cwfitzgerald
Convention here is just pub(super)

@kpreid
IMO, using super, particularly across files, is fragile and best kept to a minimum, because it means that module-moving refactors can have surprising effects. I’ll change it anyway, but I am noting that I disagree with this policy.

@cwfitzgerald
Yeah that makes sense - I don't really have much of a preference either way, just following existing convention. Might be worth an issue about changing it. While hal backends have historically been a single mod + submodules, as we split things up more, we might see deeper splits.

Default private visibility is to this module (and children). pub(crate) limits visibilty to this crate. pub(in path) visibility is explicit about its purpose. pub(super) visibility is an oddball which limits visibility to whichever module happens to be this module’s parent. This is undesirable action-at-a-distance which can lead to, after refactoring, items being visible where they aren’t intended to be. I don’t think that this is a very serious problem, but I think that a policy of using pub(super) instead of pub(in path) is an unwise policy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: refactor Making existing function faster or nicer type: enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

2 participants