-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Lint unreachable_pub
got easily confused by multiple items in a single pub use ...
statement
#64762
Comments
unreachable_pub
got easily confused by multiple items in single pub use ...
statementunreachable_pub
got easily confused by multiple items in a single pub use ...
statement
Running into this myself. Right now I'm just If someone could lead me in the right direction, I'll give fixing this a shot. |
It also gets confused if the export happens via a glob, also on a single item (Playground). #![deny(unreachable_pub)]
mod m1 {
pub mod m2 {
pub use super::Item1;
}
pub struct Item1;
}
pub use m1::m2::*; |
…ccuring. Note: due to a compiler error, the root-level `metadata` re-exports had to be split into 3; see rust-lang/rust#64762
Added unreachable_pub lint which should help to prevent this issue from happening again. Note: due to a compiler error, the root-level `metadata` re-exports had to be split into 3; see rust-lang/rust#64762
Looks like this is because of #57922 (comment) |
Also, remove the `unreachable_pub` lint, which suggested the erroneous change. Rust issue: rust-lang/rust#64762
Sadly, due to a known issue ([#64762]) with the lint, `pub` items that are exposed through multi-item intermediate `pub use` re-exports trigger false positives with the lint. There are two ways of working around this: 1. Avoiding multi-item `pub use` statements. This leads to swathes of mostly redundant `pub use` lines, especially on modules like `types`. 2. Leaking the structure of nested modules up to a reachable `pub use`. This leaves the export-point vulnerable to module reorganisation. For this module, option 2 was chosen due to the sheer number of re-exported items, and the relatively shallow module hierarchies. [#64726]: rust-lang/rust#64762
@rustbot claim |
Since I claimed it 8 days ago, just a follow up. tl;dr: I haven't given up! |
How to fix this: #82064. |
…, r=petrochenkov Fixes wrong unreachable_pub lints on nested and glob public reexport Linked issues: rust-lang#64762 & rust-lang#82064
Closed by #87487 |
This code (playground) trips
unreachable_pub
lint (while being completely legit).However, if we break the top-level
pub use ...
statement into two separate statements (playground) -unreachable_pub
lint convinces itself that the code is, indeed, legit.The text was updated successfully, but these errors were encountered: