Files
rust/compiler
Jonathan Brouwer 604d124199 Rollup merge of #156500 - Bryanskiy:macros_vis, r=petrochenkov
Privacy: move macros handling to early stage

The patch moves effective visibility computation for macros from `rustc_privacy` to `rustc_resolve`. It will enable this optimization: https://github.com/rust-lang/rust/pull/156228.

However, I found some problems with macro handling while I was doing this. The current implementation was written ~6 years ago and checks the reachability of a definition from a macro by nominal visibility. In general this is incorrect.

For example, in the current implementation modules are not traversed if their nominal visibility is less then the nominal visibility of a module defining macro: https://github.com/rust-lang/rust/blob/29b7590130c83542a095cdf1323ed0f78eec2bb8/compiler/rustc_privacy/src/lib.rs#L618-L626

As a result, in order to compile code like  `tests/ui/definition-reachable/auxiliary/field-method-macro.rs`. we have to additionally traverse types of adt fields: https://github.com/rust-lang/rust/blob/29b7590130c83542a095cdf1323ed0f78eec2bb8/compiler/rustc_privacy/src/lib.rs#L628-L638

This is a hack and the proper solution would be to check definitions with `EffectiveVisibilities::is_reachable`. I haven’t done this yet, as it would start to trigger many lints as more items become reachable. I think it’s better to leave the change to another commit.

r? @petrochenkov
2026-05-14 00:35:36 +02:00
..
2026-05-12 17:09:19 +02:00
2026-05-07 22:22:56 +09:00
2026-05-04 16:28:58 +00:00
2026-05-04 16:28:58 +00:00
2026-05-07 20:23:37 +03:00
2026-05-12 17:09:19 +02:00
2026-05-12 22:03:27 +02:00
2026-05-11 21:32:42 +02:00
2026-05-12 21:58:50 +02:00
2026-05-12 21:58:50 +02:00
2026-05-12 21:58:50 +02:00
2026-05-11 21:32:42 +02:00
2026-05-12 21:58:50 +02:00
2026-05-12 17:09:19 +02:00
2026-05-12 21:58:50 +02:00
2026-04-08 21:09:07 +02:00
2026-05-12 17:09:19 +02:00
2026-05-12 17:09:19 +02:00
2026-05-12 21:58:50 +02:00
2026-05-12 21:58:50 +02:00