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

Regression: false positive from unreachable_pub lint #102352

Closed
djc opened this issue Sep 27, 2022 · 5 comments · Fixed by #103249
Closed

Regression: false positive from unreachable_pub lint #102352

djc opened this issue Sep 27, 2022 · 5 comments · Fixed by #103249
Assignees
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-visibility Area: Visibility / privacy C-bug Category: This is a bug. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone

Comments

@djc
Copy link
Contributor

djc commented Sep 27, 2022

Code

I tried this code:

#![deny(unreachable_pub)]

pub use crate::builder::Foo;

mod builder {
    pub struct Foo(pub(crate) ());
}

I expected to see no output from the compiler.

Instead, this happened:

djc-2021 main test-rs $ cargo +nightly c
    Checking test-rs v0.1.0 (/Users/djc/src/test-rs)
error: unreachable `pub` item
 --> src/lib.rs:3:9
  |
3 | pub use crate::builder::Foo;
  | ---     ^^^^^^^^^^^^^^^^^^^
  | |
  | help: consider restricting its visibility: `pub(crate)`
  |

cargo-bisect-rustc ouptut

searched nightlies: from nightly-2022-09-22 to nightly-2022-09-27
regressed nightly: nightly-2022-09-25
searched commit range: 4a14677...3f83906
regressed commit: 6580010

This is a roll-up, #102109 seems the most likely culprit. cc @petrochenkov @oli-obk

bisected with cargo-bisect-rustc v0.6.4

Host triple: aarch64-apple-darwin
Reproduce with:

cargo bisect-rustc --start=2022-09-22 

@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged

@djc djc added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Sep 27, 2022
@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. and removed regression-untriaged Untriaged performance or correctness regression. labels Sep 27, 2022
@apiraino
Copy link
Contributor

WG-prioritization assigning priority, probably a P-high since the lint malfunction is blocking valid code (iiuc)

@rustbot label -I-prioritize P-high T-compiler

@rustbot rustbot added P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Sep 28, 2022
@Mark-Simulacrum Mark-Simulacrum added this to the 1.66.0 milestone Sep 30, 2022
@pnkfelix pnkfelix added A-visibility Area: Visibility / privacy A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. labels Sep 30, 2022
@oli-obk oli-obk self-assigned this Sep 30, 2022
@oli-obk
Copy link
Contributor

oli-obk commented Sep 30, 2022

@petrochenkov any ideas how to address this or should I start digging in to it

@petrochenkov
Copy link
Contributor

In HIR pub use crate::builder::Foo; desugars into two items (import in type namespace and import in value namespace).
One of them is externally reachable and another is not (before #102109 both of them were incorrectly marked as externally reachable).

Code in compiler\rustc_lint\src\builtin.rs should somehow account for this desugaring and not report the pub as unnecessary if at least one of the imports is reachable.

@oli-obk
Copy link
Contributor

oli-obk commented Oct 19, 2022

I have been unable to fix this or apply a revert. @petrochenkov can you look at implementing this before the beta cutoff?

@petrochenkov
Copy link
Contributor

Reverted in #103249.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-visibility Area: Visibility / privacy C-bug Category: This is a bug. P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants