Skip to content

Commit af2ca52

Browse files
authored
Rollup merge of #163170 - mejrs:hir_imports, r=oli-obk
Update deprecated rustc_hir imports Followup to #160336 That's ~half of them, I'm not doing it all in one go to reduce conflicts.
2 parents 1a82b5d + 78d478a commit af2ca52

66 files changed

Lines changed: 200 additions & 177 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4168,6 +4168,7 @@ dependencies = [
41684168
"rustc_abi",
41694169
"rustc_ast",
41704170
"rustc_ast_pretty",
4171+
"rustc_attr_ir",
41714172
"rustc_hir",
41724173
"rustc_span",
41734174
]
@@ -4732,6 +4733,7 @@ dependencies = [
47324733
"rustc_arena",
47334734
"rustc_ast",
47344735
"rustc_ast_pretty",
4736+
"rustc_attr_ir",
47354737
"rustc_attr_parsing",
47364738
"rustc_data_structures",
47374739
"rustc_errors",
@@ -4848,6 +4850,7 @@ dependencies = [
48484850
"punycode",
48494851
"rustc-demangle",
48504852
"rustc_abi",
4853+
"rustc_attr_ir",
48514854
"rustc_data_structures",
48524855
"rustc_hashes",
48534856
"rustc_hir",
@@ -4947,8 +4950,8 @@ version = "0.0.0"
49474950
dependencies = [
49484951
"itertools",
49494952
"rustc_abi",
4953+
"rustc_attr_ir",
49504954
"rustc_data_structures",
4951-
"rustc_hir",
49524955
"rustc_middle",
49534956
"rustc_span",
49544957
"smallvec",
@@ -4961,6 +4964,7 @@ version = "0.0.0"
49614964
dependencies = [
49624965
"itertools",
49634966
"rustc_abi",
4967+
"rustc_attr_ir",
49644968
"rustc_data_structures",
49654969
"rustc_errors",
49664970
"rustc_hashes",

compiler/rustc_ast_lowering/src/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_ast::{Block, BlockCheckMode, Local, LocalKind, Stmt, StmtKind};
2+
use rustc_attr_ir::target::Target;
23
use rustc_hir as hir;
3-
use rustc_hir::Target;
44
use rustc_span::sym;
55
use smallvec::SmallVec;
66

compiler/rustc_ast_lowering/src/contract.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::sync::Arc;
22

3-
use rustc_hir::attrs::lang_items::LangItem;
3+
use rustc_attr_ir::lang_items::LangItem;
4+
use rustc_attr_ir::target::Target;
45
use thin_vec::thin_vec;
56

67
use crate::LoweringContext;
@@ -209,15 +210,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
209210

210211
let postcond_checker = self.arena.alloc(self.expr_enum_variant_lang_item(
211212
postcond_checker.span,
212-
rustc_hir::attrs::lang_items::LangItem::OptionSome,
213+
LangItem::OptionSome,
213214
&*arena_vec![self; *postcond_checker],
214215
));
215216
let then_block_stmts = self.block_all(span, stmts, Some(postcond_checker));
216217
let then_block = self.arena.alloc(self.expr_block(&then_block_stmts));
217218

218219
let none_expr = self.arena.alloc(self.expr_enum_variant_lang_item(
219220
postcond_checker.span,
220-
rustc_hir::attrs::lang_items::LangItem::OptionNone,
221+
LangItem::OptionNone,
221222
Default::default(),
222223
));
223224
let else_block = self.block_expr(none_expr);
@@ -350,7 +351,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
350351
));
351352

352353
let attrs: rustc_ast::AttrVec = thin_vec![self.unreachable_code_attr(span)];
353-
self.lower_attrs(contract_check.hir_id, &attrs, span, rustc_hir::Target::Expression);
354+
self.lower_attrs(contract_check.hir_id, &attrs, span, Target::Expression);
354355

355356
let ret_block = self.block_all(span, arena_vec![self; ret_stmt], Some(contract_check));
356357
self.arena.alloc(self.expr_block(self.arena.alloc(ret_block)))

compiler/rustc_ast_lowering/src/delegation/attributes.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,43 @@
1+
use rustc_attr_ir::{AttributeKind, InlineAttr};
12
use rustc_hir as hir;
2-
use rustc_hir::attrs::{AttributeKind, InlineAttr};
33
use rustc_span::Span;
44
use rustc_span::def_id::DefId;
55

66
use crate::LoweringContext;
77
use crate::delegation::DelegationResolution;
88

99
struct AdditionInfo {
10-
pub equals: fn(&hir::Attribute) -> bool,
10+
pub equals: fn(&rustc_attr_ir::Attribute) -> bool,
1111
pub kind: AdditionKind,
1212
}
1313

1414
enum AdditionKind {
15-
Default { factory: fn(Span) -> hir::Attribute },
16-
Inherit { factory: fn(Span, &hir::Attribute) -> hir::Attribute },
15+
Default { factory: fn(Span) -> rustc_attr_ir::Attribute },
16+
Inherit { factory: fn(Span, &rustc_attr_ir::Attribute) -> rustc_attr_ir::Attribute },
1717
}
1818

1919
static ADDITIONS: &[AdditionInfo] = &[
2020
AdditionInfo {
21-
equals: |a| matches!(a, hir::Attribute::Parsed(AttributeKind::MustUse { .. })),
21+
equals: |a| matches!(a, rustc_attr_ir::Attribute::Parsed(AttributeKind::MustUse { .. })),
2222
kind: AdditionKind::Inherit {
2323
factory: |span, original_attr| {
2424
let reason = match original_attr {
25-
hir::Attribute::Parsed(AttributeKind::MustUse { reason, .. }) => *reason,
25+
rustc_attr_ir::Attribute::Parsed(AttributeKind::MustUse { reason, .. }) => {
26+
*reason
27+
}
2628
_ => None,
2729
};
2830

29-
hir::Attribute::Parsed(AttributeKind::MustUse { span, reason })
31+
rustc_attr_ir::Attribute::Parsed(AttributeKind::MustUse { span, reason })
3032
},
3133
},
3234
},
3335
AdditionInfo {
34-
equals: |a| matches!(a, hir::Attribute::Parsed(AttributeKind::Inline(..))),
36+
equals: |a| matches!(a, rustc_attr_ir::Attribute::Parsed(AttributeKind::Inline(..))),
3537
kind: AdditionKind::Default {
36-
factory: |span| hir::Attribute::Parsed(AttributeKind::Inline(InlineAttr::Hint, span)),
38+
factory: |span| {
39+
rustc_attr_ir::Attribute::Parsed(AttributeKind::Inline(InlineAttr::Hint, span))
40+
},
3741
},
3842
},
3943
];
@@ -61,8 +65,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
6165
&self,
6266
span: Span,
6367
sig_id: DefId,
64-
existing: Option<&&[hir::Attribute]>,
65-
) -> Vec<hir::Attribute> {
68+
existing: Option<&&[rustc_attr_ir::Attribute]>,
69+
) -> Vec<rustc_attr_ir::Attribute> {
6670
ADDITIONS
6771
.iter()
6872
.filter_map(|addition| {

compiler/rustc_ast_lowering/src/delegation/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use hir::def::Res;
4545
use rustc_abi::ExternAbi;
4646
use rustc_ast as ast;
4747
use rustc_ast::*;
48-
use rustc_hir::attrs::lang_items::LangItem;
48+
use rustc_attr_ir::lang_items::LangItem;
4949
use rustc_hir::def::DefKind;
5050
use rustc_hir::{self as hir, FnDeclFlags, QPath};
5151
use rustc_middle::ty::Asyncness;

compiler/rustc_ast_lowering/src/expr/closure.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use rustc_ast::*;
2+
use rustc_attr_ir::find_attr;
3+
use rustc_attr_ir::target::Target;
24
use rustc_hir as hir;
3-
use rustc_hir::{HirId, Target, find_attr};
5+
use rustc_hir::HirId;
46
use rustc_span::{Span, span_bug};
57

68
use super::{LoweringContext, MoveExprState};
@@ -55,7 +57,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
5557
fn lower_expr_coroutine_closure_with_move_exprs(
5658
&mut self,
5759
expr_hir_id: HirId,
58-
attrs: &[hir::Attribute],
60+
attrs: &[rustc_attr_ir::Attribute],
5961
binder: &ClosureBinder,
6062
capture_clause: CaptureBy,
6163
closure_id: NodeId,
@@ -114,7 +116,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
114116
fn lower_expr_plain_closure_with_move_exprs(
115117
&mut self,
116118
expr_hir_id: HirId,
117-
attrs: &[hir::Attribute],
119+
attrs: &[rustc_attr_ir::Attribute],
118120
binder: &ClosureBinder,
119121
capture_clause: CaptureBy,
120122
closure_id: NodeId,
@@ -153,7 +155,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
153155
// local uses and the caller can later add the matching initializers.
154156
fn lower_expr_closure(
155157
&mut self,
156-
attrs: &[hir::Attribute],
158+
attrs: &[rustc_attr_ir::Attribute],
157159
binder: &ClosureBinder,
158160
capture_clause: CaptureBy,
159161
closure_id: NodeId,
@@ -283,7 +285,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
283285
body: &Expr,
284286
fn_decl_span: Span,
285287
fn_arg_span: Span,
286-
attrs: &[hir::Attribute],
288+
attrs: &[rustc_attr_ir::Attribute],
287289
) -> hir::ExprKind<'hir> {
288290
let closure_def_id = self.local_def_id(closure_id);
289291
let (binder_clause, generic_params) = self.lower_closure_binder(binder);

compiler/rustc_ast_lowering/src/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::borrow::Cow;
22

33
use rustc_ast::*;
4+
use rustc_attr_ir::lang_items::LangItem;
45
use rustc_data_structures::fx::FxIndexMap;
56
use rustc_hir as hir;
6-
use rustc_hir::attrs::lang_items::LangItem;
77
use rustc_session::config::FmtDebug;
88
use rustc_span::{ByteSymbol, DesugaringKind, Ident, Span, Symbol, sym};
99

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use rustc_abi::ExternAbi;
22
use rustc_ast::visit::AssocCtxt;
33
use rustc_ast::*;
4+
use rustc_attr_ir::target::Target;
5+
use rustc_attr_ir::{AttributeKind, EiiImplResolution, find_attr};
46
use rustc_errors::{E0570, ErrorGuaranteed, struct_span_code_err};
5-
use rustc_hir::attrs::{AttributeKind, EiiImplResolution};
67
use rustc_hir::def::{DefKind, PerNS, Res};
7-
use rustc_hir::{
8-
self as hir, HirId, ImplItemImplKind, LifetimeSource, PredicateOrigin, Target, find_attr,
9-
};
8+
use rustc_hir::{self as hir, HirId, ImplItemImplKind, LifetimeSource, PredicateOrigin};
109
use rustc_middle::ty::data_structures::IndexMap;
1110
use rustc_span::def_id::{DefId, LocalDefId};
1211
use rustc_span::edit_distance::find_best_match_for_name;
@@ -68,8 +67,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
6867
id: NodeId,
6968
name: Ident,
7069
EiiDecl { foreign_item, impl_unsafe }: &EiiDecl,
71-
) -> Option<hir::attrs::EiiDecl> {
72-
self.lower_path_simple_eii(id, foreign_item).map(|did| hir::attrs::EiiDecl {
70+
) -> Option<rustc_attr_ir::EiiDecl> {
71+
self.lower_path_simple_eii(id, foreign_item).map(|did| rustc_attr_ir::EiiDecl {
7372
foreign_item: did,
7473
impl_unsafe: *impl_unsafe,
7574
name,
@@ -87,7 +86,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
8786
is_default,
8887
known_eii_macro_resolution,
8988
}: &EiiImpl,
90-
) -> hir::attrs::EiiImpl {
89+
) -> rustc_attr_ir::EiiImpl {
9190
let resolution = if let Some(target) = known_eii_macro_resolution
9291
&& let Some(foreign_item_did) = self.lower_path_simple_eii(*node_id, target)
9392
{
@@ -100,7 +99,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10099
)
101100
};
102101

103-
hir::attrs::EiiImpl {
102+
rustc_attr_ir::EiiImpl {
104103
span: self.lower_span(*span),
105104
inner_span: self.lower_span(*inner_span),
106105
impl_unsafe_span: match *impl_safety {
@@ -116,19 +115,21 @@ impl<'hir> LoweringContext<'_, 'hir> {
116115
&mut self,
117116
id: NodeId,
118117
i: &ItemKind,
119-
) -> Vec<hir::Attribute> {
118+
) -> Vec<rustc_attr_ir::Attribute> {
120119
match i {
121120
ItemKind::Fn(Fn { eii_impl: None, .. })
122121
| ItemKind::Static(StaticItem { eii_impl: None, .. }) => Vec::new(),
123122
ItemKind::Fn(Fn { eii_impl: Some(eii_impl), .. })
124123
| ItemKind::Static(StaticItem { eii_impl: Some(eii_impl), .. }) => {
125-
vec![hir::Attribute::Parsed(AttributeKind::EiiImpl(Box::new(
124+
vec![rustc_attr_ir::Attribute::Parsed(AttributeKind::EiiImpl(Box::new(
126125
self.lower_eii_impl(eii_impl),
127126
)))]
128127
}
129128
ItemKind::MacroDef(name, MacroDef { eii_declaration: Some(target), .. }) => self
130129
.lower_eii_decl(id, *name, target)
131-
.map(|decl| vec![hir::Attribute::Parsed(AttributeKind::EiiDeclaration(decl))])
130+
.map(|decl| {
131+
vec![rustc_attr_ir::Attribute::Parsed(AttributeKind::EiiDeclaration(decl))]
132+
})
132133
.unwrap_or_default(),
133134

134135
ItemKind::ExternCrate(..)
@@ -184,7 +185,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
184185
span: Span,
185186
id: NodeId,
186187
hir_id: hir::HirId,
187-
attrs: &'hir [hir::Attribute],
188+
attrs: &'hir [rustc_attr_ir::Attribute],
188189
vis_span: Span,
189190
i: &ItemKind,
190191
) -> hir::ItemKind<'hir> {
@@ -551,7 +552,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
551552
prefix: &Path,
552553
id: NodeId,
553554
vis_span: Span,
554-
attrs: &'hir [hir::Attribute],
555+
attrs: &'hir [rustc_attr_ir::Attribute],
555556
) -> hir::ItemKind<'hir> {
556557
let path = &tree.prefix;
557558
let segments = prefix.segments.iter().chain(path.segments.iter()).cloned().collect();
@@ -1351,7 +1352,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
13511352
decl: &FnDecl,
13521353
coroutine_marker: Option<CoroutineMarker>,
13531354
body: Option<&Block>,
1354-
attrs: &'hir [hir::Attribute],
1355+
attrs: &'hir [rustc_attr_ir::Attribute],
13551356
contract: Option<&FnContract>,
13561357
) -> hir::BodyId {
13571358
let Some(body) = body else {
@@ -1612,7 +1613,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
16121613
id: NodeId,
16131614
kind: FnDeclKind,
16141615
coroutine_marker: Option<CoroutineMarker>,
1615-
attrs: &[hir::Attribute],
1616+
attrs: &[rustc_attr_ir::Attribute],
16161617
) -> (&'hir hir::Generics<'hir>, hir::FnSig<'hir>) {
16171618
let header = self.lower_fn_header(sig.header, hir::Safety::Safe, attrs);
16181619
let itctx = ImplTraitContext::Universal;
@@ -1626,7 +1627,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
16261627
&mut self,
16271628
h: FnHeader,
16281629
default_safety: hir::Safety,
1629-
attrs: &[hir::Attribute],
1630+
attrs: &[rustc_attr_ir::Attribute],
16301631
) -> hir::FnHeader {
16311632
let asyncness = if let Some(coroutine_marker) = h.coroutine_marker
16321633
&& let CoroutineKind::Async = coroutine_marker.kind
@@ -1713,7 +1714,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
17131714
/// Lowers constness or comptime attribute.
17141715
/// Whether `const` is allowed here is checked by ast validation.
17151716
/// Whether `comptime` is allowed here is checked by the `comptime` attribute parser.
1716-
pub(super) fn lower_constness(&mut self, attrs: &[hir::Attribute], c: Const) -> hir::Constness {
1717+
pub(super) fn lower_constness(
1718+
&mut self,
1719+
attrs: &[rustc_attr_ir::Attribute],
1720+
c: Const,
1721+
) -> hir::Constness {
17171722
let mut constness = match c {
17181723
Const::Yes(_) => hir::Constness::Const { always: false },
17191724
Const::No => hir::Constness::NotConst,

0 commit comments

Comments
 (0)