diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2022-05-17 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2022-05-17 00:00:00 +0000 |
| commit | 17f289345516662166a93a388b6225b862d1f238 (patch) | |
| tree | cb4f8ad5c0b0516b18119acd6b25a03b2d0f5a2f /compiler/rustc_privacy/src | |
| parent | c52b9c10bfb5164015eb977ff498e0597ae63eb1 (diff) | |
| download | rust-17f289345516662166a93a388b6225b862d1f238.tar.gz rust-17f289345516662166a93a388b6225b862d1f238.zip | |
Types with reachable constructors are reachable
Diffstat (limited to 'compiler/rustc_privacy/src')
| -rw-r--r-- | compiler/rustc_privacy/src/lib.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index ee459d9c129..86244aa8985 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -775,7 +775,14 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> { } // Corner case: if the variant is reachable, but its // enum is not, make the enum reachable as well. - self.update(item.def_id, variant_level); + self.reach(item.def_id, variant_level).ty(); + } + if let Some(hir_id) = variant.data.ctor_hir_id() { + let ctor_def_id = self.tcx.hir().local_def_id(hir_id); + let ctor_level = self.get(ctor_def_id); + if ctor_level.is_some() { + self.reach(item.def_id, ctor_level).ty(); + } } } } @@ -803,6 +810,13 @@ impl<'tcx> Visitor<'tcx> for EmbargoVisitor<'tcx> { } } } + if let Some(hir_id) = struct_def.ctor_hir_id() { + let ctor_def_id = self.tcx.hir().local_def_id(hir_id); + let ctor_level = self.get(ctor_def_id); + if ctor_level.is_some() { + self.reach(item.def_id, ctor_level).ty(); + } + } } } |
