Skip to content

Commit 3193ab0

Browse files
committed
Fix up lang_items import paths
1 parent 4667d75 commit 3193ab0

230 files changed

Lines changed: 510 additions & 410 deletions

File tree

Some content is hidden

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

compiler/rustc_ast_lowering/src/contract.rs

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

3+
use rustc_hir::attrs::lang_items::LangItem;
34
use thin_vec::thin_vec;
45

56
use crate::LoweringContext;
@@ -146,7 +147,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
146147
);
147148
let precond = self.expr_call_lang_item_fn_mut(
148149
req_span,
149-
rustc_hir::LangItem::ContractCheckRequires,
150+
LangItem::ContractCheckRequires,
150151
&*arena_vec![self; lowered_req],
151152
);
152153
self.stmt_expr(req.span, precond)
@@ -165,7 +166,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
165166
let lowered_ens = self.lower_expr_mut(&ens);
166167
self.expr_call_lang_item_fn(
167168
ens_span,
168-
rustc_hir::LangItem::ContractBuildCheckEnsures,
169+
LangItem::ContractBuildCheckEnsures,
169170
&*arena_vec![self; lowered_ens],
170171
)
171172
}
@@ -208,15 +209,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
208209

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

217218
let none_expr = self.arena.alloc(self.expr_enum_variant_lang_item(
218219
postcond_checker.span,
219-
rustc_hir::lang_items::LangItem::OptionNone,
220+
rustc_hir::attrs::lang_items::LangItem::OptionNone,
220221
Default::default(),
221222
));
222223
let else_block = self.block_expr(none_expr);
@@ -326,7 +327,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
326327
let cond_fn = self.expr_ident(span, cond_ident, cond_hir_id);
327328
let contract_check = self.expr_call_lang_item_fn_mut(
328329
span,
329-
rustc_hir::LangItem::ContractCheckEnsures,
330+
LangItem::ContractCheckEnsures,
330331
arena_vec![self; *cond_fn, *ret],
331332
);
332333
let contract_check = self.arena.alloc(contract_check);

compiler/rustc_ast_lowering/src/delegation/attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use rustc_hir as hir;
12
use rustc_hir::attrs::{AttributeKind, InlineAttr};
2-
use rustc_hir::{self as hir};
33
use rustc_span::Span;
44
use rustc_span::def_id::DefId;
55

compiler/rustc_ast_lowering/src/delegation/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +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;
4849
use rustc_hir::def::DefKind;
4950
use rustc_hir::{self as hir, FnDeclFlags};
5051
use rustc_middle::ty::Asyncness;
@@ -341,8 +342,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
341342
crate::re_lowering::ReloweringChecker::allow_relowering(self, |this| {
342343
this.lower_block_noalloc(HirId::INVALID, block, false)
343344
})
344-
},
345-
_ => self.lower_block_noalloc(HirId::INVALID, block, false)
345+
}
346+
_ => self.lower_block_noalloc(HirId::INVALID, block, false),
346347
};
347348

348349
// Remove node ids for which we overwrote resolution to generated param
@@ -456,7 +457,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
456457

457458
let expr = self.mk_expr(initializer, span);
458459

459-
let path = self.make_lang_item_qpath(hir::LangItem::FromFn, span, None);
460+
let path = self.make_lang_item_qpath(LangItem::FromFn, span, None);
460461
let path = self.arena.alloc(self.mk_expr(hir::ExprKind::Path(path), span));
461462

462463
let call = hir::ExprKind::Call(path, self.arena.alloc_slice(&[expr]));

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc_ast::*;
77
use rustc_data_structures::stack::ensure_sufficient_stack;
88
use rustc_errors::msg;
99
use rustc_hir as hir;
10+
use rustc_hir::attrs::lang_items::LangItem;
1011
use rustc_hir::def::{DefKind, Res};
1112
use rustc_hir::{HirId, Target, find_attr};
1213
use rustc_middle::span_bug;
@@ -717,7 +718,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
717718

718719
// `::std::ops::Try::from_output($tail_expr)`
719720
block.expr = Some(this.wrap_in_try_constructor(
720-
hir::LangItem::TryTraitFromOutput,
721+
LangItem::TryTraitFromOutput,
721722
try_span,
722723
tail_expr,
723724
ok_wrapped_span,
@@ -737,7 +738,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
737738

738739
fn wrap_in_try_constructor(
739740
&mut self,
740-
lang_item: hir::LangItem,
741+
lang_item: LangItem,
741742
method_span: Span,
742743
expr: &'hir hir::Expr<'hir>,
743744
overall_span: Span,
@@ -836,8 +837,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
836837
self.lower_span(span),
837838
Some(Arc::clone(&self.allow_gen_future)),
838839
);
839-
let resume_ty =
840-
self.make_lang_item_qpath(hir::LangItem::ResumeTy, unstable_span, None);
840+
let resume_ty = self.make_lang_item_qpath(LangItem::ResumeTy, unstable_span, None);
841841
let input_ty = hir::Ty {
842842
hir_id: self.next_id(),
843843
kind: hir::TyKind::Path(resume_ty),
@@ -1036,23 +1036,23 @@ impl<'hir> LoweringContext<'_, 'hir> {
10361036

10371037
let new_unchecked = self.expr_call_lang_item_fn_mut(
10381038
span,
1039-
hir::LangItem::PinNewUnchecked,
1039+
LangItem::PinNewUnchecked,
10401040
arena_vec![self; ref_mut_awaitee],
10411041
);
10421042
let get_context = self.expr_call_lang_item_fn_mut(
10431043
gen_future_span,
1044-
hir::LangItem::GetContext,
1044+
LangItem::GetContext,
10451045
arena_vec![self; task_context],
10461046
);
10471047
let call = match await_kind {
10481048
FutureKind::Future => self.expr_call_lang_item_fn(
10491049
span,
1050-
hir::LangItem::FuturePoll,
1050+
LangItem::FuturePoll,
10511051
arena_vec![self; new_unchecked, get_context],
10521052
),
10531053
FutureKind::AsyncIterator => self.expr_call_lang_item_fn(
10541054
span,
1055-
hir::LangItem::AsyncIteratorPollNext,
1055+
LangItem::AsyncIteratorPollNext,
10561056
arena_vec![self; new_unchecked, get_context],
10571057
),
10581058
};
@@ -1067,7 +1067,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10671067
let (x_pat, x_pat_hid) = self.pat_ident(gen_future_span, x_ident);
10681068
let x_expr = self.expr_ident(gen_future_span, x_ident, x_pat_hid);
10691069
let ready_field = self.single_pat_field(gen_future_span, x_pat);
1070-
let ready_pat = self.pat_lang_item_variant(span, hir::LangItem::PollReady, ready_field);
1070+
let ready_pat = self.pat_lang_item_variant(span, LangItem::PollReady, ready_field);
10711071
let break_x = self.with_loop_scope(loop_hir_id, move |this| {
10721072
let expr_break =
10731073
hir::ExprKind::Break(this.lower_loop_destination(None), Some(x_expr));
@@ -1078,7 +1078,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10781078

10791079
// `::std::task::Poll::Pending => {}`
10801080
let pending_arm = {
1081-
let pending_pat = self.pat_lang_item_variant(span, hir::LangItem::PollPending, &[]);
1081+
let pending_pat = self.pat_lang_item_variant(span, LangItem::PollPending, &[]);
10821082
let empty_block = self.expr_block_empty(span);
10831083
self.arm(pending_pat, empty_block, span)
10841084
};
@@ -1098,7 +1098,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10981098
// async gen - task_context = yield ASYNC_GEN_PENDING;
10991099
let yield_stmt = {
11001100
let yielded = if is_async_gen {
1101-
self.arena.alloc(self.expr_lang_item_path(span, hir::LangItem::AsyncGenPending))
1101+
self.arena.alloc(self.expr_lang_item_path(span, LangItem::AsyncGenPending))
11021102
} else {
11031103
self.expr_unit(span)
11041104
};
@@ -1140,7 +1140,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11401140
let into_future_expr = match await_kind {
11411141
FutureKind::Future => self.expr_call_lang_item_fn(
11421142
span,
1143-
hir::LangItem::IntoFutureIntoFuture,
1143+
LangItem::IntoFutureIntoFuture,
11441144
arena_vec![self; *expr],
11451145
),
11461146
// Not needed for `for await` because we expect to have already called
@@ -1444,7 +1444,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14441444
fn lower_expr_range_closed(&mut self, span: Span, e1: &Expr, e2: &Expr) -> hir::ExprKind<'hir> {
14451445
let e1 = self.lower_expr_mut(e1);
14461446
let e2 = self.lower_expr_mut(e2);
1447-
let fn_path = self.make_lang_item_qpath(hir::LangItem::RangeInclusiveNew, span, None);
1447+
let fn_path = self.make_lang_item_qpath(LangItem::RangeInclusiveNew, span, None);
14481448
let fn_expr = self.arena.alloc(self.expr(span, hir::ExprKind::Path(fn_path)));
14491449
hir::ExprKind::Call(fn_expr, arena_vec![self; e1, e2])
14501450
}
@@ -1459,32 +1459,32 @@ impl<'hir> LoweringContext<'_, 'hir> {
14591459
use rustc_ast::RangeLimits::*;
14601460

14611461
let lang_item = match (e1, e2, lims) {
1462-
(None, None, HalfOpen) => hir::LangItem::RangeFull,
1462+
(None, None, HalfOpen) => LangItem::RangeFull,
14631463
(Some(..), None, HalfOpen) => {
14641464
if self.tcx.features().new_range() {
1465-
hir::LangItem::RangeFromCopy
1465+
LangItem::RangeFromCopy
14661466
} else {
1467-
hir::LangItem::RangeFrom
1467+
LangItem::RangeFrom
14681468
}
14691469
}
1470-
(None, Some(..), HalfOpen) => hir::LangItem::RangeTo,
1470+
(None, Some(..), HalfOpen) => LangItem::RangeTo,
14711471
(Some(..), Some(..), HalfOpen) => {
14721472
if self.tcx.features().new_range() {
1473-
hir::LangItem::RangeCopy
1473+
LangItem::RangeCopy
14741474
} else {
1475-
hir::LangItem::Range
1475+
LangItem::Range
14761476
}
14771477
}
14781478
(None, Some(..), Closed) => {
14791479
if self.tcx.features().new_range() {
1480-
hir::LangItem::RangeToInclusiveCopy
1480+
LangItem::RangeToInclusiveCopy
14811481
} else {
1482-
hir::LangItem::RangeToInclusive
1482+
LangItem::RangeToInclusive
14831483
}
14841484
}
14851485
(Some(e1), Some(e2), Closed) => {
14861486
if self.tcx.features().new_range() {
1487-
hir::LangItem::RangeInclusiveCopy
1487+
LangItem::RangeInclusiveCopy
14881488
} else {
14891489
return self.lower_expr_range_closed(span, e1, e2);
14901490
}
@@ -1494,12 +1494,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
14941494
match start {
14951495
Some(..) => {
14961496
if self.tcx.features().new_range() {
1497-
hir::LangItem::RangeFromCopy
1497+
LangItem::RangeFromCopy
14981498
} else {
1499-
hir::LangItem::RangeFrom
1499+
LangItem::RangeFrom
15001500
}
15011501
}
1502-
None => hir::LangItem::RangeFull,
1502+
None => LangItem::RangeFull,
15031503
}
15041504
}
15051505
};
@@ -1511,7 +1511,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15111511
(
15121512
if matches!(
15131513
lang_item,
1514-
hir::LangItem::RangeInclusiveCopy | hir::LangItem::RangeToInclusiveCopy
1514+
LangItem::RangeInclusiveCopy | LangItem::RangeToInclusiveCopy
15151515
) {
15161516
sym::last
15171517
} else {
@@ -1691,7 +1691,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
16911691
);
16921692
let wrapped_yielded = self.expr_call_lang_item_fn(
16931693
desugar_span,
1694-
hir::LangItem::AsyncGenReady,
1694+
LangItem::AsyncGenReady,
16951695
std::slice::from_ref(yielded),
16961696
);
16971697
let yield_expr = self.arena.alloc(
@@ -1781,7 +1781,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
17811781
let ref_mut_iter = self.expr_mut_addr_of(head_span, iter);
17821782
self.expr_call_lang_item_fn(
17831783
head_span,
1784-
hir::LangItem::IteratorNext,
1784+
LangItem::IteratorNext,
17851785
arena_vec![self; ref_mut_iter],
17861786
)
17871787
}
@@ -1796,7 +1796,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
17961796
// `Pin::new_unchecked(...)`
17971797
let iter = self.arena.alloc(self.expr_call_lang_item_fn_mut(
17981798
head_span,
1799-
hir::LangItem::PinNewUnchecked,
1799+
LangItem::PinNewUnchecked,
18001800
arena_vec![self; iter],
18011801
));
18021802
// `unsafe { ... }`
@@ -1831,7 +1831,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18311831
// `::std::iter::IntoIterator::into_iter(<head>)`
18321832
let into_iter_expr = self.expr_call_lang_item_fn(
18331833
head_span,
1834-
hir::LangItem::IntoIterIntoIter,
1834+
LangItem::IntoIterIntoIter,
18351835
arena_vec![self; head],
18361836
);
18371837

@@ -1851,7 +1851,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18511851
// `Pin::new_unchecked(...)`
18521852
let iter = self.arena.alloc(self.expr_call_lang_item_fn_mut(
18531853
head_span,
1854-
hir::LangItem::PinNewUnchecked,
1854+
LangItem::PinNewUnchecked,
18551855
arena_vec![self; iter],
18561856
));
18571857
// `unsafe { ... }`
@@ -1866,7 +1866,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18661866
// `::core::async_iter::IntoAsyncIterator::into_async_iter(<head>)`
18671867
let iter = self.expr_call_lang_item_fn(
18681868
head_span,
1869-
hir::LangItem::IntoAsyncIterIntoIter,
1869+
LangItem::IntoAsyncIterIntoIter,
18701870
arena_vec![self; head],
18711871
);
18721872
let iter_arm = self.arm(async_iter_pat, inner_match_expr, for_span);
@@ -1922,7 +1922,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
19221922

19231923
self.expr_call_lang_item_fn(
19241924
unstable_span,
1925-
hir::LangItem::TryTraitBranch,
1925+
LangItem::TryTraitBranch,
19261926
arena_vec![self; sub_expr],
19271927
)
19281928
};
@@ -1949,13 +1949,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
19491949

19501950
let (constructor_item, target_id) = match self.try_block_scope {
19511951
TryBlockScope::Function => {
1952-
(hir::LangItem::TryTraitFromResidual, Err(hir::LoopIdError::OutsideLoopScope))
1952+
(LangItem::TryTraitFromResidual, Err(hir::LoopIdError::OutsideLoopScope))
19531953
}
19541954
TryBlockScope::Homogeneous(block_id) => {
1955-
(hir::LangItem::ResidualIntoTryType, Ok(block_id))
1955+
(LangItem::ResidualIntoTryType, Ok(block_id))
19561956
}
19571957
TryBlockScope::Heterogeneous(block_id) => {
1958-
(hir::LangItem::TryTraitFromResidual, Ok(block_id))
1958+
(LangItem::TryTraitFromResidual, Ok(block_id))
19591959
}
19601960
};
19611961
let from_residual_expr = self.wrap_in_try_constructor(
@@ -2013,7 +2013,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
20132013
);
20142014

20152015
let from_yeet_expr = self.wrap_in_try_constructor(
2016-
hir::LangItem::TryTraitFromYeet,
2016+
LangItem::TryTraitFromYeet,
20172017
unstable_span,
20182018
yeeted_expr,
20192019
yeeted_span,
@@ -2140,7 +2140,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
21402140
pub(super) fn expr_enum_variant_lang_item(
21412141
&mut self,
21422142
span: Span,
2143-
lang_item: hir::LangItem,
2143+
lang_item: LangItem,
21442144
fields: &'hir [hir::Expr<'hir>],
21452145
) -> hir::Expr<'hir> {
21462146
let path = self.arena.alloc(self.make_lang_item_qpath(lang_item, span, None));
@@ -2159,7 +2159,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
21592159
pub(super) fn expr_call_lang_item_fn_mut(
21602160
&mut self,
21612161
span: Span,
2162-
lang_item: hir::LangItem,
2162+
lang_item: LangItem,
21632163
args: &'hir [hir::Expr<'hir>],
21642164
) -> hir::Expr<'hir> {
21652165
let path = self.arena.alloc(self.expr_lang_item_path(span, lang_item));
@@ -2169,7 +2169,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
21692169
pub(super) fn expr_call_lang_item_fn(
21702170
&mut self,
21712171
span: Span,
2172-
lang_item: hir::LangItem,
2172+
lang_item: LangItem,
21732173
args: &'hir [hir::Expr<'hir>],
21742174
) -> &'hir hir::Expr<'hir> {
21752175
self.arena.alloc(self.expr_call_lang_item_fn_mut(span, lang_item, args))
@@ -2178,7 +2178,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
21782178
pub(super) fn expr_lang_item_path(
21792179
&mut self,
21802180
span: Span,
2181-
lang_item: hir::LangItem,
2181+
lang_item: LangItem,
21822182
) -> hir::Expr<'hir> {
21832183
let qpath = self.make_lang_item_qpath(lang_item, self.lower_span(span), None);
21842184
self.expr(span, hir::ExprKind::Path(qpath))
@@ -2188,7 +2188,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
21882188
pub(super) fn expr_lang_item_type_relative(
21892189
&mut self,
21902190
span: Span,
2191-
lang_item: hir::LangItem,
2191+
lang_item: LangItem,
21922192
name: Symbol,
21932193
) -> hir::Expr<'hir> {
21942194
let qpath = self.make_lang_item_qpath(lang_item, self.lower_span(span), None);

0 commit comments

Comments
 (0)