Skip to content

Commit 600e45b

Browse files
committed
Add feature to set path-based visibility of macro_rules to pub by default
1 parent ee44706 commit 600e45b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

compiler/rustc_lint/src/builtin.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,12 @@ impl<'tcx> LateLintPass<'tcx> for UnreachablePub {
12881288
if let hir::ItemKind::Use(_, hir::UseKind::ListStem) = &item.kind {
12891289
return;
12901290
}
1291+
// Do not warn for macro_rules definitions which are pub and unreachable by default,
1292+
// only check their associated use re-exports.
1293+
if let hir::ItemKind::Macro(_, _, _) = &item.kind {
1294+
// TODO: How do I differentiate between `macro` and `macro_rules!` definitions?
1295+
return;
1296+
}
12911297
self.perform_lint(cx, "item", item.owner_id.def_id, item.vis_span, true);
12921298
}
12931299

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,11 +1299,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
12991299
let ident = ident.normalize_to_macros_2_0();
13001300
self.r.macro_names.insert(ident);
13011301
let is_macro_export = ast::attr::contains_name(&item.attrs, sym::macro_export);
1302-
let vis = if is_macro_export {
1303-
Visibility::Public
1304-
} else {
1305-
Visibility::Restricted(CRATE_DEF_ID)
1306-
};
1302+
let vis = Visibility::Public;
13071303
let binding = self.r.arenas.new_res_binding(res, vis.to_def_id(), span, expansion);
13081304
self.r.set_binding_parent_module(binding, parent_scope.module);
13091305
self.r.all_macro_rules.insert(ident.name);

0 commit comments

Comments
 (0)