diff options
| author | Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com> | 2021-01-05 15:16:56 +0100 |
|---|---|---|
| committer | Daniel Henry-Mantilla <daniel.henry.mantilla@gmail.com> | 2021-01-06 15:13:39 +0100 |
| commit | a4de27aeec7a8c876cce56561598898313a5a6bf (patch) | |
| tree | 28630f67dc2a096600747b0e15989dfaf135ccd9 | |
| parent | 255f107cacb8927e72798313d69fa83d2e752a20 (diff) | |
| download | rust-a4de27aeec7a8c876cce56561598898313a5a6bf.tar.gz rust-a4de27aeec7a8c876cce56561598898313a5a6bf.zip | |
Fixed non-declarative-nor-opaque macros effective privacy.
cc @petrochenkov
| -rw-r--r-- | compiler/rustc_privacy/src/lib.rs | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 6332130f80e..c2db2c82fa1 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -832,21 +832,15 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> { } fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef<'tcx>) { - // HACK (or fix?): a - // ```rust,ignore (dummy example) - // mod private { - // #[rustc_macro_transparency(semitransparent)] - // pub macro m { … } - // } - // ``` - // is *not* `Public`ly reachable and yet this shortcut would express - // that. - // FIXME! - if md.ast.macro_rules - && attr::find_transparency(&self.tcx.sess, &md.attrs, md.ast.macro_rules).0 - != Transparency::Opaque + // Non-opaque macros cannot make other items more accessible than they already are. + if attr::find_transparency(&self.tcx.sess, &md.attrs, md.ast.macro_rules).0 + != Transparency::Opaque { - self.update(md.hir_id, Some(AccessLevel::Public)); + // `#[macro_export]`-ed `macro_rules!` are `Public` since they + // ignore their containing path to always appear at the crate root. + if md.ast.macro_rules { + self.update(md.hir_id, Some(AccessLevel::Public)); + } return; } |
