Skip to content

Commit a4de27a

Browse files
Fixed non-declarative-nor-opaque macros effective privacy.
cc @petrochenkov
1 parent 255f107 commit a4de27a

File tree

1 file changed

+8
-14
lines changed
  • compiler/rustc_privacy/src

1 file changed

+8
-14
lines changed

compiler/rustc_privacy/src/lib.rs

+8-14
Original file line numberDiff line numberDiff line change
@@ -832,21 +832,15 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
832832
}
833833

834834
fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef<'tcx>) {
835-
// HACK (or fix?): a
836-
// ```rust,ignore (dummy example)
837-
// mod private {
838-
// #[rustc_macro_transparency(semitransparent)]
839-
// pub macro m { … }
840-
// }
841-
// ```
842-
// is *not* `Public`ly reachable and yet this shortcut would express
843-
// that.
844-
// FIXME!
845-
if md.ast.macro_rules
846-
&& attr::find_transparency(&self.tcx.sess, &md.attrs, md.ast.macro_rules).0
847-
!= Transparency::Opaque
835+
// Non-opaque macros cannot make other items more accessible than they already are.
836+
if attr::find_transparency(&self.tcx.sess, &md.attrs, md.ast.macro_rules).0
837+
!= Transparency::Opaque
848838
{
849-
self.update(md.hir_id, Some(AccessLevel::Public));
839+
// `#[macro_export]`-ed `macro_rules!` are `Public` since they
840+
// ignore their containing path to always appear at the crate root.
841+
if md.ast.macro_rules {
842+
self.update(md.hir_id, Some(AccessLevel::Public));
843+
}
850844
return;
851845
}
852846

0 commit comments

Comments
 (0)