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

No warning for unread pub struct field in private module #119545

Closed
tormeh opened this issue Jan 3, 2024 · 2 comments · Fixed by #119552
Closed

No warning for unread pub struct field in private module #119545

tormeh opened this issue Jan 3, 2024 · 2 comments · Fixed by #119552
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tormeh
Copy link

tormeh commented Jan 3, 2024

I tried this code:

fn main() {
    let _ = foo::Bar1{baz: false};
    let _ = foo::Bar2{baz: false};
}

mod foo {
    pub struct Bar1 {
        pub baz: bool,
    }

    pub(crate) struct Bar2 {
        pub baz: bool,
    }
}

I expected a "field baz is never read" warning for both Bar1 and Bar2 structs. Instead, I only got this warning for Bar2.

Meta

rustc --version --verbose:

rustc 1.75.0 (82e1608df 2023-12-21)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: x86_64-apple-darwin
release: 1.75.0
LLVM version: 17.0.6

Same behavior when running RUSTUP_TOOLCHAIN=nightly-2024-01-01-x86_64-apple-darwin cargo check

RUSTUP_TOOLCHAIN=nightly-2024-01-01-x86_64-apple-darwin rustc --version --verbose:

rustc 1.77.0-nightly (e51e98dde 2023-12-31)
binary: rustc
commit-hash: e51e98dde6a60637b6a71b8105245b629ac3fe77
commit-date: 2023-12-31
host: x86_64-apple-darwin
release: 1.77.0-nightly
LLVM version: 17.0.6
@tormeh tormeh added the C-bug Category: This is a bug. label Jan 3, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 3, 2024
@tormeh
Copy link
Author

tormeh commented Jan 3, 2024

In case it's relevant: The rest of the package consists of the results of running cargo new vistest with cargo 1.75.0, with no extra arguments.

@krtab
Copy link
Contributor

krtab commented Jan 3, 2024

@rustbot claim

@Noratrieb Noratrieb added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-visibility Area: Visibility / privacy T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 4, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Jan 16, 2024
…r=<try>

Replace visibility test with reachability test in dead code detection

Fixes rust-lang#119545

Also included is a fix for an error now flagged by the lint
bors added a commit to rust-lang-ci/rust that referenced this issue Jan 19, 2024
…r=cjgillot

Replace visibility test with reachability test in dead code detection

Fixes rust-lang#119545

Also included is a fix for an error now flagged by the lint
bors pushed a commit to rust-lang-ci/rust that referenced this issue Feb 25, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 25, 2024
…r=cjgillot

Replace visibility test with reachability test in dead code detection

Fixes rust-lang#119545

Also included is a fix for an error now flagged by the lint
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 3, 2024
…r=cjgillot

Replace visibility test with reachability test in dead code detection

Fixes rust-lang#119545

Also included is a fix for an error now flagged by the lint
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 9, 2024
…r=cjgillot

Replace visibility test with reachability test in dead code detection

Fixes rust-lang#119545

Also included is a fix for an error now flagged by the lint
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 22, 2024
…r=cjgillot,saethlin

Replace visibility test with reachability test in dead code detection

Fixes rust-lang#119545

Also included is a fix for an error now flagged by the lint
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 22, 2024
…r=cjgillot,saethlin

Replace visibility test with reachability test in dead code detection

Fixes rust-lang#119545

Also included is a fix for an error now flagged by the lint
bors added a commit to rust-lang-ci/rust that referenced this issue Mar 23, 2024
…r=cjgillot,saethlin

Replace visibility test with reachability test in dead code detection

Fixes rust-lang#119545

Also included is a fix for an error now flagged by the lint
@bors bors closed this as completed in a0fe413 Mar 23, 2024
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Mar 23, 2024
…t,saethlin

Replace visibility test with reachability test in dead code detection

Fixes rust-lang/rust#119545

Also included is a fix for an error now flagged by the lint
GuillaumeGomez pushed a commit to GuillaumeGomez/rustc_codegen_gcc that referenced this issue Mar 26, 2024
…t,saethlin

Replace visibility test with reachability test in dead code detection

Fixes rust-lang/rust#119545

Also included is a fix for an error now flagged by the lint
flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue Apr 4, 2024
…t,saethlin

Replace visibility test with reachability test in dead code detection

Fixes rust-lang/rust#119545

Also included is a fix for an error now flagged by the lint
lnicola pushed a commit to lnicola/rust-analyzer that referenced this issue Apr 7, 2024
…t,saethlin

Replace visibility test with reachability test in dead code detection

Fixes rust-lang/rust#119545

Also included is a fix for an error now flagged by the lint
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 27, 2024
…t,saethlin

Replace visibility test with reachability test in dead code detection

Fixes rust-lang/rust#119545

Also included is a fix for an error now flagged by the lint
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. 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.

4 participants