]> git.lizzy.rs Git - rust.git/commit
Auto merge of #45569 - zackmdavis:unexported_pub_lint, r=petrochenkov
authorbors <bors@rust-lang.org>
Fri, 3 Nov 2017 16:28:24 +0000 (16:28 +0000)
committerbors <bors@rust-lang.org>
Fri, 3 Nov 2017 16:28:24 +0000 (16:28 +0000)
commit59d484575a714291481563d13ad058b9a3d31fa8
tree6051dd2e1575f007a9ed9d3d62970b16da63fd42
parent525b81d570b15df2ed5896f0215baea5c64c650c
parent085ec6d5286151fb06416965eb5ebaaf947b5ec8
Auto merge of #45569 - zackmdavis:unexported_pub_lint, r=petrochenkov

`unreachable-pub` lint (as authorized by RFC 2126)

To whom it may concern:

RFC 2126 commissions the creation of a lint for `pub` items that are not visible from crate root (#45521). We understand (but seek confirmation from more knowledgable compiler elders) that this can be implemented by linting HIR items that are _not_ ~~`cx.access_levels.is_exported`~~ `cx.access_levels.is_reachable` but have a `vis` (-ibility) field of `hir::Visibility::Public`.

The lint, tentatively called ~~`unexported-pub`~~ `unreachable-pub` (with the understanding that much could be written on the merits of various names, as it is said of the colors of bicycle-sheds), suggests `crate` as a replacement for `pub` if the `crate_visibility_modifier` feature is enabled (see #45388), and `pub(crate)` otherwise. We also use help messaging to suggest the other potential fix of exporting the item; feedback is desired as to whether this may be confusing or could be worded better.

As a preview of what respecting the proposed lint would look like (and to generate confirmatory evidence that this implementation doesn't issue false positives), ~~we take its suggestions for `libcore`~~ (save one, which is deferred to another pull request because it brings up an unrelated technical matter). I remain your obedient servant.

![unexported_pub](https://user-images.githubusercontent.com/1076988/32089794-fbd02420-baa0-11e7-87e5-3ec01f18924a.png)

r? @petrochenkov