File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed
compiler/rustc_passes/src Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -434,12 +434,13 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> {
434434 let tcx = self . tcx ;
435435 let has_repr_c = self . repr_has_repr_c ;
436436 let has_repr_simd = self . repr_has_repr_simd ;
437+ let effective_visibilities = & tcx. effective_visibilities ( ( ) ) ;
437438 let live_fields = def. fields ( ) . iter ( ) . filter_map ( |f| {
438439 let def_id = f. def_id ;
439440 if has_repr_c || ( f. is_positional ( ) && has_repr_simd) {
440441 return Some ( def_id) ;
441442 }
442- if !tcx . visibility ( f. hir_id . owner . def_id ) . is_public ( ) {
443+ if !effective_visibilities . is_reachable ( f. hir_id . owner . def_id ) {
443444 return None ;
444445 }
445446 if tcx. visibility ( def_id) . is_public ( ) { Some ( def_id) } else { None }
Original file line number Diff line number Diff line change 1+ #![ deny( dead_code) ]
2+
3+ fn main ( ) {
4+ let _ = foo:: S { f : false } ;
5+ }
6+
7+ mod foo {
8+ pub struct S {
9+ pub f : bool , //~ ERROR field `f` is never read
10+ }
11+ }
Original file line number Diff line number Diff line change 1+ error: field `f` is never read
2+ --> $DIR/pub-field-in-priv-mod.rs:9:13
3+ |
4+ LL | pub struct S {
5+ | - field in this struct
6+ LL | pub f: bool,
7+ | ^
8+ |
9+ note: the lint level is defined here
10+ --> $DIR/pub-field-in-priv-mod.rs:1:9
11+ |
12+ LL | #![deny(dead_code)]
13+ | ^^^^^^^^^
14+
15+ error: aborting due to 1 previous error
16+
You can’t perform that action at this time.
0 commit comments