Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,12 @@ impl<'tcx> LateLintPass<'tcx> for UnreachablePub {
if let hir::ItemKind::Use(_, hir::UseKind::ListStem) = &item.kind {
return;
}
// Do not warn for macro_rules definitions which are pub and unreachable by default,
// only check their associated use re-exports.
if let hir::ItemKind::Macro(_, _, _) = &item.kind {
// TODO: How do I differentiate between `macro` and `macro_rules!` definitions?
return;
}
self.perform_lint(cx, "item", item.owner_id.def_id, item.vis_span, true);
}

Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_resolve/src/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1299,11 +1299,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
let ident = ident.normalize_to_macros_2_0();
self.r.macro_names.insert(ident);
let is_macro_export = ast::attr::contains_name(&item.attrs, sym::macro_export);
let vis = if is_macro_export {
Visibility::Public
} else {
Visibility::Restricted(CRATE_DEF_ID)
};
let vis = Visibility::Public;
let binding = self.r.arenas.new_res_binding(res, vis.to_def_id(), span, expansion);
self.r.set_binding_parent_module(binding, parent_scope.module);
self.r.all_macro_rules.insert(ident.name);
Expand Down
Loading