Skip to content

Commit e7ec428

Browse files
authored
Rollup merge of #111496 - mpalmer:unreachable-pub-docs, r=pnkfelix
Extra context for unreachable_pub lint While experienced Rustaceans no doubt know this sort of thing already, as more of a newbie I had trouble understanding why I was triggering the lint. Hopefully this expanded explanation saves someone else some head-scratching. Fixes #110922
2 parents 789dd0b + 3e71f4d commit e7ec428

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

compiler/rustc_lint/src/builtin.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1317,10 +1317,14 @@ declare_lint! {
13171317
///
13181318
/// ### Explanation
13191319
///
1320-
/// A bare `pub` visibility may be misleading if the item is not actually
1321-
/// publicly exported from the crate. The `pub(crate)` visibility is
1322-
/// recommended to be used instead, which more clearly expresses the intent
1323-
/// that the item is only visible within its own crate.
1320+
/// The `pub` keyword both expresses an intent for an item to be publicly available, and also
1321+
/// signals to the compiler to make the item publicly accessible. The intent can only be
1322+
/// satisfied, however, if all items which contain this item are *also* publicly accessible.
1323+
/// Thus, this lint serves to identify situations where the intent does not match the reality.
1324+
///
1325+
/// If you wish the item to be accessible elsewhere within the crate, but not outside it, the
1326+
/// `pub(crate)` visibility is recommended to be used instead. This more clearly expresses the
1327+
/// intent that the item is only visible within its own crate.
13241328
///
13251329
/// This lint is "allow" by default because it will trigger for a large
13261330
/// amount existing Rust code, and has some false-positives. Eventually it

0 commit comments

Comments
 (0)