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

edition lint: prefer crate to pub(crate) #52048

Closed
nrc opened this issue Jul 4, 2018 · 10 comments
Closed

edition lint: prefer crate to pub(crate) #52048

nrc opened this issue Jul 4, 2018 · 10 comments
Labels
A-edition-2018-lints Area: lints supporting the 2018 edition T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@nrc
Copy link
Member

nrc commented Jul 4, 2018

No description provided.

@nrc nrc added the A-edition-2018-lints Area: lints supporting the 2018 edition label Jul 4, 2018
@nrc nrc mentioned this issue Jul 4, 2018
15 tasks
@zackmdavis
Copy link
Member

Mentoring hints: study the unreachable_pub lint for an example of a lint that operates on visibility modifiers, except in this case, we probably want an EarlyLintPass (which operates on the AST rather than the HIR). The Item, ForeignItem, StructField, and ImplItem AST nodes all have a vis field of type Visibility. Visibility has two fields: span (a Span, representing the place in the source code that the visibility modifier takes up) and node (which is a VisibilityKind). We want the lint to fire if node is the variant VisibilityKind::Crate(CrateSugar) and the value it wraps is a CrateSugar::PubCrate. We should suggest (using span_suggestion_with_applicability) replacing the visibility span with the text crate.

@seanmonstar
Copy link
Contributor

What does this mean exactly? Will the lint warn if I use pub(crate)? Or this is more for rustfix?

I personally find pub(crate) much clearer as a visibility modifier than just crate. I'd probably even want a lint in the opposite direction (warn contributors to not change things to crate over pub(crate) in libraries I maintain.

@Centril Centril added the I-needs-decision Issue: In need of a decision. label Jul 11, 2018
@Manishearth
Copy link
Member

This is an edition lint; post edition upgrade this will ask you to replace pub(crate) with crate, via rustfix.

@seanmonstar
Copy link
Contributor

Is there a reason to push people from pub(crate) to crate? Why not allow (as in, leave alone) pub(crate) to stay?

@carllerche
Copy link
Member

👍 I agree, I find pub(crate) much clearer and will most likely stick with that.

@Manishearth
Copy link
Member

I feel like this issue is not the place to discuss this -- perhaps the tracking issue for the path changes? (I'm not sure where it should be discussed, I just find that implementation issues are not that place)

@seanmonstar
Copy link
Contributor

I get that, though the path changes tracking issue is so noisy, it'd get easily lost. Besides, the path changes doesn't seem to suggest that pub(crate) is deprecated, just that people who want to can change to crate. If that's the case, then this implementation issue might be slightly over-zealous.

@nikomatsakis nikomatsakis added I-nominated T-lang Relevant to the language team, which will review and decide on the PR/issue. labels Oct 4, 2018
@nikomatsakis
Copy link
Contributor

I believe we are not going to stabilize crate in Rust 2018, correct? If so, I nominate for removal from the milestone.

@scottmcm scottmcm removed this from the Edition 2018 RC 2 milestone Oct 4, 2018
@scottmcm scottmcm removed I-needs-decision Issue: In need of a decision. I-nominated labels Oct 4, 2018
@joshtriplett
Copy link
Member

Discussion in the @rust-lang/lang meeting came to the same conclusion: this is fundamentally tied to whether we add crate as a visibility modifier. If we do, we want this lint; if we don't, we don't.

@jplatte
Copy link
Contributor

jplatte commented Jun 14, 2023

crate was removed, pretty sure this can be closed.

@Manishearth Manishearth closed this as not planned Won't fix, can't repro, duplicate, stale Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edition-2018-lints Area: lints supporting the 2018 edition T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests