-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Internal lint: Ban pub
re-exports
#65233
Comments
That specific example made me wonder if
|
I actually wanted to do the opposite thing and reexport the whole
That includes the symbol interner. |
I agree that it would be nice to cleanup random public reexports that are traces of various refactorings rather than conscious choices. |
Hm, I don't see this :) I see this as a very happy accident that Sharing data types would be a step back. Sharing state (the interner) would be even more problematic. |
Oh, my bad, I forgot that |
I would be ok with this change. Even leaving aside the library-ification question, I personally find the "facade" style sort of confusing -- I'm never quite sure which name I should be importing. I'd prefer if we had one canonical path that we used everywhere. I also like to use |
In Miri we currently make heavy use of public re-exports. Namely, OTOH, for hir/syntax-level things, I have often been confused myself by all the reexports. When seeing two types of the same name (e.g. in the docs, comparing to what I have in my code), I never know if those are genuinely different or if one is a reexport of the other. So maybe the lesson is that the Miri part works for me just because I know better? I am not sure. |
Would you be OK with just |
Sure, the question is more if you'd be okay with that. ;) |
Yeah sure, doesn't have to be all / at once or nothing with internal lints. :) |
I tried adding this (rust-lang/compiler-team#368) and it was rejected because it was too intrusive and people were used to using the re-exports. Does it still make sense to keep this open? |
Suggested lint name:
rustc::pub_reexport
.When given something like the following, reject it (as a lint):
cc #49509
Me and @Mark-Simulacrum were discussing library-ification and I mentioned to them how re-exports like this (specifically of
syntax_pos::hygiene
in the case of a refactoring I'm working on) was detrimental because it encourages relying on wider dependencies than strictly necessary. We want to fix the situation in #65031 and having this lint could help with that.@Mark-Simulacrum had the idea of introducing an internal lint to ban it. This will cause some large diffs for
syntax_pos::symbol::
in particular but that should be gradually fixable on a crate-by-crate basis through#![allow(...)]
and it is mostly mechanical.cc @oli-obk @nikomatsakis
The text was updated successfully, but these errors were encountered: