From ef151d65d26755f1e063e74e7ff16ef02991eaf0 Mon Sep 17 00:00:00 2001 From: mejrs <59372212+mejrs@users.noreply.github.com> Date: Mon, 10 Aug 2026 11:43:54 +0200 Subject: [PATCH 1/5] rustc_attr_parsing: depend on rustc_attr_ir instead of rustc_hir --- Cargo.lock | 2 +- compiler/rustc_attr_parsing/Cargo.toml | 2 +- .../src/attributes/autodiff.rs | 4 ++-- .../rustc_attr_parsing/src/attributes/cfg.rs | 4 ++-- .../src/attributes/cfg_select.rs | 4 ++-- .../src/attributes/codegen_attrs.rs | 7 +++---- .../src/attributes/crate_level.rs | 2 +- .../src/attributes/debugger.rs | 2 +- .../src/attributes/deprecation.rs | 3 +-- .../attributes/diagnostic/do_not_recommend.rs | 4 ++-- .../src/attributes/diagnostic/mod.rs | 4 ++-- .../src/attributes/diagnostic/on_const.rs | 2 +- .../src/attributes/diagnostic/on_move.rs | 2 +- .../src/attributes/diagnostic/on_type_error.rs | 2 +- .../attributes/diagnostic/on_unimplemented.rs | 2 +- .../src/attributes/diagnostic/on_unknown.rs | 2 +- .../attributes/diagnostic/on_unmatched_args.rs | 2 +- .../src/attributes/diagnostic/opaque.rs | 4 ++-- .../rustc_attr_parsing/src/attributes/doc.rs | 10 +++++----- .../rustc_attr_parsing/src/attributes/dummy.rs | 2 +- .../rustc_attr_parsing/src/attributes/inline.rs | 3 +-- .../src/attributes/instruction_set.rs | 2 +- .../src/attributes/link_attrs.rs | 4 ++-- .../src/attributes/lint_helpers.rs | 3 +-- .../src/attributes/macro_attrs.rs | 3 +-- .../rustc_attr_parsing/src/attributes/mod.rs | 2 +- .../src/attributes/non_exhaustive.rs | 4 ++-- .../rustc_attr_parsing/src/attributes/pin_v2.rs | 4 ++-- .../rustc_attr_parsing/src/attributes/prelude.rs | 4 ++-- .../src/attributes/prototype.rs | 4 ++-- .../rustc_attr_parsing/src/attributes/repr.rs | 6 +++--- .../src/attributes/rustc_dump.rs | 4 ++-- .../src/attributes/rustc_internal.rs | 10 +++++----- .../src/attributes/semantics.rs | 2 +- .../src/attributes/stability.rs | 11 +++++------ .../src/attributes/test_attrs.rs | 2 +- .../rustc_attr_parsing/src/attributes/unroll.rs | 2 +- .../rustc_attr_parsing/src/attributes/util.rs | 2 +- compiler/rustc_attr_parsing/src/context.rs | 6 +++--- compiler/rustc_attr_parsing/src/diagnostics.rs | 3 +-- compiler/rustc_attr_parsing/src/interface.rs | 4 ++-- compiler/rustc_attr_parsing/src/lib.rs | 6 +++--- compiler/rustc_attr_parsing/src/parser.rs | 4 ++-- compiler/rustc_attr_parsing/src/safety.rs | 2 +- compiler/rustc_attr_parsing/src/stability.rs | 2 +- compiler/rustc_attr_parsing/src/synthetic.rs | 8 ++++---- .../rustc_attr_parsing/src/target_checking.rs | 16 ++++++++-------- compiler/rustc_attr_parsing/src/validate_attr.rs | 2 +- 48 files changed, 92 insertions(+), 99 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7f1d44eca7b9e..31f36a017be2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3725,10 +3725,10 @@ dependencies = [ "rustc_abi", "rustc_ast", "rustc_ast_pretty", + "rustc_attr_ir", "rustc_data_structures", "rustc_errors", "rustc_feature", - "rustc_hir", "rustc_lexer", "rustc_lint_defs", "rustc_macros", diff --git a/compiler/rustc_attr_parsing/Cargo.toml b/compiler/rustc_attr_parsing/Cargo.toml index 7542cb4bbec26..70161a7961815 100644 --- a/compiler/rustc_attr_parsing/Cargo.toml +++ b/compiler/rustc_attr_parsing/Cargo.toml @@ -8,10 +8,10 @@ edition = "2024" rustc_abi = { path = "../rustc_abi" } rustc_ast = { path = "../rustc_ast" } rustc_ast_pretty = { path = "../rustc_ast_pretty" } +rustc_attr_ir = { path = "../rustc_attr_ir" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_errors = { path = "../rustc_errors" } rustc_feature = { path = "../rustc_feature" } -rustc_hir = { path = "../rustc_hir" } rustc_lexer = { path = "../rustc_lexer" } rustc_lint_defs = { path = "../rustc_lint_defs" } rustc_macros = { path = "../rustc_macros" } diff --git a/compiler/rustc_attr_parsing/src/attributes/autodiff.rs b/compiler/rustc_attr_parsing/src/attributes/autodiff.rs index 78ed4ff46d997..111aca58e424c 100644 --- a/compiler/rustc_attr_parsing/src/attributes/autodiff.rs +++ b/compiler/rustc_attr_parsing/src/attributes/autodiff.rs @@ -2,9 +2,9 @@ use std::str::FromStr; use rustc_ast::LitKind; use rustc_ast::expand::autodiff_attrs::{DiffActivity, DiffMode}; +use rustc_attr_ir::target::{MethodKind, Target}; +use rustc_attr_ir::{AttributeKind, RustcAutodiff}; use rustc_feature::AttributeStability; -use rustc_hir::attrs::{AttributeKind, RustcAutodiff}; -use rustc_hir::{MethodKind, Target}; use rustc_span::{Symbol, sym}; use thin_vec::ThinVec; diff --git a/compiler/rustc_attr_parsing/src/attributes/cfg.rs b/compiler/rustc_attr_parsing/src/attributes/cfg.rs index 9ac15a5dc87b7..7899ed0614a34 100644 --- a/compiler/rustc_attr_parsing/src/attributes/cfg.rs +++ b/compiler/rustc_attr_parsing/src/attributes/cfg.rs @@ -3,10 +3,10 @@ use std::convert::identity; use rustc_ast::token::Delimiter; use rustc_ast::tokenstream::{DelimSpan, WithTokens}; use rustc_ast::{AttrItem, Attribute, LitKind, ast, token}; +use rustc_attr_ir::target::Target; +use rustc_attr_ir::{AttrPath, CfgEntry, RustcVersion}; use rustc_errors::{Applicability, Diagnostic, PResult, msg}; use rustc_feature::{Features, GatedCfg, find_gated_cfg}; -use rustc_hir::attrs::{CfgEntry, RustcVersion}; -use rustc_hir::{AttrPath, Target}; use rustc_parse::parser::{ForceCollect, Parser, Recovery}; use rustc_parse::{exp, parse_in}; use rustc_session::Session; diff --git a/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs b/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs index 6d2ee2426dd4a..63a289691794b 100644 --- a/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs +++ b/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs @@ -1,11 +1,11 @@ use rustc_ast::token::Token; use rustc_ast::tokenstream::TokenStream; use rustc_ast::{AttrStyle, NodeId, token}; +use rustc_attr_ir::target::Target; +use rustc_attr_ir::{AttrPath, CfgEntry}; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{Diagnostic, MultiSpan}; use rustc_feature::Features; -use rustc_hir::attrs::CfgEntry; -use rustc_hir::{AttrPath, Target}; use rustc_parse::exp; use rustc_parse::parser::{Parser, Recovery}; use rustc_session::Session; diff --git a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs index 1e56b65c633b1..feed600d44df4 100644 --- a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs @@ -1,8 +1,7 @@ -use rustc_feature::AttributeStability; -use rustc_hir::attrs::{ - CoverageAttrKind, InstrumentFnAttr, OptimizeAttr, RtsanSetting, SanitizerSet, UsedBy, +use rustc_attr_ir::{ + CoverageAttrKind, InstrumentFnAttr, OptimizeAttr, RtsanSetting, SanitizerSet, UsedBy, find_attr, }; -use rustc_hir::find_attr; +use rustc_feature::AttributeStability; use rustc_session::diagnostics::feature_err; use rustc_span::edition::Edition::Edition2024; diff --git a/compiler/rustc_attr_parsing/src/attributes/crate_level.rs b/compiler/rustc_attr_parsing/src/attributes/crate_level.rs index bc8b4a71697e1..d9d93579805c6 100644 --- a/compiler/rustc_attr_parsing/src/attributes/crate_level.rs +++ b/compiler/rustc_attr_parsing/src/attributes/crate_level.rs @@ -1,6 +1,6 @@ +use rustc_attr_ir::{CrateType, WindowsSubsystemKind}; use rustc_data_structures::fx::FxIndexSet; use rustc_feature::AttributeStability; -use rustc_hir::attrs::{CrateType, WindowsSubsystemKind}; use rustc_session::lint::builtin::{DUPLICATE_TOOLS, UNKNOWN_CRATE_TYPES}; use rustc_span::Symbol; use rustc_span::edit_distance::find_best_match_for_name_with_substrings; diff --git a/compiler/rustc_attr_parsing/src/attributes/debugger.rs b/compiler/rustc_attr_parsing/src/attributes/debugger.rs index b514235a48eca..956aafcf5ec7a 100644 --- a/compiler/rustc_attr_parsing/src/attributes/debugger.rs +++ b/compiler/rustc_attr_parsing/src/attributes/debugger.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::{DebugVisualizer, DebuggerVisualizerType}; use rustc_feature::AttributeStability; -use rustc_hir::attrs::{DebugVisualizer, DebuggerVisualizerType}; use super::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/deprecation.rs b/compiler/rustc_attr_parsing/src/attributes/deprecation.rs index c3fadb9f41489..fb35e5169caba 100644 --- a/compiler/rustc_attr_parsing/src/attributes/deprecation.rs +++ b/compiler/rustc_attr_parsing/src/attributes/deprecation.rs @@ -1,7 +1,6 @@ use rustc_ast::LitKind; +use rustc_attr_ir::{DeprecatedSince, Deprecation, RustcVersion, VERSION_PLACEHOLDER}; use rustc_feature::AttributeStability; -use rustc_hir::VERSION_PLACEHOLDER; -use rustc_hir::attrs::{DeprecatedSince, Deprecation, RustcVersion}; use super::prelude::*; use super::util::parse_version; diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/do_not_recommend.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/do_not_recommend.rs index 250326db42bb7..868c77517052a 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/do_not_recommend.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/do_not_recommend.rs @@ -1,6 +1,6 @@ +use rustc_attr_ir::AttributeKind; +use rustc_attr_ir::target::Target; use rustc_feature::AttributeStability; -use rustc_hir::Target; -use rustc_hir::attrs::AttributeKind; use rustc_session::lint::builtin::MALFORMED_DIAGNOSTIC_ATTRIBUTES; use rustc_span::{Symbol, sym}; diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs index a813e0ba02a89..60d80310b0f85 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs @@ -1,11 +1,11 @@ use std::ops::Range; use rustc_ast::PathSegment; -use rustc_errors::{Diagnostic, MultiSpan}; -use rustc_hir::attrs::diagnostic::{ +use rustc_attr_ir::diagnostic::{ Directive, Filter, FilterFormatString, Flag, FormatArg, FormatString, LitOrArg, Name, NameValue, Piece, Predicate, }; +use rustc_errors::{Diagnostic, MultiSpan}; use rustc_lint_defs::LintId; use rustc_parse_format::{ Argument, FormatSpec, ParseError, ParseMode, Parser, Piece as RpfPiece, Position, diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_const.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_const.rs index f92a7694ec357..61ebe13bfb98d 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_const.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_const.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::diagnostic::Directive; use rustc_feature::AttributeStability; -use rustc_hir::attrs::diagnostic::Directive; use crate::attributes::diagnostic::*; use crate::attributes::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_move.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_move.rs index dcba5d5b301a6..9f8e120353c7f 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_move.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_move.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::AttributeKind; use rustc_feature::AttributeStability; -use rustc_hir::attrs::AttributeKind; use rustc_span::sym; use crate::attributes::diagnostic::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_type_error.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_type_error.rs index 1bdde3af7f0eb..ea980c7da0cd5 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_type_error.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_type_error.rs @@ -1,4 +1,4 @@ -use rustc_hir::attrs::AttributeKind; +use rustc_attr_ir::AttributeKind; use rustc_span::sym; use crate::attributes::AttributeStability; diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unimplemented.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unimplemented.rs index bd82a532c1c3c..9975b2795be4f 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unimplemented.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unimplemented.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::diagnostic::Directive; use rustc_feature::AttributeStability; -use rustc_hir::attrs::diagnostic::Directive; use crate::attributes::diagnostic::*; use crate::attributes::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unknown.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unknown.rs index 029d971910e5e..58e2d37f7cdaf 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unknown.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unknown.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::diagnostic::Directive; use rustc_feature::AttributeStability; -use rustc_hir::attrs::diagnostic::Directive; use crate::attributes::diagnostic::*; use crate::attributes::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unmatched_args.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unmatched_args.rs index 41ed6df43063e..14918b26e8dc2 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unmatched_args.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unmatched_args.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::diagnostic::Directive; use rustc_feature::AttributeStability; -use rustc_hir::attrs::diagnostic::Directive; use crate::attributes::diagnostic::*; use crate::attributes::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/opaque.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/opaque.rs index 0864b76f0e030..d29c2ee654d20 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/opaque.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/opaque.rs @@ -1,6 +1,6 @@ +use rustc_attr_ir::AttributeKind; +use rustc_attr_ir::target::Target; use rustc_feature::AttributeStability; -use rustc_hir::Target; -use rustc_hir::attrs::AttributeKind; use rustc_session::lint::builtin::MALFORMED_DIAGNOSTIC_ATTRIBUTES; use rustc_span::{Span, sym}; diff --git a/compiler/rustc_attr_parsing/src/attributes/doc.rs b/compiler/rustc_attr_parsing/src/attributes/doc.rs index 897dea6cd49f9..492c2eb028f96 100644 --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs @@ -1,12 +1,12 @@ use rustc_ast::ast::{AttrStyle, LitKind, MetaItemLit}; -use rustc_data_structures::fx::{FxHashSet, FxIndexMap, IndexEntry}; -use rustc_errors::{Applicability, msg}; -use rustc_feature::AttributeStability; -use rustc_hir::Target; -use rustc_hir::attrs::{ +use rustc_attr_ir::target::Target; +use rustc_attr_ir::{ AttributeKind, CfgEntry, CfgHideShow, DocAttribute, DocCfgHideShow, DocCfgHideShowValue, DocInline, HideOrShow, }; +use rustc_data_structures::fx::{FxHashSet, FxIndexMap, IndexEntry}; +use rustc_errors::{Applicability, msg}; +use rustc_feature::AttributeStability; use rustc_session::diagnostics::feature_err; use rustc_span::{Span, Symbol, edition, sym}; diff --git a/compiler/rustc_attr_parsing/src/attributes/dummy.rs b/compiler/rustc_attr_parsing/src/attributes/dummy.rs index 425637b694e98..fec42f43d035a 100644 --- a/compiler/rustc_attr_parsing/src/attributes/dummy.rs +++ b/compiler/rustc_attr_parsing/src/attributes/dummy.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::AttributeKind; use rustc_feature::AttributeStability; -use rustc_hir::attrs::AttributeKind; use rustc_span::{Symbol, sym}; use crate::attributes::{OnDuplicate, SingleAttributeParser}; diff --git a/compiler/rustc_attr_parsing/src/attributes/inline.rs b/compiler/rustc_attr_parsing/src/attributes/inline.rs index c3972b23eb101..6ec78843fabd0 100644 --- a/compiler/rustc_attr_parsing/src/attributes/inline.rs +++ b/compiler/rustc_attr_parsing/src/attributes/inline.rs @@ -1,6 +1,5 @@ +use rustc_attr_ir::{AttributeKind, InlineAttr, find_attr}; use rustc_feature::AttributeStability; -use rustc_hir::attrs::{AttributeKind, InlineAttr}; -use rustc_hir::find_attr; use rustc_session::lint::builtin::ILL_FORMED_ATTRIBUTE_INPUT; use super::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs b/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs index afca9845f8cbe..6c470f0587732 100644 --- a/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs +++ b/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::InstructionSetAttr; use rustc_feature::AttributeStability; -use rustc_hir::attrs::InstructionSetAttr; use super::prelude::*; use crate::diagnostics; diff --git a/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs index ed44cb1d5afc9..6289b1c726684 100644 --- a/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs @@ -1,7 +1,7 @@ +use rustc_attr_ir::AttributeKind::{LinkName, LinkOrdinal, LinkSection}; +use rustc_attr_ir::*; use rustc_errors::msg; use rustc_feature::{AttributeStability, Features}; -use rustc_hir::attrs::AttributeKind::{LinkName, LinkOrdinal, LinkSection}; -use rustc_hir::attrs::*; use rustc_session::Session; use rustc_session::diagnostics::feature_err; use rustc_session::lint::builtin::ILL_FORMED_ATTRIBUTE_INPUT; diff --git a/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs b/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs index 719afeb1de0d1..4ead90af8d630 100644 --- a/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs +++ b/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs @@ -1,6 +1,5 @@ +use rustc_attr_ir::{ReprAttr, find_attr}; use rustc_feature::AttributeStability; -use rustc_hir::attrs::ReprAttr; -use rustc_hir::find_attr; use super::prelude::*; use crate::diagnostics::RustcPubTransparent; diff --git a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs index d382a948bffca..9301323c28df3 100644 --- a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs @@ -1,6 +1,5 @@ +use rustc_attr_ir::{CollapseMacroDebuginfo, MacroUseArgs, find_attr}; use rustc_feature::AttributeStability; -use rustc_hir::attrs::{CollapseMacroDebuginfo, MacroUseArgs}; -use rustc_hir::find_attr; use rustc_session::lint::builtin::INVALID_MACRO_EXPORT_ARGUMENTS; use super::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/mod.rs b/compiler/rustc_attr_parsing/src/attributes/mod.rs index 09db8dcb84785..242b4a73b06a6 100644 --- a/compiler/rustc_attr_parsing/src/attributes/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/mod.rs @@ -20,8 +20,8 @@ use std::marker::PhantomData; +use rustc_attr_ir::AttributeKind; use rustc_feature::AttributeStability; -use rustc_hir::attrs::AttributeKind; use rustc_span::edition::Edition; use rustc_span::{Span, Symbol}; use thin_vec::ThinVec; diff --git a/compiler/rustc_attr_parsing/src/attributes/non_exhaustive.rs b/compiler/rustc_attr_parsing/src/attributes/non_exhaustive.rs index cbbaad445f70f..48e97784a2286 100644 --- a/compiler/rustc_attr_parsing/src/attributes/non_exhaustive.rs +++ b/compiler/rustc_attr_parsing/src/attributes/non_exhaustive.rs @@ -1,6 +1,6 @@ +use rustc_attr_ir::AttributeKind; +use rustc_attr_ir::target::Target; use rustc_feature::AttributeStability; -use rustc_hir::Target; -use rustc_hir::attrs::AttributeKind; use rustc_span::{Span, Symbol, sym}; use crate::attributes::{NoArgsAttributeParser, OnDuplicate}; diff --git a/compiler/rustc_attr_parsing/src/attributes/pin_v2.rs b/compiler/rustc_attr_parsing/src/attributes/pin_v2.rs index 59c35690d3c93..acd64b0c7be39 100644 --- a/compiler/rustc_attr_parsing/src/attributes/pin_v2.rs +++ b/compiler/rustc_attr_parsing/src/attributes/pin_v2.rs @@ -1,6 +1,6 @@ +use rustc_attr_ir::AttributeKind; +use rustc_attr_ir::target::Target; use rustc_feature::AttributeStability; -use rustc_hir::Target; -use rustc_hir::attrs::AttributeKind; use rustc_span::{Span, Symbol, sym}; use crate::attributes::NoArgsAttributeParser; diff --git a/compiler/rustc_attr_parsing/src/attributes/prelude.rs b/compiler/rustc_attr_parsing/src/attributes/prelude.rs index 744d5368580d8..0721d6f1926ae 100644 --- a/compiler/rustc_attr_parsing/src/attributes/prelude.rs +++ b/compiler/rustc_attr_parsing/src/attributes/prelude.rs @@ -1,8 +1,8 @@ // data structures #[doc(hidden)] -pub(super) use rustc_hir::attrs::AttributeKind; +pub(super) use rustc_attr_ir::AttributeKind; #[doc(hidden)] -pub(super) use rustc_hir::{MethodKind, Target}; +pub(super) use rustc_attr_ir::target::{MethodKind, Target}; #[doc(hidden)] pub(super) use rustc_span::{Ident, Span, Symbol, sym}; #[doc(hidden)] diff --git a/compiler/rustc_attr_parsing/src/attributes/prototype.rs b/compiler/rustc_attr_parsing/src/attributes/prototype.rs index 48f65c2434584..a681d3f2fa971 100644 --- a/compiler/rustc_attr_parsing/src/attributes/prototype.rs +++ b/compiler/rustc_attr_parsing/src/attributes/prototype.rs @@ -1,8 +1,8 @@ //! Attributes that are only used on function prototypes. +use rustc_attr_ir::target::Target; +use rustc_attr_ir::{AttributeKind, MirDialect, MirPhase}; use rustc_feature::AttributeStability; -use rustc_hir::Target; -use rustc_hir::attrs::{AttributeKind, MirDialect, MirPhase}; use rustc_span::{Span, Symbol, sym}; use crate::attributes::SingleAttributeParser; diff --git a/compiler/rustc_attr_parsing/src/attributes/repr.rs b/compiler/rustc_attr_parsing/src/attributes/repr.rs index d815cf7e5d931..6115ed207d98c 100644 --- a/compiler/rustc_attr_parsing/src/attributes/repr.rs +++ b/compiler/rustc_attr_parsing/src/attributes/repr.rs @@ -1,8 +1,8 @@ use rustc_abi::{Align, Size}; use rustc_ast::{IntTy, LitIntType, LitKind, UintTy}; +use rustc_attr_ir::IntType::{SignedInt, UnsignedInt}; +use rustc_attr_ir::ReprAttr; use rustc_feature::AttributeStability; -use rustc_hir::attrs::IntType::{SignedInt, UnsignedInt}; -use rustc_hir::attrs::ReprAttr; use rustc_session::diagnostics::feature_err; use super::prelude::*; @@ -161,7 +161,7 @@ fn parse_repr(cx: &mut AcceptContext<'_, '_>, param: &MetaItemParser) -> Option< &AllowedTargets::AllowList(&[ Allow(Target::Struct), Allow(Target::Enum), - Allow(Target::Union), // Feature gated in `rustc_hir_analysis` + Allow(Target::Union), // Feature gated in `rustc_attr_ir_analysis` Warn(Target::MacroCall), ]), ); diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs index e20d4585925c3..975013ba065d4 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs @@ -1,6 +1,6 @@ +use rustc_attr_ir::target::{MethodKind, Target}; +use rustc_attr_ir::{AttributeKind, RustcDumpLayoutKind}; use rustc_feature::AttributeStability; -use rustc_hir::attrs::{AttributeKind, RustcDumpLayoutKind}; -use rustc_hir::{MethodKind, Target}; use rustc_span::{Span, Symbol, sym}; use super::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index 10d9858864a3e..fe90b51c221a1 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -1,14 +1,14 @@ use std::path::PathBuf; use rustc_ast::{LitIntType, LitKind, MetaItemLit}; -use rustc_data_structures::fx::FxHashMap; -use rustc_feature::AttributeStability; -use rustc_hir::attrs::lang_items::LangItem; -use rustc_hir::attrs::{ +use rustc_attr_ir::lang_items::LangItem; +use rustc_attr_ir::target::GenericParamKind; +use rustc_attr_ir::{ BorrowckGraphvizFormatKind, CguFields, CguKind, DivergingBlockBehavior, DivergingFallbackBehavior, RustcCleanAttribute, RustcCleanQueries, RustcMirKind, }; -use rustc_hir::target::GenericParamKind; +use rustc_data_structures::fx::FxHashMap; +use rustc_feature::AttributeStability; use rustc_span::Symbol; use super::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/semantics.rs b/compiler/rustc_attr_parsing/src/attributes/semantics.rs index fa19d51c397eb..7a8475c12eada 100644 --- a/compiler/rustc_attr_parsing/src/attributes/semantics.rs +++ b/compiler/rustc_attr_parsing/src/attributes/semantics.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::target::GenericParamKind; use rustc_feature::AttributeStability; -use rustc_hir::target::GenericParamKind; use super::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/stability.rs b/compiler/rustc_attr_parsing/src/attributes/stability.rs index 71be778905f26..6bdb14548cfee 100644 --- a/compiler/rustc_attr_parsing/src/attributes/stability.rs +++ b/compiler/rustc_attr_parsing/src/attributes/stability.rs @@ -1,13 +1,12 @@ use std::num::NonZero; +use rustc_attr_ir::target::{GenericParamKind, MethodKind, Target}; +use rustc_attr_ir::{ + DefaultBodyStability, PartialConstStability, Stability, StabilityLevel, StableSince, + UnstableReason, UnstableRemovedFeature, VERSION_PLACEHOLDER, +}; use rustc_errors::ErrorGuaranteed; use rustc_feature::{ACCEPTED_LANG_FEATURES, AttributeStability}; -use rustc_hir::attrs::UnstableRemovedFeature; -use rustc_hir::target::GenericParamKind; -use rustc_hir::{ - DefaultBodyStability, MethodKind, PartialConstStability, Stability, StabilityLevel, - StableSince, Target, UnstableReason, VERSION_PLACEHOLDER, -}; use super::prelude::*; use super::util::parse_version; diff --git a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs index 780b9e185b0ed..22dd77ce45737 100644 --- a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::RustcAbiAttrKind; use rustc_feature::AttributeStability; -use rustc_hir::attrs::RustcAbiAttrKind; use rustc_session::lint::builtin::ILL_FORMED_ATTRIBUTE_INPUT; use super::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/unroll.rs b/compiler/rustc_attr_parsing/src/attributes/unroll.rs index 5a49feca2a1ea..2626adb24ec9d 100644 --- a/compiler/rustc_attr_parsing/src/attributes/unroll.rs +++ b/compiler/rustc_attr_parsing/src/attributes/unroll.rs @@ -1,6 +1,6 @@ use rustc_ast::{LitIntType, LitKind}; +use rustc_attr_ir::UnrollAttr; use rustc_feature::AttributeStability; -use rustc_hir::attrs::UnrollAttr; use super::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/util.rs b/compiler/rustc_attr_parsing/src/attributes/util.rs index b6cc68ffc04fe..ed6d27b4c58f7 100644 --- a/compiler/rustc_attr_parsing/src/attributes/util.rs +++ b/compiler/rustc_attr_parsing/src/attributes/util.rs @@ -1,9 +1,9 @@ use std::num::IntErrorKind; use rustc_ast::{LitKind, ast}; +use rustc_attr_ir::RustcVersion; use rustc_data_structures::Limit; use rustc_feature::is_builtin_attr_name; -use rustc_hir::attrs::RustcVersion; use rustc_span::Symbol; use crate::context::AcceptContext; diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 72673214b42d9..73195c7b77b10 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -9,11 +9,11 @@ use std::sync::LazyLock; use std::sync::atomic::{AtomicBool, Ordering}; use rustc_ast::{AttrStyle, MetaItemLit, Safety}; +use rustc_attr_ir::target::Target; +use rustc_attr_ir::{AttrPath, Attribute, AttributeKind}; use rustc_data_structures::sync::{DynSend, DynSync}; use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level, MultiSpan}; use rustc_feature::AttributeStability; -use rustc_hir::attrs::AttributeKind; -use rustc_hir::{AttrPath, Attribute}; use rustc_parse::parser::Recovery; use rustc_session::Session; use rustc_session::lint::{Lint, LintId}; @@ -775,7 +775,7 @@ pub struct SharedContext<'p, 'sess> { pub(crate) cx: &'p mut AttributeParser<'sess>, /// The span of the syntactical component this attribute was applied to pub(crate) target_span: Span, - pub(crate) target: rustc_hir::Target, + pub(crate) target: Target, pub(crate) emit_lint: &'p mut dyn FnMut(LintId, MultiSpan, EmitAttribute), diff --git a/compiler/rustc_attr_parsing/src/diagnostics.rs b/compiler/rustc_attr_parsing/src/diagnostics.rs index 48128b109194c..9d72bdcb75ce3 100644 --- a/compiler/rustc_attr_parsing/src/diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/diagnostics.rs @@ -1,12 +1,11 @@ use std::num::IntErrorKind; +use rustc_attr_ir::{AttrPath, MirDialect, MirPhase}; use rustc_errors::codes::*; use rustc_errors::{ Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, E0264, EmissionGuarantee, Level, MultiSpan, }; -use rustc_hir::AttrPath; -use rustc_hir::attrs::{MirDialect, MirPhase}; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{Ident, Span, Symbol}; use rustc_target::spec::TargetTuple; diff --git a/compiler/rustc_attr_parsing/src/interface.rs b/compiler/rustc_attr_parsing/src/interface.rs index 492cf1e268ac6..63a273a063ebb 100644 --- a/compiler/rustc_attr_parsing/src/interface.rs +++ b/compiler/rustc_attr_parsing/src/interface.rs @@ -6,11 +6,11 @@ use std::sync::atomic::{AtomicBool, Ordering}; use rustc_ast as ast; use rustc_ast::token::DocFragmentKind; use rustc_ast::{AttrStyle, CRATE_NODE_ID, NodeId, Safety}; +use rustc_attr_ir::target::Target; +use rustc_attr_ir::{AttrArgs, AttrItem, AttrPath, Attribute, AttributeKind, HashIgnoredAttrId}; use rustc_data_structures::sync::{DynSend, DynSync}; use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level, MultiSpan}; use rustc_feature::{BUILTIN_ATTRIBUTE_MAP, Features}; -use rustc_hir::attrs::AttributeKind; -use rustc_hir::{AttrArgs, AttrItem, AttrPath, Attribute, HashIgnoredAttrId, Target}; use rustc_lint_defs::RegisteredTools; use rustc_session::Session; use rustc_session::lint::LintId; diff --git a/compiler/rustc_attr_parsing/src/lib.rs b/compiler/rustc_attr_parsing/src/lib.rs index 5a1d1b8091da2..4b386f06a005c 100644 --- a/compiler/rustc_attr_parsing/src/lib.rs +++ b/compiler/rustc_attr_parsing/src/lib.rs @@ -2,12 +2,12 @@ //! //! ## Architecture //! This crate is part of a series of crates and modules that handle attribute processing. -//! - [`rustc_hir::attrs`]: Defines the data structures that store parsed attributes +//! - [`rustc_attr_ir`]: Defines the data structures that store parsed attributes //! - `rustc_attr_parsing`: This crate, handles the parsing of attributes //! - [`rustc_passes::check_attr`] handles attribute validation that cannot be done in this crate //! //! The separation between data structures and parsing follows the principle of separation of concerns. -//! Data structures (`rustc_hir::attrs`) define what attributes look like after parsing. +//! Data structures (`rustc_attr_ir`) define what attributes look like after parsing. //! This crate (`rustc_attr_parsing`) handles how to convert raw tokens into those structures. //! This split allows other parts of the compiler to use the data structures without needing //! the parsing logic, making the codebase more modular and maintainable. @@ -62,7 +62,7 @@ //! a "stability" of an item. So, the stability attribute has an //! [`AttributeParser`](attributes::AttributeParser) that recognizes both the `#[stable()]` //! and `#[unstable()]` syntactic attributes, and at the end produces a single -//! [`AttributeKind::Stability`](rustc_hir::attrs::AttributeKind::Stability). +//! [`AttributeKind::Stability`](rustc_attr_ir::AttributeKind::Stability). //! //! When multiple instances of the same attribute are allowed, they're combined into a single //! semantic attribute. For example: diff --git a/compiler/rustc_attr_parsing/src/parser.rs b/compiler/rustc_attr_parsing/src/parser.rs index a1563d629d474..8efe5bf4f1f90 100644 --- a/compiler/rustc_attr_parsing/src/parser.rs +++ b/compiler/rustc_attr_parsing/src/parser.rs @@ -19,8 +19,8 @@ use rustc_ast::{ AttrArgs, Expr, ExprKind, LitKind, MetaItemLit, Path, PathSegment, StmtKind, UnOp, }; use rustc_ast_pretty::pprust; +use rustc_attr_ir::AttrPath; use rustc_errors::{Applicability, Diag, PResult}; -use rustc_hir::{self as hir, AttrPath}; use rustc_parse::exp; use rustc_parse::parser::{ForceCollect, Parser, PathStyle, Recovery, token_descr}; use rustc_session::diagnostics::create_lit_error; @@ -41,7 +41,7 @@ pub type OwnedPathParser = PathParser; pub type RefPathParser<'p> = PathParser<&'p Path>; impl> PathParser

{ - pub fn get_attribute_path(&self) -> hir::AttrPath { + pub fn get_attribute_path(&self) -> AttrPath { AttrPath { segments: self.segments().map(|s| s.name).collect::>().into_boxed_slice(), span: self.span(), diff --git a/compiler/rustc_attr_parsing/src/safety.rs b/compiler/rustc_attr_parsing/src/safety.rs index 1e0717dfd8e26..ba1a6f2265f48 100644 --- a/compiler/rustc_attr_parsing/src/safety.rs +++ b/compiler/rustc_attr_parsing/src/safety.rs @@ -1,6 +1,6 @@ use rustc_ast::Safety; +use rustc_attr_ir::AttrPath; use rustc_errors::{Diagnostic, MultiSpan}; -use rustc_hir::AttrPath; use rustc_lint_defs::builtin::UNSAFE_CODE; use rustc_session::lint::LintId; use rustc_session::lint::builtin::UNSAFE_ATTR_OUTSIDE_UNSAFE; diff --git a/compiler/rustc_attr_parsing/src/stability.rs b/compiler/rustc_attr_parsing/src/stability.rs index 5fe86a4a3e569..b0ab2649c4078 100644 --- a/compiler/rustc_attr_parsing/src/stability.rs +++ b/compiler/rustc_attr_parsing/src/stability.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::AttrPath; use rustc_feature::AttributeStability; -use rustc_hir::AttrPath; use rustc_session::diagnostics::feature_err; use rustc_span::{Span, sym}; diff --git a/compiler/rustc_attr_parsing/src/synthetic.rs b/compiler/rustc_attr_parsing/src/synthetic.rs index 290730aaee132..6a16ee698e936 100644 --- a/compiler/rustc_attr_parsing/src/synthetic.rs +++ b/compiler/rustc_attr_parsing/src/synthetic.rs @@ -1,13 +1,13 @@ use rustc_ast::SyntheticAttr; use rustc_ast::attr::data_structures::CfgEntry; -use rustc_hir::Attribute; -use rustc_hir::attrs::AttributeKind; +use rustc_attr_ir::{Attribute, AttributeKind}; use rustc_span::Span; use thin_vec::ThinVec; -/// This struct contains the state necessary to convert synthetic attributes to hir attributes +/// Contains the state necessary to convert synthetic attributes to parsed attributes. +/// /// The only conversion that really happens here is that multiple synthetic attributes are -/// merged into a single hir attribute, representing their combined state. +/// merged into a single `rustc_attr_ir::attribute`, representing their combined state. /// FIXME: We should make this a nice and extendable system if this is going to be used more often #[derive(Default)] pub(crate) struct SyntheticAttrState { diff --git a/compiler/rustc_attr_parsing/src/target_checking.rs b/compiler/rustc_attr_parsing/src/target_checking.rs index fc78279da0c62..68357dfec88e8 100644 --- a/compiler/rustc_attr_parsing/src/target_checking.rs +++ b/compiler/rustc_attr_parsing/src/target_checking.rs @@ -1,10 +1,10 @@ use std::borrow::Cow; use rustc_ast::{AttrStyle, Safety}; +use rustc_attr_ir::target::{MethodKind, Target}; +use rustc_attr_ir::{AttrItem, Attribute, AttributeKind}; use rustc_errors::{DiagArgValue, MultiSpan, StashKey}; use rustc_feature::Features; -use rustc_hir::attrs::AttributeKind; -use rustc_hir::{AttrItem, Attribute, MethodKind, Target}; use rustc_span::{BytePos, FileName, RemapPathScopeComponents, Span, Symbol, sym}; use crate::context::AcceptContext; @@ -526,27 +526,27 @@ pub(crate) const ALL_TARGETS: &[Policy] = { Allow(Target::Delegation { mac: false }), Allow(Target::Delegation { mac: true }), Allow(Target::GenericParam { - kind: rustc_hir::target::GenericParamKind::Const, + kind: rustc_attr_ir::target::GenericParamKind::Const, has_default: false, }), Allow(Target::GenericParam { - kind: rustc_hir::target::GenericParamKind::Const, + kind: rustc_attr_ir::target::GenericParamKind::Const, has_default: true, }), Allow(Target::GenericParam { - kind: rustc_hir::target::GenericParamKind::Lifetime, + kind: rustc_attr_ir::target::GenericParamKind::Lifetime, has_default: false, }), Allow(Target::GenericParam { - kind: rustc_hir::target::GenericParamKind::Lifetime, + kind: rustc_attr_ir::target::GenericParamKind::Lifetime, has_default: true, }), Allow(Target::GenericParam { - kind: rustc_hir::target::GenericParamKind::Type, + kind: rustc_attr_ir::target::GenericParamKind::Type, has_default: false, }), Allow(Target::GenericParam { - kind: rustc_hir::target::GenericParamKind::Type, + kind: rustc_attr_ir::target::GenericParamKind::Type, has_default: true, }), Allow(Target::Loop), diff --git a/compiler/rustc_attr_parsing/src/validate_attr.rs b/compiler/rustc_attr_parsing/src/validate_attr.rs index 53a06e27cc4e8..73dc0cd93df3a 100644 --- a/compiler/rustc_attr_parsing/src/validate_attr.rs +++ b/compiler/rustc_attr_parsing/src/validate_attr.rs @@ -9,9 +9,9 @@ use rustc_ast::{ self as ast, AttrArgs, AttrKind, Attribute, DelimArgs, MetaItem, MetaItemInner, MetaItemKind, Safety, }; +use rustc_attr_ir::AttrPath; use rustc_errors::{Applicability, Diagnostic, PResult}; use rustc_feature::BUILTIN_ATTRIBUTE_MAP; -use rustc_hir::AttrPath; use rustc_parse::parse_in; use rustc_session::diagnostics::report_lit_error; use rustc_session::lint::builtin::ILL_FORMED_ATTRIBUTE_INPUT; From 12674a1f58a6b4cc58e6cdb34408ef0b6451202b Mon Sep 17 00:00:00 2001 From: mejrs <59372212+mejrs@users.noreply.github.com> Date: Mon, 10 Aug 2026 12:01:06 +0200 Subject: [PATCH 2/5] rustc_session: minimize rustc_hir dependencies --- Cargo.lock | 1 + compiler/rustc_session/Cargo.toml | 1 + compiler/rustc_session/src/config.rs | 4 ++-- compiler/rustc_session/src/config/native_libs.rs | 2 +- compiler/rustc_session/src/cstore.rs | 11 ++++++----- compiler/rustc_session/src/options.rs | 2 +- compiler/rustc_session/src/utils.rs | 2 +- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 31f36a017be2b..e0e57ce8cefa0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4746,6 +4746,7 @@ dependencies = [ "libc", "rustc_abi", "rustc_ast", + "rustc_attr_ir", "rustc_data_structures", "rustc_errors", "rustc_feature", diff --git a/compiler/rustc_session/Cargo.toml b/compiler/rustc_session/Cargo.toml index 79d05e2d20a69..f70a7069b0d93 100644 --- a/compiler/rustc_session/Cargo.toml +++ b/compiler/rustc_session/Cargo.toml @@ -8,6 +8,7 @@ edition = "2024" getopts = "0.2" rustc_abi = { path = "../rustc_abi" } rustc_ast = { path = "../rustc_ast" } +rustc_attr_ir = { path = "../rustc_attr_ir" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_errors = { path = "../rustc_errors" } rustc_feature = { path = "../rustc_feature" } diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 91eac6613db37..0303081e2c627 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1571,7 +1571,7 @@ pub enum EntryFnType { }, } -pub use rustc_hir::attrs::CrateType; +pub use rustc_attr_ir::CrateType; #[derive(Clone, Hash, Debug, PartialEq, Eq, Encodable, Decodable)] pub enum Passes { @@ -3310,12 +3310,12 @@ pub(crate) mod dep_tracking { use rustc_abi::Align; use rustc_ast::attr::version::RustcVersion; + use rustc_attr_ir::CollapseMacroDebuginfo; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::stable_hash::StableHasher; use rustc_errors::LanguageIdentifier; use rustc_feature::UnstableFeatures; use rustc_hashes::Hash64; - use rustc_hir::attrs::CollapseMacroDebuginfo; use rustc_span::edition::Edition; use rustc_span::{RealFileName, RemapPathScopeComponents}; use rustc_target::spec::{ diff --git a/compiler/rustc_session/src/config/native_libs.rs b/compiler/rustc_session/src/config/native_libs.rs index 28e2d0f94104b..d8c41fbae4c96 100644 --- a/compiler/rustc_session/src/config/native_libs.rs +++ b/compiler/rustc_session/src/config/native_libs.rs @@ -4,8 +4,8 @@ //! (There is also a similar but separate syntax for `#[link]` attributes, //! which have their own parser in `rustc_metadata`.) +use rustc_attr_ir::NativeLibKind; use rustc_feature::UnstableFeatures; -use rustc_hir::attrs::NativeLibKind; use crate::EarlyDiagCtxt; use crate::config::UnstableOptions; diff --git a/compiler/rustc_session/src/cstore.rs b/compiler/rustc_session/src/cstore.rs index c2b517824a058..0db1a645acafe 100644 --- a/compiler/rustc_session/src/cstore.rs +++ b/compiler/rustc_session/src/cstore.rs @@ -6,13 +6,14 @@ use std::any::Any; use std::path::PathBuf; use rustc_abi::ExternAbi; +use rustc_attr_ir::{CfgEntry, NativeLibKind, PeImportNameType}; use rustc_data_structures::sync::{self, AppendOnlyIndexVec, FreezeLock}; -use rustc_hir::attrs::{CfgEntry, NativeLibKind, PeImportNameType}; -use rustc_hir::def_id::{ - CrateNum, DefId, LOCAL_CRATE, LocalDefId, StableCrateId, StableCrateIdMap, -}; -use rustc_hir::definitions::{DefKey, DefPath, DefPathHash, Definitions}; +// FIXME: Can we not depend on `rustc_hir` here? :) +use rustc_hir::definitions::{DefKey, DefPath, Definitions}; use rustc_macros::{BlobDecodable, Decodable, Encodable, StableHash}; +use rustc_span::def_id::{ + CrateNum, DefId, DefPathHash, LOCAL_CRATE, LocalDefId, StableCrateId, StableCrateIdMap, +}; use rustc_span::{Span, Symbol}; // lonely orphan structs and enums looking for a better home diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 785abc46e61b6..b3023c731eeff 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -5,13 +5,13 @@ use std::str; use rustc_abi::Align; use rustc_ast::attr::version::RustcVersion; +use rustc_attr_ir::CollapseMacroDebuginfo; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::profiling::TimePassesFormat; use rustc_data_structures::stable_hash::StableHasher; use rustc_errors::{ColorConfig, TerminalUrl}; use rustc_feature::UnstableFeatures; use rustc_hashes::Hash64; -use rustc_hir::attrs::CollapseMacroDebuginfo; use rustc_macros::{BlobDecodable, Encodable}; use rustc_span::edit_distance::edit_distance; use rustc_span::edition::Edition; diff --git a/compiler/rustc_session/src/utils.rs b/compiler/rustc_session/src/utils.rs index bc89390eaaae3..d1d0f18b2c4cf 100644 --- a/compiler/rustc_session/src/utils.rs +++ b/compiler/rustc_session/src/utils.rs @@ -1,9 +1,9 @@ use std::path::PathBuf; use std::sync::OnceLock; +use rustc_attr_ir::NativeLibKind; use rustc_data_structures::profiling::VerboseTimingGuard; use rustc_fs_util::try_canonicalize; -use rustc_hir::attrs::NativeLibKind; use rustc_macros::{Decodable, Encodable, StableHash}; use crate::session::Session; From 1c9d8461d65252c21993ad674a8b5ad53acb2a21 Mon Sep 17 00:00:00 2001 From: mejrs <59372212+mejrs@users.noreply.github.com> Date: Mon, 10 Aug 2026 12:09:38 +0200 Subject: [PATCH 3/5] rustc_ast_passes: use rustc_attr_ir imports --- Cargo.lock | 2 +- compiler/rustc_ast_passes/Cargo.toml | 2 +- compiler/rustc_ast_passes/src/feature_gate.rs | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e0e57ce8cefa0..e57d9d5399c05 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3679,11 +3679,11 @@ dependencies = [ "rustc_abi", "rustc_ast", "rustc_ast_pretty", + "rustc_attr_ir", "rustc_attr_parsing", "rustc_data_structures", "rustc_errors", "rustc_feature", - "rustc_hir", "rustc_macros", "rustc_session", "rustc_span", diff --git a/compiler/rustc_ast_passes/Cargo.toml b/compiler/rustc_ast_passes/Cargo.toml index ddfcb19b02e1e..643e72af84c25 100644 --- a/compiler/rustc_ast_passes/Cargo.toml +++ b/compiler/rustc_ast_passes/Cargo.toml @@ -9,11 +9,11 @@ itertools = "0.15" rustc_abi = { path = "../rustc_abi" } rustc_ast = { path = "../rustc_ast" } rustc_ast_pretty = { path = "../rustc_ast_pretty" } +rustc_attr_ir = { path = "../rustc_attr_ir" } rustc_attr_parsing = { path = "../rustc_attr_parsing" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_errors = { path = "../rustc_errors" } rustc_feature = { path = "../rustc_feature" } -rustc_hir = { path = "../rustc_hir" } rustc_macros = { path = "../rustc_macros" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 8641b334ff24b..bd92f32e24b68 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -1,10 +1,9 @@ use rustc_ast::visit::{self, AssocCtxt, FnKind, Visitor}; use rustc_ast::{self as ast, AttrVec, GenericBound, NodeId, PatKind, attr, token}; +use rustc_attr_ir::{Attribute, AttributeKind}; use rustc_attr_parsing::AttributeParser; use rustc_errors::msg; use rustc_feature::Features; -use rustc_hir::Attribute; -use rustc_hir::attrs::AttributeKind; use rustc_session::Session; use rustc_session::diagnostics::{feature_err, feature_warn}; use rustc_span::{Span, Spanned, Symbol, sym}; From 8c85df353e366e4acaaf14833561e1ee1caba1f0 Mon Sep 17 00:00:00 2001 From: mejrs <59372212+mejrs@users.noreply.github.com> Date: Mon, 10 Aug 2026 12:22:37 +0200 Subject: [PATCH 4/5] rustc_expand: depend more on rustc_attr_ir --- Cargo.lock | 1 + compiler/rustc_expand/Cargo.toml | 1 + compiler/rustc_expand/src/base.rs | 10 +++++----- compiler/rustc_expand/src/config.rs | 8 +++----- compiler/rustc_expand/src/expand.rs | 8 ++++---- compiler/rustc_expand/src/mbe/diagnostics.rs | 2 +- compiler/rustc_expand/src/mbe/macro_rules.rs | 7 +++---- 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e57d9d5399c05..d099ebf1dafc2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4037,6 +4037,7 @@ dependencies = [ "rustc_ast", "rustc_ast_passes", "rustc_ast_pretty", + "rustc_attr_ir", "rustc_attr_parsing", "rustc_data_structures", "rustc_errors", diff --git a/compiler/rustc_expand/Cargo.toml b/compiler/rustc_expand/Cargo.toml index 2b8dc55012616..885de14fd6b2f 100644 --- a/compiler/rustc_expand/Cargo.toml +++ b/compiler/rustc_expand/Cargo.toml @@ -12,6 +12,7 @@ doctest = false rustc_ast = { path = "../rustc_ast" } rustc_ast_passes = { path = "../rustc_ast_passes" } rustc_ast_pretty = { path = "../rustc_ast_pretty" } +rustc_attr_ir = { path = "../rustc_attr_ir" } rustc_attr_parsing = { path = "../rustc_attr_parsing" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_errors = { path = "../rustc_errors" } diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index f15b005960c9f..2579be47deb61 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -10,14 +10,14 @@ use rustc_ast::attr::MarkedAttrs; use rustc_ast::tokenstream::TokenStream; use rustc_ast::visit::{AssocCtxt, Visitor}; use rustc_ast::{self as ast, AttrVec, Attribute, HasAttrs, Item, NodeId, PatKind, Safety}; +use rustc_attr_ir::{ + self as attrs, CfgEntry, CollapseMacroDebuginfo, Deprecation, Stability, find_attr, +}; use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; use rustc_data_structures::{Limit, sync}; use rustc_errors::{BufferedEarlyLint, DiagCtxtHandle, ErrorGuaranteed, PResult}; use rustc_feature::Features; -use rustc_hir as hir; -use rustc_hir::attrs::{CfgEntry, CollapseMacroDebuginfo, Deprecation}; use rustc_hir::def::MacroKinds; -use rustc_hir::{Stability, find_attr}; use rustc_lint_defs::RegisteredTools; use rustc_parse::MACRO_ARGUMENTS; use rustc_parse::parser::Parser; @@ -844,7 +844,7 @@ impl SyntaxExtension { /// | (unspecified) | no | if-ext | if-ext | yes | /// | external | no | if-ext | if-ext | yes | /// | yes | yes | yes | yes | yes | - fn get_collapse_debuginfo(sess: &Session, attrs: &[hir::Attribute], ext: bool) -> bool { + fn get_collapse_debuginfo(sess: &Session, attrs: &[attrs::Attribute], ext: bool) -> bool { let flag = sess.opts.cg.collapse_macro_debuginfo; let attr = if let Some(info) = find_attr!(attrs, CollapseDebugInfo(info) => info) { *info @@ -873,7 +873,7 @@ impl SyntaxExtension { helper_attrs: Vec, edition: Edition, name: Symbol, - attrs: &[hir::Attribute], + attrs: &[attrs::Attribute], is_local: bool, ) -> SyntaxExtension { let allow_internal_unstable = find_attr!(attrs, AllowInternalUnstable(i, _) => i) diff --git a/compiler/rustc_expand/src/config.rs b/compiler/rustc_expand/src/config.rs index af017bea67697..93dfab10077ee 100644 --- a/compiler/rustc_expand/src/config.rs +++ b/compiler/rustc_expand/src/config.rs @@ -11,6 +11,8 @@ use rustc_ast::{ self as ast, AttrStyle, Attribute, HasAttrs, HasTokens, MetaItem, MetaItemInner, NodeId, SyntheticAttr, }; +use rustc_attr_ir::target::Target; +use rustc_attr_ir::{self as attrs, AttributeKind}; use rustc_attr_parsing::parser::AllowExprMetavar; use rustc_attr_parsing::{ self as attr, AttributeParser, AttributeSafety, CFG_TEMPLATE, EvalConfigResult, ShouldEmit, @@ -22,10 +24,6 @@ use rustc_feature::{ ACCEPTED_LANG_FEATURES, EnabledLangFeature, EnabledLibFeature, Features, REMOVED_LANG_FEATURES, UNSTABLE_LANG_FEATURES, }; -use rustc_hir::attrs::AttributeKind; -use rustc_hir::{ - Target, {self as hir}, -}; use rustc_parse::parser::Recovery; use rustc_session::Session; use rustc_session::diagnostics::feature_err; @@ -51,7 +49,7 @@ pub struct StripUnconfigured<'a> { pub fn features(sess: &Session, krate_attrs: &[Attribute], crate_name: Symbol) -> Features { let mut features = Features::default(); - if let Some(hir::Attribute::Parsed(AttributeKind::Feature(feature_idents, _))) = + if let Some(attrs::Attribute::Parsed(AttributeKind::Feature(feature_idents, _))) = AttributeParser::parse_limited_sym(sess, krate_attrs, &[sym::feature]) { for feature_ident in feature_idents { diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index 63877cb92f1d1..6328115f4b37c 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -13,6 +13,7 @@ use rustc_ast::{ PatKind, StmtKind, SyntheticAttr, TyKind, token, }; use rustc_ast_pretty::pprust; +use rustc_attr_ir::target::Target; use rustc_attr_parsing::parser::AllowExprMetavar; use rustc_attr_parsing::{ AttributeParser, AttributeSafety, CFG_TEMPLATE, EvalConfigResult, ShouldEmit, @@ -22,7 +23,6 @@ use rustc_data_structures::Limit; use rustc_data_structures::flat_map_in_place::FlatMapInPlace; use rustc_errors::PResult; use rustc_feature::Features; -use rustc_hir::Target; use rustc_hir::def::MacroKinds; use rustc_parse::parser::{ AllowConstBlockItems, AttemptLocalParseRecovery, CommaRecoveryMode, ForceCollect, Parser, @@ -1715,15 +1715,15 @@ impl InvocationCollectorNode for ast::GenericParam { Target::GenericParam { kind: match &self.kind { rustc_ast::GenericParamKind::Lifetime => { - rustc_hir::target::GenericParamKind::Lifetime + rustc_attr_ir::target::GenericParamKind::Lifetime } rustc_ast::GenericParamKind::Type { default } => { has_default = default.is_some(); - rustc_hir::target::GenericParamKind::Type + rustc_attr_ir::target::GenericParamKind::Type } rustc_ast::GenericParamKind::Const { default, .. } => { has_default = default.is_some(); - rustc_hir::target::GenericParamKind::Const + rustc_attr_ir::target::GenericParamKind::Const } }, has_default, diff --git a/compiler/rustc_expand/src/mbe/diagnostics.rs b/compiler/rustc_expand/src/mbe/diagnostics.rs index cd0c54f293e44..89b4aac3299fc 100644 --- a/compiler/rustc_expand/src/mbe/diagnostics.rs +++ b/compiler/rustc_expand/src/mbe/diagnostics.rs @@ -2,9 +2,9 @@ use std::borrow::Cow; use rustc_ast::token::{self, Token}; use rustc_ast::tokenstream::TokenStream; +use rustc_attr_ir::diagnostic::{CustomDiagnostic, Directive, FormatArgs}; use rustc_data_structures::fx::FxHashSet; use rustc_errors::{Applicability, Diag, DiagCtxtHandle, DiagMessage, pluralize}; -use rustc_hir::attrs::diagnostic::{CustomDiagnostic, Directive, FormatArgs}; use rustc_macros::Subdiagnostic; use rustc_middle::bug; use rustc_parse::parser::{Parser, Recovery, token_descr}; diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index 6b997713cb36b..b268b8b767327 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -10,13 +10,12 @@ use rustc_ast::token::{self, Delimiter, NonterminalKind, Token, TokenKind}; use rustc_ast::tokenstream::{self, DelimSpan, TokenStream}; use rustc_ast::{self as ast, DUMMY_NODE_ID, NodeId, Safety}; use rustc_ast_pretty::pprust; +use rustc_attr_ir::diagnostic::Directive; +use rustc_attr_ir::{self as attrs, find_attr}; use rustc_data_structures::fx::{FxHashMap, FxIndexMap}; use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan}; use rustc_feature::Features; -use rustc_hir as hir; -use rustc_hir::attrs::diagnostic::Directive; use rustc_hir::def::MacroKinds; -use rustc_hir::find_attr; use rustc_lint_defs::builtin::{ RUST_2021_INCOMPATIBLE_OR_PATTERNS, SEMICOLON_IN_EXPRESSIONS_FROM_MACROS, SEMICOLON_IN_EXPRESSIONS_FROM_NON_LOCAL_MACROS, @@ -783,7 +782,7 @@ pub fn compile_declarative_macro( features: &Features, macro_def: &ast::MacroDef, ident: Ident, - attrs: &[hir::Attribute], + attrs: &[attrs::Attribute], span: Span, node_id: NodeId, edition: Edition, From e35d06a821e78749a8b9561a6df4ef896dfd85b9 Mon Sep 17 00:00:00 2001 From: mejrs <59372212+mejrs@users.noreply.github.com> Date: Mon, 10 Aug 2026 12:50:02 +0200 Subject: [PATCH 5/5] rustc_builtin_macros: depend on rustc_attr_ir instead --- Cargo.lock | 2 +- compiler/rustc_builtin_macros/Cargo.toml | 2 +- compiler/rustc_builtin_macros/src/autodiff.rs | 2 +- compiler/rustc_builtin_macros/src/cfg.rs | 4 ++-- compiler/rustc_builtin_macros/src/deriving/generic/mod.rs | 3 +-- compiler/rustc_builtin_macros/src/proc_macro_harness.rs | 4 ++-- compiler/rustc_builtin_macros/src/test.rs | 3 +-- compiler/rustc_builtin_macros/src/test_harness.rs | 4 ++-- 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d099ebf1dafc2..dcdf9e63b6af1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3781,12 +3781,12 @@ version = "0.0.0" dependencies = [ "rustc_ast", "rustc_ast_pretty", + "rustc_attr_ir", "rustc_attr_parsing", "rustc_data_structures", "rustc_errors", "rustc_expand", "rustc_feature", - "rustc_hir", "rustc_index", "rustc_lexer", "rustc_lint_defs", diff --git a/compiler/rustc_builtin_macros/Cargo.toml b/compiler/rustc_builtin_macros/Cargo.toml index 8f265bad9728e..f53bc5b33c899 100644 --- a/compiler/rustc_builtin_macros/Cargo.toml +++ b/compiler/rustc_builtin_macros/Cargo.toml @@ -10,12 +10,12 @@ doctest = false # tidy-alphabetical-start rustc_ast = { path = "../rustc_ast" } rustc_ast_pretty = { path = "../rustc_ast_pretty" } +rustc_attr_ir = { path = "../rustc_attr_ir" } rustc_attr_parsing = { path = "../rustc_attr_parsing" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_errors = { path = "../rustc_errors" } rustc_expand = { path = "../rustc_expand" } rustc_feature = { path = "../rustc_feature" } -rustc_hir = { path = "../rustc_hir" } rustc_index = { path = "../rustc_index" } rustc_lexer = { path = "../rustc_lexer" } rustc_lint_defs = { path = "../rustc_lint_defs" } diff --git a/compiler/rustc_builtin_macros/src/autodiff.rs b/compiler/rustc_builtin_macros/src/autodiff.rs index 0618c28759a66..c3fb727ede7bd 100644 --- a/compiler/rustc_builtin_macros/src/autodiff.rs +++ b/compiler/rustc_builtin_macros/src/autodiff.rs @@ -18,8 +18,8 @@ mod llvm_enzyme { FnRetTy, FnSig, GenericArg, GenericArgs, GenericParamKind, Generics, ItemKind, MetaItemInner, PatKind, Path, PathSegment, TyKind, Visibility, }; + use rustc_attr_ir::RustcAutodiff; use rustc_expand::base::{Annotatable, ExtCtxt}; - use rustc_hir::attrs::RustcAutodiff; use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym}; use thin_vec::{ThinVec, thin_vec}; use tracing::{debug, trace}; diff --git a/compiler/rustc_builtin_macros/src/cfg.rs b/compiler/rustc_builtin_macros/src/cfg.rs index f2771f125ff54..b34d928146efd 100644 --- a/compiler/rustc_builtin_macros/src/cfg.rs +++ b/compiler/rustc_builtin_macros/src/cfg.rs @@ -4,14 +4,14 @@ use rustc_ast::tokenstream::TokenStream; use rustc_ast::{AttrStyle, token}; +use rustc_attr_ir::target::Target; +use rustc_attr_ir::{AttrPath, CfgEntry}; use rustc_attr_parsing::parser::{AllowExprMetavar, MetaItemOrLitParser}; use rustc_attr_parsing::{ self as attr, AttributeParser, AttributeSafety, CFG_TEMPLATE, ParsedDescription, ShouldEmit, parse_cfg_entry, }; use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult}; -use rustc_hir::attrs::CfgEntry; -use rustc_hir::{AttrPath, Target}; use rustc_parse::exp; use rustc_parse::parser::Recovery; use rustc_span::{ErrorGuaranteed, Span, sym}; diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index 03ccdbb902a96..c5f6c96bd8634 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -186,10 +186,9 @@ use rustc_ast::{ self as ast, AnonConst, AttrArgs, BindingMode, ByRef, DelimArgs, EnumDef, Expr, GenericArg, GenericParamKind, Generics, Mutability, PatKind, Safety, VariantData, }; +use rustc_attr_ir::{Attribute, AttributeKind, ReprPacked}; use rustc_attr_parsing::AttributeParser; use rustc_expand::base::{Annotatable, ExtCtxt}; -use rustc_hir::Attribute; -use rustc_hir::attrs::{AttributeKind, ReprPacked}; use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym}; use thin_vec::{ThinVec, thin_vec}; use ty::{Bounds, Path, Ref, Self_, Ty}; diff --git a/compiler/rustc_builtin_macros/src/proc_macro_harness.rs b/compiler/rustc_builtin_macros/src/proc_macro_harness.rs index 88f380fa9ef64..2f939e226c292 100644 --- a/compiler/rustc_builtin_macros/src/proc_macro_harness.rs +++ b/compiler/rustc_builtin_macros/src/proc_macro_harness.rs @@ -3,12 +3,12 @@ use std::{mem, slice}; use rustc_ast::visit::{self, Visitor}; use rustc_ast::{self as ast, NodeId, attr}; use rustc_ast_pretty::pprust; +use rustc_attr_ir::AttributeKind; use rustc_attr_parsing::AttributeParser; use rustc_errors::DiagCtxtHandle; use rustc_expand::base::{ExtCtxt, ResolverExpand}; use rustc_expand::expand::{AstFragment, ExpansionConfig}; use rustc_feature::Features; -use rustc_hir::attrs::AttributeKind; use rustc_session::Session; use rustc_span::hygiene::AstPass; use rustc_span::source_map::SourceMap; @@ -99,7 +99,7 @@ impl<'a> CollectProcMacros<'a> { function_ident: Ident, attr: &'a ast::Attribute, ) { - let Some(rustc_hir::Attribute::Parsed(AttributeKind::ProcMacroDerive { .. })) = + let Some(rustc_attr_ir::Attribute::Parsed(AttributeKind::ProcMacroDerive { .. })) = AttributeParser::parse_limited_sym( self.session, slice::from_ref(attr), diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index 5206df563ec10..9839de9ce0560 100644 --- a/compiler/rustc_builtin_macros/src/test.rs +++ b/compiler/rustc_builtin_macros/src/test.rs @@ -5,11 +5,10 @@ use std::{assert_matches, iter}; use rustc_ast::{self as ast, GenericParamKind, attr, join_path_idents}; use rustc_ast_pretty::pprust; +use rustc_attr_ir::{Attribute, AttributeKind}; use rustc_attr_parsing::AttributeParser; use rustc_errors::{Applicability, Diag, Level}; use rustc_expand::base::*; -use rustc_hir::Attribute; -use rustc_hir::attrs::AttributeKind; use rustc_span::{ErrorGuaranteed, Ident, RemapPathScopeComponents, Span, Symbol, sym}; use thin_vec::{ThinVec, thin_vec}; use tracing::debug; diff --git a/compiler/rustc_builtin_macros/src/test_harness.rs b/compiler/rustc_builtin_macros/src/test_harness.rs index 5d20fed223468..a39db94b4fe55 100644 --- a/compiler/rustc_builtin_macros/src/test_harness.rs +++ b/compiler/rustc_builtin_macros/src/test_harness.rs @@ -9,11 +9,11 @@ use rustc_ast::entry::EntryPointType; use rustc_ast::mut_visit::*; use rustc_ast::visit::Visitor; use rustc_ast::{ModKind, attr}; +use rustc_attr_ir::AttributeKind; use rustc_attr_parsing::AttributeParser; use rustc_expand::base::{ExtCtxt, ResolverExpand}; use rustc_expand::expand::{AstFragment, ExpansionConfig}; use rustc_feature::Features; -use rustc_hir::attrs::AttributeKind; use rustc_session::Session; use rustc_session::lint::builtin::UNNAMEABLE_TEST_ITEMS; use rustc_span::hygiene::{AstPass, SyntaxContext, Transparency}; @@ -392,7 +392,7 @@ fn get_test_name(i: &ast::Item) -> Option { fn get_test_runner(sess: &Session, krate: &ast::Crate) -> Option { match AttributeParser::parse_limited_sym(sess, &krate.attrs, &[sym::test_runner]) { - Some(rustc_hir::Attribute::Parsed(AttributeKind::TestRunner(path))) => Some(path), + Some(rustc_attr_ir::Attribute::Parsed(AttributeKind::TestRunner(path))) => Some(path), _ => None, } }