Rollup merge of #140874 - mejrs:rads, r=WaffleLapkin

make `rustc_attr_parsing` less dominant in the rustc crate graph

It has/had a glob re-export of `rustc_attr_data_structures`, which is a crate much lower in the graph, and a lot of crates were using it *just* (or *mostly*) for that re-export, while they can rely on `rustc_attr_data_structures` directly.

Previous graph:
![graph_1](https://github.com/user-attachments/assets/f4a5f13c-4222-4903-b56d-28c83511fcbd)

Graph with this PR:
![graph_2](https://github.com/user-attachments/assets/1e053d9c-75cc-402b-84df-86229c98277a)

The first commit keeps the re-export, and just changes the dependency if possible. The second commit is the "breaking change" which removes the re-export, and "explicitly" adds the `rustc_attr_data_structures` dependency where needed. It also switches over some src/tools/*.

The second commit is actually a lot more involved than I expected. Please let me know if it's a better idea to back it out and just keep the first commit.
This commit is contained in:
Stuart Cook 2025-05-19 13:24:54 +10:00 committed by GitHub
commit 599b08ada8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
72 changed files with 142 additions and 125 deletions

View file

@ -6,7 +6,7 @@ edition = "2024"
[dependencies]
# tidy-alphabetical-start
rustc_ast = { path = "../rustc_ast" }
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_attr_data_structures = { path = "../rustc_attr_data_structures" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }

View file

@ -20,7 +20,6 @@ use errors::{
};
use rustc_ast::MacroDef;
use rustc_ast::visit::{VisitorResult, try_visit};
use rustc_attr_parsing::AttributeKind;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::intern::Interned;
use rustc_errors::{MultiSpan, listify};
@ -40,7 +39,7 @@ use rustc_session::lint;
use rustc_span::hygiene::Transparency;
use rustc_span::{Ident, Span, Symbol, sym};
use tracing::debug;
use {rustc_attr_parsing as attr, rustc_hir as hir};
use {rustc_attr_data_structures as attrs, rustc_hir as hir};
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
@ -497,7 +496,7 @@ impl<'tcx> EmbargoVisitor<'tcx> {
let hir_id = self.tcx.local_def_id_to_hir_id(local_def_id);
let attrs = self.tcx.hir_attrs(hir_id);
if attr::find_attr!(attrs, AttributeKind::MacroTransparency(x) => *x)
if attrs::find_attr!(attrs, attrs::AttributeKind::MacroTransparency(x) => *x)
.unwrap_or(Transparency::fallback(md.macro_rules))
!= Transparency::Opaque
{