diff --git a/compiler/rustc_abi/src/extern_abi.rs b/compiler/rustc_abi/src/extern_abi.rs
index 5a44323a0b755..57fa6310b2bac 100644
--- a/compiler/rustc_abi/src/extern_abi.rs
+++ b/compiler/rustc_abi/src/extern_abi.rs
@@ -290,8 +290,8 @@ impl ExternAbi {
}
/// Returns whether the ABI supports C variadics. This only controls whether we allow *imports*
- /// of such functions via `extern` blocks; there's a separate check during AST construction
- /// guarding *definitions* of variadic functions.
+ /// of such functions via `extern` blocks and definition via naked functions; there's a
+ /// separate check during AST construction guarding *definitions* of variadic functions.
#[cfg(feature = "nightly")]
pub fn supports_c_variadic(self) -> CVariadicStatus {
// * C and Cdecl obviously support varargs.
diff --git a/compiler/rustc_ast_lowering/src/contract.rs b/compiler/rustc_ast_lowering/src/contract.rs
index 4b2ee21ca5980..c06dbc0fe1ed2 100644
--- a/compiler/rustc_ast_lowering/src/contract.rs
+++ b/compiler/rustc_ast_lowering/src/contract.rs
@@ -1,5 +1,6 @@
use std::sync::Arc;
+use rustc_hir::attrs::lang_items::LangItem;
use thin_vec::thin_vec;
use crate::LoweringContext;
@@ -146,7 +147,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
);
let precond = self.expr_call_lang_item_fn_mut(
req_span,
- rustc_hir::LangItem::ContractCheckRequires,
+ LangItem::ContractCheckRequires,
&*arena_vec![self; lowered_req],
);
self.stmt_expr(req.span, precond)
@@ -165,7 +166,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let lowered_ens = self.lower_expr_mut(&ens);
self.expr_call_lang_item_fn(
ens_span,
- rustc_hir::LangItem::ContractBuildCheckEnsures,
+ LangItem::ContractBuildCheckEnsures,
&*arena_vec![self; lowered_ens],
)
}
@@ -208,7 +209,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let postcond_checker = self.arena.alloc(self.expr_enum_variant_lang_item(
postcond_checker.span,
- rustc_hir::lang_items::LangItem::OptionSome,
+ rustc_hir::attrs::lang_items::LangItem::OptionSome,
&*arena_vec![self; *postcond_checker],
));
let then_block_stmts = self.block_all(span, stmts, Some(postcond_checker));
@@ -216,7 +217,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let none_expr = self.arena.alloc(self.expr_enum_variant_lang_item(
postcond_checker.span,
- rustc_hir::lang_items::LangItem::OptionNone,
+ rustc_hir::attrs::lang_items::LangItem::OptionNone,
Default::default(),
));
let else_block = self.block_expr(none_expr);
@@ -326,7 +327,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let cond_fn = self.expr_ident(span, cond_ident, cond_hir_id);
let contract_check = self.expr_call_lang_item_fn_mut(
span,
- rustc_hir::LangItem::ContractCheckEnsures,
+ LangItem::ContractCheckEnsures,
arena_vec![self; *cond_fn, *ret],
);
let contract_check = self.arena.alloc(contract_check);
diff --git a/compiler/rustc_ast_lowering/src/delegation/attributes.rs b/compiler/rustc_ast_lowering/src/delegation/attributes.rs
index 88bd03389c14c..885ee0d51c730 100644
--- a/compiler/rustc_ast_lowering/src/delegation/attributes.rs
+++ b/compiler/rustc_ast_lowering/src/delegation/attributes.rs
@@ -1,5 +1,5 @@
+use rustc_hir as hir;
use rustc_hir::attrs::{AttributeKind, InlineAttr};
-use rustc_hir::{self as hir};
use rustc_span::Span;
use rustc_span::def_id::DefId;
diff --git a/compiler/rustc_ast_lowering/src/delegation/mod.rs b/compiler/rustc_ast_lowering/src/delegation/mod.rs
index 02fd6de314d3a..3b9074e67bdd2 100644
--- a/compiler/rustc_ast_lowering/src/delegation/mod.rs
+++ b/compiler/rustc_ast_lowering/src/delegation/mod.rs
@@ -45,6 +45,7 @@ use hir::def::Res;
use rustc_abi::ExternAbi;
use rustc_ast as ast;
use rustc_ast::*;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::DefKind;
use rustc_hir::{self as hir, FnDeclFlags};
use rustc_middle::ty::Asyncness;
@@ -341,8 +342,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
crate::re_lowering::ReloweringChecker::allow_relowering(self, |this| {
this.lower_block_noalloc(HirId::INVALID, block, false)
})
- },
- _ => self.lower_block_noalloc(HirId::INVALID, block, false)
+ }
+ _ => self.lower_block_noalloc(HirId::INVALID, block, false),
};
// Remove node ids for which we overwrote resolution to generated param
@@ -456,7 +457,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let expr = self.mk_expr(initializer, span);
- let path = self.make_lang_item_qpath(hir::LangItem::FromFn, span, None);
+ let path = self.make_lang_item_qpath(LangItem::FromFn, span, None);
let path = self.arena.alloc(self.mk_expr(hir::ExprKind::Path(path), span));
let call = hir::ExprKind::Call(path, self.arena.alloc_slice(&[expr]));
diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs
index 06673379a5e9f..b173130d2cc98 100644
--- a/compiler/rustc_ast_lowering/src/expr.rs
+++ b/compiler/rustc_ast_lowering/src/expr.rs
@@ -7,6 +7,7 @@ use rustc_ast::*;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::msg;
use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::{HirId, Target, find_attr};
use rustc_middle::span_bug;
@@ -717,7 +718,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// `::std::ops::Try::from_output($tail_expr)`
block.expr = Some(this.wrap_in_try_constructor(
- hir::LangItem::TryTraitFromOutput,
+ LangItem::TryTraitFromOutput,
try_span,
tail_expr,
ok_wrapped_span,
@@ -737,7 +738,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
fn wrap_in_try_constructor(
&mut self,
- lang_item: hir::LangItem,
+ lang_item: LangItem,
method_span: Span,
expr: &'hir hir::Expr<'hir>,
overall_span: Span,
@@ -836,8 +837,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
self.lower_span(span),
Some(Arc::clone(&self.allow_gen_future)),
);
- let resume_ty =
- self.make_lang_item_qpath(hir::LangItem::ResumeTy, unstable_span, None);
+ let resume_ty = self.make_lang_item_qpath(LangItem::ResumeTy, unstable_span, None);
let input_ty = hir::Ty {
hir_id: self.next_id(),
kind: hir::TyKind::Path(resume_ty),
@@ -1036,23 +1036,23 @@ impl<'hir> LoweringContext<'_, 'hir> {
let new_unchecked = self.expr_call_lang_item_fn_mut(
span,
- hir::LangItem::PinNewUnchecked,
+ LangItem::PinNewUnchecked,
arena_vec![self; ref_mut_awaitee],
);
let get_context = self.expr_call_lang_item_fn_mut(
gen_future_span,
- hir::LangItem::GetContext,
+ LangItem::GetContext,
arena_vec![self; task_context],
);
let call = match await_kind {
FutureKind::Future => self.expr_call_lang_item_fn(
span,
- hir::LangItem::FuturePoll,
+ LangItem::FuturePoll,
arena_vec![self; new_unchecked, get_context],
),
FutureKind::AsyncIterator => self.expr_call_lang_item_fn(
span,
- hir::LangItem::AsyncIteratorPollNext,
+ LangItem::AsyncIteratorPollNext,
arena_vec![self; new_unchecked, get_context],
),
};
@@ -1067,7 +1067,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let (x_pat, x_pat_hid) = self.pat_ident(gen_future_span, x_ident);
let x_expr = self.expr_ident(gen_future_span, x_ident, x_pat_hid);
let ready_field = self.single_pat_field(gen_future_span, x_pat);
- let ready_pat = self.pat_lang_item_variant(span, hir::LangItem::PollReady, ready_field);
+ let ready_pat = self.pat_lang_item_variant(span, LangItem::PollReady, ready_field);
let break_x = self.with_loop_scope(loop_hir_id, move |this| {
let expr_break =
hir::ExprKind::Break(this.lower_loop_destination(None), Some(x_expr));
@@ -1078,7 +1078,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// `::std::task::Poll::Pending => {}`
let pending_arm = {
- let pending_pat = self.pat_lang_item_variant(span, hir::LangItem::PollPending, &[]);
+ let pending_pat = self.pat_lang_item_variant(span, LangItem::PollPending, &[]);
let empty_block = self.expr_block_empty(span);
self.arm(pending_pat, empty_block, span)
};
@@ -1098,7 +1098,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// async gen - task_context = yield ASYNC_GEN_PENDING;
let yield_stmt = {
let yielded = if is_async_gen {
- self.arena.alloc(self.expr_lang_item_path(span, hir::LangItem::AsyncGenPending))
+ self.arena.alloc(self.expr_lang_item_path(span, LangItem::AsyncGenPending))
} else {
self.expr_unit(span)
};
@@ -1140,7 +1140,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let into_future_expr = match await_kind {
FutureKind::Future => self.expr_call_lang_item_fn(
span,
- hir::LangItem::IntoFutureIntoFuture,
+ LangItem::IntoFutureIntoFuture,
arena_vec![self; *expr],
),
// Not needed for `for await` because we expect to have already called
@@ -1444,7 +1444,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
fn lower_expr_range_closed(&mut self, span: Span, e1: &Expr, e2: &Expr) -> hir::ExprKind<'hir> {
let e1 = self.lower_expr_mut(e1);
let e2 = self.lower_expr_mut(e2);
- let fn_path = self.make_lang_item_qpath(hir::LangItem::RangeInclusiveNew, span, None);
+ let fn_path = self.make_lang_item_qpath(LangItem::RangeInclusiveNew, span, None);
let fn_expr = self.arena.alloc(self.expr(span, hir::ExprKind::Path(fn_path)));
hir::ExprKind::Call(fn_expr, arena_vec![self; e1, e2])
}
@@ -1459,32 +1459,32 @@ impl<'hir> LoweringContext<'_, 'hir> {
use rustc_ast::RangeLimits::*;
let lang_item = match (e1, e2, lims) {
- (None, None, HalfOpen) => hir::LangItem::RangeFull,
+ (None, None, HalfOpen) => LangItem::RangeFull,
(Some(..), None, HalfOpen) => {
if self.tcx.features().new_range() {
- hir::LangItem::RangeFromCopy
+ LangItem::RangeFromCopy
} else {
- hir::LangItem::RangeFrom
+ LangItem::RangeFrom
}
}
- (None, Some(..), HalfOpen) => hir::LangItem::RangeTo,
+ (None, Some(..), HalfOpen) => LangItem::RangeTo,
(Some(..), Some(..), HalfOpen) => {
if self.tcx.features().new_range() {
- hir::LangItem::RangeCopy
+ LangItem::RangeCopy
} else {
- hir::LangItem::Range
+ LangItem::Range
}
}
(None, Some(..), Closed) => {
if self.tcx.features().new_range() {
- hir::LangItem::RangeToInclusiveCopy
+ LangItem::RangeToInclusiveCopy
} else {
- hir::LangItem::RangeToInclusive
+ LangItem::RangeToInclusive
}
}
(Some(e1), Some(e2), Closed) => {
if self.tcx.features().new_range() {
- hir::LangItem::RangeInclusiveCopy
+ LangItem::RangeInclusiveCopy
} else {
return self.lower_expr_range_closed(span, e1, e2);
}
@@ -1494,12 +1494,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
match start {
Some(..) => {
if self.tcx.features().new_range() {
- hir::LangItem::RangeFromCopy
+ LangItem::RangeFromCopy
} else {
- hir::LangItem::RangeFrom
+ LangItem::RangeFrom
}
}
- None => hir::LangItem::RangeFull,
+ None => LangItem::RangeFull,
}
}
};
@@ -1511,7 +1511,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
(
if matches!(
lang_item,
- hir::LangItem::RangeInclusiveCopy | hir::LangItem::RangeToInclusiveCopy
+ LangItem::RangeInclusiveCopy | LangItem::RangeToInclusiveCopy
) {
sym::last
} else {
@@ -1691,7 +1691,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
);
let wrapped_yielded = self.expr_call_lang_item_fn(
desugar_span,
- hir::LangItem::AsyncGenReady,
+ LangItem::AsyncGenReady,
std::slice::from_ref(yielded),
);
let yield_expr = self.arena.alloc(
@@ -1781,7 +1781,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let ref_mut_iter = self.expr_mut_addr_of(head_span, iter);
self.expr_call_lang_item_fn(
head_span,
- hir::LangItem::IteratorNext,
+ LangItem::IteratorNext,
arena_vec![self; ref_mut_iter],
)
}
@@ -1796,7 +1796,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// `Pin::new_unchecked(...)`
let iter = self.arena.alloc(self.expr_call_lang_item_fn_mut(
head_span,
- hir::LangItem::PinNewUnchecked,
+ LangItem::PinNewUnchecked,
arena_vec![self; iter],
));
// `unsafe { ... }`
@@ -1831,7 +1831,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// `::std::iter::IntoIterator::into_iter(
)`
let into_iter_expr = self.expr_call_lang_item_fn(
head_span,
- hir::LangItem::IntoIterIntoIter,
+ LangItem::IntoIterIntoIter,
arena_vec![self; head],
);
@@ -1851,7 +1851,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// `Pin::new_unchecked(...)`
let iter = self.arena.alloc(self.expr_call_lang_item_fn_mut(
head_span,
- hir::LangItem::PinNewUnchecked,
+ LangItem::PinNewUnchecked,
arena_vec![self; iter],
));
// `unsafe { ... }`
@@ -1866,7 +1866,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// `::core::async_iter::IntoAsyncIterator::into_async_iter()`
let iter = self.expr_call_lang_item_fn(
head_span,
- hir::LangItem::IntoAsyncIterIntoIter,
+ LangItem::IntoAsyncIterIntoIter,
arena_vec![self; head],
);
let iter_arm = self.arm(async_iter_pat, inner_match_expr, for_span);
@@ -1922,7 +1922,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
self.expr_call_lang_item_fn(
unstable_span,
- hir::LangItem::TryTraitBranch,
+ LangItem::TryTraitBranch,
arena_vec![self; sub_expr],
)
};
@@ -1949,13 +1949,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
let (constructor_item, target_id) = match self.try_block_scope {
TryBlockScope::Function => {
- (hir::LangItem::TryTraitFromResidual, Err(hir::LoopIdError::OutsideLoopScope))
+ (LangItem::TryTraitFromResidual, Err(hir::LoopIdError::OutsideLoopScope))
}
TryBlockScope::Homogeneous(block_id) => {
- (hir::LangItem::ResidualIntoTryType, Ok(block_id))
+ (LangItem::ResidualIntoTryType, Ok(block_id))
}
TryBlockScope::Heterogeneous(block_id) => {
- (hir::LangItem::TryTraitFromResidual, Ok(block_id))
+ (LangItem::TryTraitFromResidual, Ok(block_id))
}
};
let from_residual_expr = self.wrap_in_try_constructor(
@@ -2013,7 +2013,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
);
let from_yeet_expr = self.wrap_in_try_constructor(
- hir::LangItem::TryTraitFromYeet,
+ LangItem::TryTraitFromYeet,
unstable_span,
yeeted_expr,
yeeted_span,
@@ -2140,7 +2140,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
pub(super) fn expr_enum_variant_lang_item(
&mut self,
span: Span,
- lang_item: hir::LangItem,
+ lang_item: LangItem,
fields: &'hir [hir::Expr<'hir>],
) -> hir::Expr<'hir> {
let path = self.arena.alloc(self.make_lang_item_qpath(lang_item, span, None));
@@ -2159,7 +2159,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
pub(super) fn expr_call_lang_item_fn_mut(
&mut self,
span: Span,
- lang_item: hir::LangItem,
+ lang_item: LangItem,
args: &'hir [hir::Expr<'hir>],
) -> hir::Expr<'hir> {
let path = self.arena.alloc(self.expr_lang_item_path(span, lang_item));
@@ -2169,7 +2169,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
pub(super) fn expr_call_lang_item_fn(
&mut self,
span: Span,
- lang_item: hir::LangItem,
+ lang_item: LangItem,
args: &'hir [hir::Expr<'hir>],
) -> &'hir hir::Expr<'hir> {
self.arena.alloc(self.expr_call_lang_item_fn_mut(span, lang_item, args))
@@ -2178,7 +2178,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
pub(super) fn expr_lang_item_path(
&mut self,
span: Span,
- lang_item: hir::LangItem,
+ lang_item: LangItem,
) -> hir::Expr<'hir> {
let qpath = self.make_lang_item_qpath(lang_item, self.lower_span(span), None);
self.expr(span, hir::ExprKind::Path(qpath))
@@ -2188,7 +2188,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
pub(super) fn expr_lang_item_type_relative(
&mut self,
span: Span,
- lang_item: hir::LangItem,
+ lang_item: LangItem,
name: Symbol,
) -> hir::Expr<'hir> {
let qpath = self.make_lang_item_qpath(lang_item, self.lower_span(span), None);
diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs
index 602635af1324e..b9974edea71a4 100644
--- a/compiler/rustc_ast_lowering/src/format.rs
+++ b/compiler/rustc_ast_lowering/src/format.rs
@@ -3,6 +3,7 @@ use std::borrow::Cow;
use rustc_ast::*;
use rustc_data_structures::fx::FxIndexMap;
use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_session::config::FmtDebug;
use rustc_span::{ByteSymbol, DesugaringKind, Ident, Span, Symbol, sym};
@@ -239,7 +240,7 @@ fn make_argument<'hir>(
use FormatTrait::*;
let new_fn = ctx.arena.alloc(ctx.expr_lang_item_type_relative(
sp,
- hir::LangItem::FormatArgument,
+ LangItem::FormatArgument,
match ty {
Format(Display) => sym::new_display,
Format(Debug) => match ctx.tcx.sess.opts.unstable_opts.fmt_debug {
@@ -331,7 +332,7 @@ fn expand_format_args<'hir>(
// ::from_str("meow")
let from_str = ctx.arena.alloc(ctx.expr_lang_item_type_relative(
macsp,
- hir::LangItem::FormatArguments,
+ LangItem::FormatArguments,
if allow_const { sym::from_str } else { sym::from_str_nonconst },
));
let sym = if incomplete_lit.is_empty() { sym } else { Symbol::intern(s) };
@@ -501,7 +502,7 @@ fn expand_format_args<'hir>(
let call = {
let new = ctx.arena.alloc(ctx.expr_lang_item_type_relative(
macsp,
- hir::LangItem::FormatArguments,
+ LangItem::FormatArguments,
sym::new,
));
let args = ctx.expr_ref(macsp, args);
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs
index 7784fc17828aa..474a2a1d6adc2 100644
--- a/compiler/rustc_ast_lowering/src/lib.rs
+++ b/compiler/rustc_ast_lowering/src/lib.rs
@@ -54,6 +54,7 @@ use rustc_data_structures::tagged_ptr::TaggedRef;
use rustc_data_structures::unord::ExtendUnord;
use rustc_errors::codes::*;
use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle, ErrorGuaranteed};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId, LocalDefIdMap};
use rustc_hir::definitions::PerParentDisambiguatorState;
@@ -104,7 +105,7 @@ pub fn provide(providers: &mut Providers) {
pub(crate) mod re_lowering {
use rustc_ast::NodeId;
use rustc_ast::node_id::NodeMap;
- use rustc_hir::{self as hir};
+ use rustc_hir as hir;
use crate::LoweringContext;
@@ -1012,7 +1013,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
fn make_lang_item_qpath(
&mut self,
- lang_item: hir::LangItem,
+ lang_item: LangItem,
span: Span,
args: Option<&'hir hir::GenericArgs<'hir>>,
) -> hir::QPath<'hir> {
@@ -1021,7 +1022,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
fn make_lang_item_path(
&mut self,
- lang_item: hir::LangItem,
+ lang_item: LangItem,
span: Span,
args: Option<&'hir hir::GenericArgs<'hir>>,
) -> &'hir hir::Path<'hir> {
@@ -1584,7 +1585,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
parenthesized: hir::GenericArgsParentheses::No,
span_ext: span,
});
- let path = self.make_lang_item_qpath(hir::LangItem::Pin, span, Some(args));
+ let path = self.make_lang_item_qpath(LangItem::Pin, span, Some(args));
hir::TyKind::Path(path)
}
TyKind::FnPtr(f) => {
@@ -2135,9 +2136,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
// "<$assoc_ty_name = T>"
let (assoc_ty_name, trait_lang_item) = match coro {
- CoroutineKind::Async { .. } => (sym::Output, hir::LangItem::Future),
- CoroutineKind::Gen { .. } => (sym::Item, hir::LangItem::Iterator),
- CoroutineKind::AsyncGen { .. } => (sym::Item, hir::LangItem::AsyncIterator),
+ CoroutineKind::Async { .. } => (sym::Output, LangItem::Future),
+ CoroutineKind::Gen { .. } => (sym::Item, LangItem::Iterator),
+ CoroutineKind::AsyncGen { .. } => (sym::Item, LangItem::AsyncIterator),
};
let bound_args = self.arena.alloc(hir::GenericArgs {
@@ -2459,7 +2460,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let extended = self.tcx.features().more_maybe_bounds();
let is_sized = trait_ref
.trait_def_id()
- .is_some_and(|def_id| self.tcx.is_lang_item(def_id, hir::LangItem::Sized));
+ .is_some_and(|def_id| self.tcx.is_lang_item(def_id, LangItem::Sized));
if extended && !is_sized {
return;
@@ -3127,21 +3128,21 @@ impl<'hir> LoweringContext<'_, 'hir> {
fn pat_cf_continue(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
let field = self.single_pat_field(span, pat);
- self.pat_lang_item_variant(span, hir::LangItem::ControlFlowContinue, field)
+ self.pat_lang_item_variant(span, LangItem::ControlFlowContinue, field)
}
fn pat_cf_break(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
let field = self.single_pat_field(span, pat);
- self.pat_lang_item_variant(span, hir::LangItem::ControlFlowBreak, field)
+ self.pat_lang_item_variant(span, LangItem::ControlFlowBreak, field)
}
fn pat_some(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
let field = self.single_pat_field(span, pat);
- self.pat_lang_item_variant(span, hir::LangItem::OptionSome, field)
+ self.pat_lang_item_variant(span, LangItem::OptionSome, field)
}
fn pat_none(&mut self, span: Span) -> &'hir hir::Pat<'hir> {
- self.pat_lang_item_variant(span, hir::LangItem::OptionNone, &[])
+ self.pat_lang_item_variant(span, LangItem::OptionNone, &[])
}
fn single_pat_field(
@@ -3162,7 +3163,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
fn pat_lang_item_variant(
&mut self,
span: Span,
- lang_item: hir::LangItem,
+ lang_item: LangItem,
fields: &'hir [hir::PatField<'hir>],
) -> &'hir hir::Pat<'hir> {
let path = self.make_lang_item_qpath(lang_item, self.lower_span(span), None);
diff --git a/compiler/rustc_ast_lowering/src/pat.rs b/compiler/rustc_ast_lowering/src/pat.rs
index 8780b70fadfa4..e14597c04742a 100644
--- a/compiler/rustc_ast_lowering/src/pat.rs
+++ b/compiler/rustc_ast_lowering/src/pat.rs
@@ -2,8 +2,9 @@ use std::sync::Arc;
use rustc_ast::*;
use rustc_data_structures::stack::ensure_sufficient_stack;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{DefKind, Res};
-use rustc_hir::{self as hir, LangItem, Target};
+use rustc_hir::{self as hir, Target};
use rustc_middle::span_bug;
use rustc_span::{DesugaringKind, Ident, Span, Spanned, respan};
@@ -454,7 +455,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
.map(|e| self.lower_anon_const_to_const_arg_and_alloc(e))
.unwrap_or_else(|| {
self.lower_ty_pat_range_end(
- hir::LangItem::RangeMin,
+ LangItem::RangeMin,
span.shrink_to_lo(),
base_type,
)
@@ -466,7 +467,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
})
.unwrap_or_else(|| {
self.lower_ty_pat_range_end(
- hir::LangItem::RangeMax,
+ LangItem::RangeMax,
span.shrink_to_hi(),
base_type,
)
@@ -499,7 +500,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
let body = this.lower_body(|this| {
// Need to use a custom function as we can't just subtract `1` from a `char`.
let kind = hir::ExprKind::Path(this.make_lang_item_qpath(
- hir::LangItem::RangeSub,
+ LangItem::RangeSub,
unstable_span,
None,
));
diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs
index d1368d8f9f633..c630277dc77e2 100644
--- a/compiler/rustc_ast_passes/src/ast_validation.rs
+++ b/compiler/rustc_ast_passes/src/ast_validation.rs
@@ -1001,29 +1001,14 @@ impl<'a> AstValidator<'a> {
dotdotdot_span: Span,
sig: &FnSig,
) {
- // For naked functions we accept any ABI that is accepted on c-variadic
- // foreign functions, if the c_variadic_naked_functions feature is enabled.
if attr::contains_name(attrs, sym::naked) {
match abi.supports_c_variadic() {
- CVariadicStatus::Stable if let ExternAbi::C { .. } = abi => {
- // With `c_variadic` naked c-variadic `extern "C"` functions are allowed.
- }
CVariadicStatus::Stable => {
- // For e.g. aapcs or sysv64 `c_variadic_naked_functions` must also be enabled.
- if !self.features.enabled(sym::c_variadic_naked_functions) {
- let msg = format!("Naked c-variadic `extern {abi}` functions are unstable");
- feature_err(&self.sess, sym::c_variadic_naked_functions, sig.span, msg)
- .emit();
- }
+ // For naked functions we accept any ABI that is accepted
+ // on c-variadic foreign functions.
}
CVariadicStatus::Unstable { feature } => {
- // Some ABIs need additional features.
- if !self.features.enabled(sym::c_variadic_naked_functions) {
- let msg = format!("Naked c-variadic `extern {abi}` functions are unstable");
- feature_err(&self.sess, sym::c_variadic_naked_functions, sig.span, msg)
- .emit();
- }
-
+ // Some ABIs need additional features to be enabled.
if !self.features.enabled(feature) {
let msg = format!(
"C-variadic functions with the {abi} calling convention are unstable"
diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs
index 5b7d305ba0d28..10d9858864a3e 100644
--- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs
+++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs
@@ -3,7 +3,7 @@ use std::path::PathBuf;
use rustc_ast::{LitIntType, LitKind, MetaItemLit};
use rustc_data_structures::fx::FxHashMap;
use rustc_feature::AttributeStability;
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::attrs::{
BorrowckGraphvizFormatKind, CguFields, CguKind, DivergingBlockBehavior,
DivergingFallbackBehavior, RustcCleanAttribute, RustcCleanQueries, RustcMirKind,
diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
index d40f611150233..7267ae113de3e 100644
--- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
@@ -10,11 +10,10 @@ use rustc_errors::codes::*;
use rustc_errors::{Applicability, Diag, MultiSpan, struct_span_code_err};
use rustc_hir as hir;
use rustc_hir::attrs::diagnostic::{CustomDiagnostic, FormatArgs};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::intravisit::{Visitor, walk_block, walk_expr};
-use rustc_hir::{
- CoroutineDesugaring, CoroutineKind, CoroutineSource, LangItem, PatField, find_attr,
-};
+use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, PatField, find_attr};
use rustc_index::bit_set::DenseBitSet;
use rustc_infer::traits::TraitErrors;
use rustc_middle::bug;
diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs
index bde2529d855cf..349337f273aab 100644
--- a/compiler/rustc_borrowck/src/diagnostics/mod.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs
@@ -6,9 +6,10 @@ use rustc_abi::{FieldIdx, VariantIdx};
use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::formatting::DiagMessageAddArg;
use rustc_errors::{Applicability, Diag, DiagMessage, EmissionGuarantee, MultiSpan, listify, msg};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{CtorKind, Namespace};
use rustc_hir::{
- self as hir, CoroutineKind, GenericBound, LangItem, WhereBoundPredicate, WherePredicateKind,
+ self as hir, CoroutineKind, GenericBound, WhereBoundPredicate, WherePredicateKind,
};
use rustc_index::{IndexSlice, IndexVec};
use rustc_infer::infer::{BoundRegionConversionTime, NllRegionVariableOrigin};
diff --git a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
index 68e7e3786b33c..49e6dc334ff80 100644
--- a/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
@@ -4,6 +4,7 @@ use either::Either;
use hir::{ExprKind, Param};
use rustc_abi::FieldIdx;
use rustc_errors::{Applicability, Diag};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::Visitor;
use rustc_hir::{self as hir, BindingMode, ByRef, Expr, Node};
@@ -1928,11 +1929,11 @@ fn suggest_ampmut<'tcx>(
&call.kind
&& let ty::FnDef(method_def_id, method_args) = *const_operand.ty().kind()
&& let Some(trait_) = tcx.trait_of_assoc(method_def_id)
- && tcx.is_lang_item(trait_, hir::LangItem::Index)
+ && tcx.is_lang_item(trait_, LangItem::Index)
{
let trait_ref = ty::TraitRef::from_assoc(
tcx,
- tcx.require_lang_item(hir::LangItem::IndexMut, rhs_span),
+ tcx.require_lang_item(LangItem::IndexMut, rhs_span),
method_args.no_bound_vars().unwrap(),
);
// The type only implements `Index` but not `IndexMut`, we must not suggest `&mut`.
diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs
index 6825c28270c30..776d23c580a54 100644
--- a/compiler/rustc_borrowck/src/type_check/mod.rs
+++ b/compiler/rustc_borrowck/src/type_check/mod.rs
@@ -8,9 +8,9 @@ use rustc_data_structures::frozen::Frozen;
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::LocalDefId;
-use rustc_hir::lang_items::LangItem;
use rustc_index::{IndexSlice, IndexVec};
use rustc_infer::infer::canonical::QueryRegionConstraints;
use rustc_infer::infer::outlives::env::RegionBoundPairs;
diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs
index 3479224cc5546..dd3b615918b72 100644
--- a/compiler/rustc_borrowck/src/universal_regions.rs
+++ b/compiler/rustc_borrowck/src/universal_regions.rs
@@ -17,9 +17,9 @@ use std::iter;
use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::Diag;
use rustc_hir::BodyOwnerKind;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId};
-use rustc_hir::lang_items::LangItem;
use rustc_index::IndexVec;
use rustc_infer::infer::NllRegionVariableOrigin;
use rustc_macros::extension;
diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs
index d57f662fc1938..27bb19c8d53c5 100644
--- a/compiler/rustc_codegen_cranelift/src/base.rs
+++ b/compiler/rustc_codegen_cranelift/src/base.rs
@@ -8,6 +8,7 @@ use rustc_ast::InlineAsmOptions;
use rustc_codegen_ssa::base::is_call_from_compiler_builtins_to_upstream_monomorphization;
use rustc_data_structures::profiling::SelfProfilerRef;
use rustc_errors::DiagCtxtHandle;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_index::IndexVec;
use rustc_middle::ty::TypeVisitableExt;
use rustc_middle::ty::adjustment::PointerCoercion;
@@ -390,7 +391,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
codegen_panic_inner(
fx,
- rustc_hir::LangItem::PanicBoundsCheck,
+ LangItem::PanicBoundsCheck,
&[index, len, location],
*unwind,
source_info.span,
@@ -403,7 +404,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
codegen_panic_inner(
fx,
- rustc_hir::LangItem::PanicMisalignedPointerDereference,
+ LangItem::PanicMisalignedPointerDereference,
&[required, found, location],
*unwind,
source_info.span,
@@ -414,7 +415,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
codegen_panic_inner(
fx,
- rustc_hir::LangItem::PanicNullPointerDereference,
+ LangItem::PanicNullPointerDereference,
&[location],
*unwind,
source_info.span,
@@ -425,7 +426,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
codegen_panic_inner(
fx,
- rustc_hir::LangItem::PanicNullReferenceConstructed,
+ LangItem::PanicNullReferenceConstructed,
&[location],
*unwind,
source_info.span,
@@ -437,7 +438,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
codegen_panic_inner(
fx,
- rustc_hir::LangItem::PanicInvalidEnumConstruction,
+ LangItem::PanicInvalidEnumConstruction,
&[source, location],
*unwind,
source_info.span,
@@ -1082,7 +1083,7 @@ pub(crate) fn codegen_panic_nounwind<'tcx>(
codegen_panic_inner(
fx,
- rustc_hir::LangItem::PanicNounwind,
+ LangItem::PanicNounwind,
&args,
UnwindAction::Terminate(UnwindTerminateReason::Abi),
span,
@@ -1099,7 +1100,7 @@ pub(crate) fn codegen_unwind_terminate<'tcx>(
fn codegen_panic_inner<'tcx>(
fx: &mut FunctionCx<'_, '_, 'tcx>,
- lang_item: rustc_hir::LangItem,
+ lang_item: LangItem,
args: &[Value],
unwind: UnwindAction,
span: Span,
diff --git a/compiler/rustc_codegen_cranelift/src/inline_asm.rs b/compiler/rustc_codegen_cranelift/src/inline_asm.rs
index 0b8eb75972ec0..1bb33e292c7d9 100644
--- a/compiler/rustc_codegen_cranelift/src/inline_asm.rs
+++ b/compiler/rustc_codegen_cranelift/src/inline_asm.rs
@@ -5,7 +5,7 @@ use std::fmt::Write;
use cranelift_codegen::isa::CallConv;
use rustc_abi::CanonAbi;
use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece};
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_middle::ty::layout::FnAbiOf;
use rustc_span::sym;
use rustc_target::asm::*;
diff --git a/compiler/rustc_codegen_cranelift/src/main_shim.rs b/compiler/rustc_codegen_cranelift/src/main_shim.rs
index 109933f4d8556..b69db582a04ca 100644
--- a/compiler/rustc_codegen_cranelift/src/main_shim.rs
+++ b/compiler/rustc_codegen_cranelift/src/main_shim.rs
@@ -1,5 +1,5 @@
use cranelift_frontend::{FunctionBuilder, FunctionBuilderContext};
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_middle::ty::{AssocTag, GenericArg, Unnormalized};
use rustc_session::config::EntryFnType;
use rustc_span::{DUMMY_SP, Ident};
diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs
index ee752373ceca4..5ecd5c19b6f8e 100644
--- a/compiler/rustc_codegen_llvm/src/consts.rs
+++ b/compiler/rustc_codegen_llvm/src/consts.rs
@@ -3,8 +3,8 @@ use std::ops::Range;
use rustc_abi::{Align, ExternAbi, HasDataLayout, Primitive, Scalar, Size, WrappingRange};
use rustc_codegen_ssa::common;
use rustc_codegen_ssa::traits::*;
-use rustc_hir::LangItem;
use rustc_hir::attrs::Linkage;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs
index b9cde145ce514..feccbd953cc1c 100644
--- a/compiler/rustc_codegen_llvm/src/llvm_util.rs
+++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs
@@ -392,8 +392,7 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
cfg.has_reliable_f128 = match (target_arch, target_os) {
// Unsupported https://github.com/llvm/llvm-project/issues/121122
(Arch::AmdGpu, _) => false,
- // Unsupported
- (Arch::Arm64EC, _) => false,
+ (Arch::Arm64EC, _) if major < 23 => false, // (fixed in llvm23)
// Selection bug . This issue is closed
// but basic math still does not work.
(Arch::Nvptx64, _) => false,
diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs
index 40ff5fa58de69..0468e3de18d8b 100644
--- a/compiler/rustc_codegen_ssa/src/base.rs
+++ b/compiler/rustc_codegen_ssa/src/base.rs
@@ -13,9 +13,9 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
use rustc_data_structures::profiling::{get_resident_set_size, print_time_passes_entry};
use rustc_data_structures::sync::{IntoDynSyncSend, par_map};
use rustc_data_structures::unord::UnordMap;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::attrs::{DebuggerVisualizerType, EiiDecl, EiiImpl, OptimizeAttr};
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
-use rustc_hir::lang_items::LangItem;
use rustc_hir::{ItemId, Target, find_attr};
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
diff --git a/compiler/rustc_codegen_ssa/src/common.rs b/compiler/rustc_codegen_ssa/src/common.rs
index 777f3f6b53fd4..e9024b7dbe934 100644
--- a/compiler/rustc_codegen_ssa/src/common.rs
+++ b/compiler/rustc_codegen_ssa/src/common.rs
@@ -1,7 +1,7 @@
#![allow(non_camel_case_types)]
-use rustc_hir::LangItem;
use rustc_hir::attrs::PeImportNameType;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_middle::mir::interpret::{GlobalAlloc, PointerArithmetic, Scalar};
use rustc_middle::ty::layout::TyAndLayout;
use rustc_middle::ty::{self, Instance, ScalarInt, TyCtxt};
diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs
index aab4259b6b41d..7f907bc630b2f 100644
--- a/compiler/rustc_codegen_ssa/src/mir/block.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/block.rs
@@ -9,7 +9,7 @@ use rustc_ast as ast;
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_data_structures::packed::Pu128;
use rustc_hir::attrs::AttributeKind;
-use rustc_hir::lang_items::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_lint_defs::builtin::TAIL_CALL_TRACK_CALLER;
use rustc_middle::mir::interpret::{CTFE_ALLOC_SALT, Scalar};
use rustc_middle::mir::{self, AssertKind, InlineAsmMacro, SwitchTargets, UnwindTerminateReason};
diff --git a/compiler/rustc_codegen_ssa/src/mir/operand.rs b/compiler/rustc_codegen_ssa/src/mir/operand.rs
index 1dbbc3fd28fb9..c1a1b2db6fa9d 100644
--- a/compiler/rustc_codegen_ssa/src/mir/operand.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/operand.rs
@@ -5,7 +5,7 @@ use rustc_abi as abi;
use rustc_abi::{
Align, BackendRepr, FIRST_VARIANT, FieldIdx, Primitive, Size, TagEncoding, VariantIdx, Variants,
};
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_middle::mir::interpret::{Pointer, Scalar, alloc_range};
use rustc_middle::mir::{self, ConstValue};
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
diff --git a/compiler/rustc_codegen_ssa/src/size_of_val.rs b/compiler/rustc_codegen_ssa/src/size_of_val.rs
index 52ffc321cbb6f..3c4369330da59 100644
--- a/compiler/rustc_codegen_ssa/src/size_of_val.rs
+++ b/compiler/rustc_codegen_ssa/src/size_of_val.rs
@@ -1,7 +1,7 @@
//! Computing the size and alignment of a value.
use rustc_abi::{Align, WrappingRange};
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_middle::bug;
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
use rustc_middle::ty::{self, Ty};
diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs
index ee2157b5a2b0f..7648bf4eb241d 100644
--- a/compiler/rustc_const_eval/src/check_consts/check.rs
+++ b/compiler/rustc_const_eval/src/check_consts/check.rs
@@ -6,9 +6,10 @@ use std::ops::Deref;
use std::{assert_matches, mem};
use rustc_errors::{Diag, ErrorGuaranteed};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
-use rustc_hir::{self as hir, LangItem, find_attr};
+use rustc_hir::{self as hir, find_attr};
use rustc_index::bit_set::DenseBitSet;
use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::mir::visit::Visitor;
diff --git a/compiler/rustc_const_eval/src/check_consts/ops.rs b/compiler/rustc_const_eval/src/check_consts/ops.rs
index 76c0c5f0d3bdf..0ce87d0ddc922 100644
--- a/compiler/rustc_const_eval/src/check_consts/ops.rs
+++ b/compiler/rustc_const_eval/src/check_consts/ops.rs
@@ -1,9 +1,10 @@
//! Concrete error types for all operations which may be invalid in a certain const context.
-use hir::{ConstContext, LangItem};
+use hir::ConstContext;
use rustc_errors::codes::*;
use rustc_errors::{Applicability, Diag, MultiSpan, msg};
use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::DefId;
use rustc_infer::infer::TyCtxtInferExt;
use rustc_infer::traits::{ImplSource, Obligation, ObligationCause};
diff --git a/compiler/rustc_const_eval/src/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/check_consts/qualifs.rs
index fa54d1ed4e562..b2b8a567860e0 100644
--- a/compiler/rustc_const_eval/src/check_consts/qualifs.rs
+++ b/compiler/rustc_const_eval/src/check_consts/qualifs.rs
@@ -6,7 +6,7 @@
// having basically only two use-cases that act in different ways.
use rustc_errors::ErrorGuaranteed;
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::mir::*;
use rustc_middle::ty::{self, AdtDef, Ty, TypingMode};
diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs
index 3f52fbecb0950..6f4919cbe507f 100644
--- a/compiler/rustc_const_eval/src/const_eval/machine.rs
+++ b/compiler/rustc_const_eval/src/const_eval/machine.rs
@@ -5,8 +5,9 @@ use std::{fmt, mem};
use rustc_abi::{Align, FIRST_VARIANT, FieldIdx, Size, VariantIdx};
use rustc_ast::Mutability;
use rustc_data_structures::fx::{FxHashMap, FxIndexMap, IndexEntry};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::{DefId, LocalDefId};
-use rustc_hir::{self as hir, CRATE_HIR_ID, LangItem, find_attr};
+use rustc_hir::{self as hir, CRATE_HIR_ID, find_attr};
use rustc_middle::mir::AssertMessage;
use rustc_middle::mir::interpret::ReportedErrorInfo;
use rustc_middle::query::TyCtxtAt;
diff --git a/compiler/rustc_const_eval/src/const_eval/type_info.rs b/compiler/rustc_const_eval/src/const_eval/type_info.rs
index 7c0fef3734975..d77e43b9858af 100644
--- a/compiler/rustc_const_eval/src/const_eval/type_info.rs
+++ b/compiler/rustc_const_eval/src/const_eval/type_info.rs
@@ -4,7 +4,7 @@ use std::borrow::Cow;
use rustc_abi::{ExternAbi, FieldIdx};
use rustc_ast::Mutability;
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_middle::span_bug;
use rustc_middle::ty::layout::TyAndLayout;
use rustc_middle::ty::{self, Const, FnHeader, FnSigKind, FnSigTys, ScalarInt, Ty, TyCtxt};
diff --git a/compiler/rustc_const_eval/src/interpret/intern.rs b/compiler/rustc_const_eval/src/interpret/intern.rs
index ecc00547e4599..49152f4c40ae2 100644
--- a/compiler/rustc_const_eval/src/interpret/intern.rs
+++ b/compiler/rustc_const_eval/src/interpret/intern.rs
@@ -16,8 +16,8 @@
use hir::def::DefKind;
use rustc_ast::Mutability;
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
+use rustc_hir as hir;
use rustc_hir::definitions::{DefPathData, PerParentDisambiguatorState};
-use rustc_hir::{self as hir};
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
use rustc_middle::mir::interpret::{
AllocBytes, ConstAllocation, CtfeProvenance, InterpResult, Provenance,
diff --git a/compiler/rustc_const_eval/src/util/caller_location.rs b/compiler/rustc_const_eval/src/util/caller_location.rs
index 18464df1e03f1..09d613bc7841a 100644
--- a/compiler/rustc_const_eval/src/util/caller_location.rs
+++ b/compiler/rustc_const_eval/src/util/caller_location.rs
@@ -1,5 +1,5 @@
use rustc_abi::FieldIdx;
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_middle::ty::{self, TyCtxt};
use rustc_middle::{bug, mir};
use rustc_span::Symbol;
diff --git a/compiler/rustc_data_structures/src/profiling.rs b/compiler/rustc_data_structures/src/profiling.rs
index cab57edb89461..00fb424cadfd1 100644
--- a/compiler/rustc_data_structures/src/profiling.rs
+++ b/compiler/rustc_data_structures/src/profiling.rs
@@ -955,30 +955,25 @@ fn get_thread_id() -> u32 {
cfg_select! {
windows => {
pub fn get_resident_set_size() -> Option {
- use windows::{
- Win32::System::ProcessStatus::{K32GetProcessMemoryInfo, PROCESS_MEMORY_COUNTERS},
- Win32::System::Threading::GetCurrentProcess,
+ use windows::Win32::System::ProcessStatus::{
+ K32GetProcessMemoryInfo, PROCESS_MEMORY_COUNTERS,
};
+ use windows::Win32::System::Threading::GetCurrentProcess;
let mut pmc = PROCESS_MEMORY_COUNTERS::default();
let pmc_size = size_of_val(&pmc);
- unsafe {
- K32GetProcessMemoryInfo(
- GetCurrentProcess(),
- &mut pmc,
- pmc_size as u32,
- )
- }
- .ok()
- .ok()?;
+ unsafe { K32GetProcessMemoryInfo(GetCurrentProcess(), &mut pmc, pmc_size as u32) }
+ .ok()
+ .ok()?;
Some(pmc.WorkingSetSize)
}
}
target_os = "macos" => {
pub fn get_resident_set_size() -> Option {
- use libc::{c_int, c_void, getpid, proc_pidinfo, proc_taskinfo, PROC_PIDTASKINFO};
use std::mem;
+
+ use libc::{PROC_PIDTASKINFO, c_int, c_void, getpid, proc_pidinfo, proc_taskinfo};
const PROC_TASKINFO_SIZE: c_int = size_of::() as c_int;
unsafe {
@@ -986,17 +981,13 @@ cfg_select! {
let info_ptr = &mut info as *mut proc_taskinfo as *mut c_void;
let pid = getpid() as c_int;
let ret = proc_pidinfo(pid, PROC_PIDTASKINFO, 0, info_ptr, PROC_TASKINFO_SIZE);
- if ret == PROC_TASKINFO_SIZE {
- Some(info.pti_resident_size as usize)
- } else {
- None
- }
+ if ret == PROC_TASKINFO_SIZE { Some(info.pti_resident_size as usize) } else { None }
}
}
}
unix => {
pub fn get_resident_set_size() -> Option {
- use libc::{sysconf, _SC_PAGESIZE};
+ use libc::{_SC_PAGESIZE, sysconf};
let field = 1;
let contents = fs::read("/proc/self/statm").ok()?;
let contents = String::from_utf8(contents).ok()?;
diff --git a/compiler/rustc_data_structures/src/sharded.rs b/compiler/rustc_data_structures/src/sharded.rs
index 7be6b8dc41d9a..adb4516e7a54d 100644
--- a/compiler/rustc_data_structures/src/sharded.rs
+++ b/compiler/rustc_data_structures/src/sharded.rs
@@ -201,7 +201,7 @@ impl ShardedHashMap {
Entry::Vacant(e) => {
e.insert((key, value));
}
- }
+ },
_ => {
shard.insert_unique(hash, (key, value), |(k, _)| make_hash(k));
}
diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs
index 9f42c5c1e7f0b..c71fecf046c9b 100644
--- a/compiler/rustc_feature/src/accepted.rs
+++ b/compiler/rustc_feature/src/accepted.rs
@@ -96,6 +96,9 @@ declare_features! (
(accepted, c_unwind, "1.81.0", Some(74990)),
/// Allows using C-variadics.
(accepted, c_variadic, "CURRENT_RUSTC_VERSION", Some(44930)),
+ /// Allows defining c-variadic naked functions with any extern ABI that is allowed
+ /// on c-variadic foreign functions.
+ (accepted, c_variadic_naked_functions, "CURRENT_RUSTC_VERSION", Some(148767)),
/// Allows `#[cfg_attr(predicate, multiple, attributes, here)]`.
(accepted, cfg_attr_multi, "1.33.0", Some(54881)),
/// Allows the use of `#[cfg()]`.
diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs
index 84d5447e07da2..3a80145e2897d 100644
--- a/compiler/rustc_feature/src/unstable.rs
+++ b/compiler/rustc_feature/src/unstable.rs
@@ -429,9 +429,6 @@ declare_features! (
/// Allows defining c-variadic functions on targets where this feature has not yet
/// undergone sufficient testing for stabilization.
(unstable, c_variadic_experimental_arch, "1.97.0", Some(155973)),
- /// Allows defining c-variadic naked functions with any extern ABI that is allowed
- /// on c-variadic foreign functions.
- (unstable, c_variadic_naked_functions, "1.93.0", Some(148767)),
/// Allows the use of `#[cfg(contract_checks)` to check if contract checks are enabled.
(unstable, cfg_contract_checks, "1.86.0", Some(128044)),
/// Allows the use of `#[cfg(overflow_checks)` to check if integer overflow behaviour.
diff --git a/compiler/rustc_hir/src/lib.rs b/compiler/rustc_hir/src/lib.rs
index b073ed4d8ed12..3885e28133087 100644
--- a/compiler/rustc_hir/src/lib.rs
+++ b/compiler/rustc_hir/src/lib.rs
@@ -39,10 +39,9 @@ pub use {
attrs::target::{self, MethodKind, Target},
attrs::{
AttrArgs, AttrItem, AttrPath, Attribute, ConstStability, DefaultBodyStability,
- HashIgnoredAttrId, LangItem, LanguageItems, PartialConstStability, Stability,
- StabilityLevel, StableSince, UnstableReason, VERSION_PLACEHOLDER,
+ HashIgnoredAttrId, PartialConstStability, Stability, StabilityLevel, StableSince,
+ UnstableReason, VERSION_PLACEHOLDER,
},
- attrs::{diagnostic_items, lang_items, weak_lang_items},
};
pub use crate::arena::Arena;
diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs
index f7d6af3c65dda..d98125f7cd9f9 100644
--- a/compiler/rustc_hir_analysis/src/check/check.rs
+++ b/compiler/rustc_hir_analysis/src/check/check.rs
@@ -7,8 +7,9 @@ use rustc_errors::codes::*;
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, MultiSpan};
use rustc_hir as hir;
use rustc_hir::attrs::ReprAttr::ReprPacked;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{CtorKind, DefKind};
-use rustc_hir::{LangItem, Node, find_attr, intravisit};
+use rustc_hir::{Node, find_attr, intravisit};
use rustc_infer::infer::{RegionVariableOrigin, TyCtxtInferExt};
use rustc_infer::traits::{Obligation, ObligationCauseCode, TraitErrors, WellFormedLoc};
use rustc_lint_defs::builtin::UNSUPPORTED_CALLING_CONVENTIONS;
@@ -1377,7 +1378,7 @@ fn check_impl_items_against_trait<'tcx>(
// instead of `Drop::drop` is unstable that might be confusing.
EvalResult::Deny { .. }
if !tcx.features().pin_ergonomics()
- && tcx.is_lang_item(trait_ref.def_id, hir::LangItem::Drop)
+ && tcx.is_lang_item(trait_ref.def_id, LangItem::Drop)
&& tcx.item_name(trait_item_id) == sym::drop =>
{
missing_items.push(tcx.associated_item(trait_item_id));
diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs
index 67fddd87fbb1d..3fea9d44946f6 100644
--- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs
+++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs
@@ -1,7 +1,8 @@
//! Type-checking for the `#[rustc_intrinsic]` intrinsics that the compiler exposes.
use rustc_errors::DiagMessage;
-use rustc_hir::{self as hir, LangItem};
+use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
use rustc_middle::ty::{self, Const, Ty, TyCtxt};
use rustc_span::def_id::LocalDefId;
@@ -639,9 +640,8 @@ pub(crate) fn check_intrinsic_type(
}
sym::discriminant_value => {
- let assoc_items = tcx.associated_item_def_ids(
- tcx.require_lang_item(hir::LangItem::DiscriminantKind, span),
- );
+ let assoc_items = tcx
+ .associated_item_def_ids(tcx.require_lang_item(LangItem::DiscriminantKind, span));
let discriminant_def_id = assoc_items[0];
let br = ty::BoundRegion { var: ty::BoundVar::ZERO, kind: ty::BoundRegionKind::Anon };
diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs
index de80d32b88578..e9bc2a2d281d4 100644
--- a/compiler/rustc_hir_analysis/src/check/mod.rs
+++ b/compiler/rustc_hir_analysis/src/check/mod.rs
@@ -78,7 +78,7 @@ pub use check::{check_abi, check_custom_abi};
use rustc_abi::VariantIdx;
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
use rustc_errors::{ErrorGuaranteed, pluralize, struct_span_code_err};
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::intravisit::Visitor;
use rustc_index::bit_set::DenseBitSet;
diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs
index 553ee4b9c5a02..9a498837b1f4d 100644
--- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs
+++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs
@@ -8,10 +8,10 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
use rustc_errors::codes::*;
use rustc_errors::{Applicability, ErrorGuaranteed, msg, pluralize, struct_span_code_err};
use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::attrs::{EiiDecl, EiiImpl, EiiImplResolution};
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{DefId, LocalDefId};
-use rustc_hir::lang_items::LangItem;
use rustc_hir::{AmbigArg, ItemKind, find_attr};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
@@ -1655,13 +1655,13 @@ fn check_fn_or_method<'tcx>(
ObligationCause::new(span, wfcx.body_def_id, ObligationCauseCode::RustCall),
wfcx.param_env,
*ty,
- tcx.require_lang_item(hir::LangItem::Tuple, span),
+ tcx.require_lang_item(LangItem::Tuple, span),
);
wfcx.register_bound(
ObligationCause::new(span, wfcx.body_def_id, ObligationCauseCode::RustCall),
wfcx.param_env,
*ty,
- tcx.require_lang_item(hir::LangItem::Sized, span),
+ tcx.require_lang_item(LangItem::Sized, span),
);
} else {
tcx.dcx().span_err(
diff --git a/compiler/rustc_hir_analysis/src/coherence/builtin.rs b/compiler/rustc_hir_analysis/src/coherence/builtin.rs
index 8ba8962bc2e6e..3b57f45e684f7 100644
--- a/compiler/rustc_hir_analysis/src/coherence/builtin.rs
+++ b/compiler/rustc_hir_analysis/src/coherence/builtin.rs
@@ -7,8 +7,8 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{ErrorGuaranteed, MultiSpan};
use rustc_hir as hir;
use rustc_hir::ItemKind;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::{DefId, LocalDefId};
-use rustc_hir::lang_items::LangItem;
use rustc_infer::infer::{self, InferCtxt, RegionResolutionError, SubregionOrigin, TyCtxtInferExt};
use rustc_infer::traits::{Obligation, TraitErrors};
use rustc_middle::ty::adjustment::CoerceUnsizedInfo;
diff --git a/compiler/rustc_hir_analysis/src/coherence/builtin/coerce_shared.rs b/compiler/rustc_hir_analysis/src/coherence/builtin/coerce_shared.rs
index 596d7151dd245..bd7130ee48bc8 100644
--- a/compiler/rustc_hir_analysis/src/coherence/builtin/coerce_shared.rs
+++ b/compiler/rustc_hir_analysis/src/coherence/builtin/coerce_shared.rs
@@ -1,8 +1,8 @@
use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir;
use rustc_hir::ItemKind;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::{DefId, LocalDefId};
-use rustc_hir::lang_items::LangItem;
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
use rustc_infer::traits::{Obligation, TraitErrors};
use rustc_middle::ty::relate::solver_relating::RelateExt;
diff --git a/compiler/rustc_hir_analysis/src/coherence/mod.rs b/compiler/rustc_hir_analysis/src/coherence/mod.rs
index 8391a47902e42..894cd584ae41d 100644
--- a/compiler/rustc_hir_analysis/src/coherence/mod.rs
+++ b/compiler/rustc_hir_analysis/src/coherence/mod.rs
@@ -7,7 +7,7 @@
use rustc_errors::codes::*;
use rustc_errors::struct_span_code_err;
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::query::Providers;
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt, elaborate};
diff --git a/compiler/rustc_hir_analysis/src/coherence/unsafety.rs b/compiler/rustc_hir_analysis/src/coherence/unsafety.rs
index 8114106a2a411..7fcf8ddceea5c 100644
--- a/compiler/rustc_hir_analysis/src/coherence/unsafety.rs
+++ b/compiler/rustc_hir_analysis/src/coherence/unsafety.rs
@@ -3,7 +3,8 @@
use rustc_errors::codes::*;
use rustc_errors::struct_span_code_err;
-use rustc_hir::{LangItem, Safety};
+use rustc_hir::Safety;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_middle::ty::ImplPolarity::*;
use rustc_middle::ty::print::PrintTraitRefExt as _;
use rustc_middle::ty::{ImplTraitHeader, TraitDef, TyCtxt};
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
index 18147afff15ce..613202ef35345 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
@@ -4,6 +4,7 @@ use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_errors::codes::*;
use rustc_errors::struct_span_code_err;
use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_hir::{PolyTraitRef, find_attr};
@@ -110,13 +111,13 @@ fn collect_sizedness_bounds<'tcx>(
context: ImpliedBoundsContext<'tcx>,
span: Span,
) -> CollectedSizednessBounds {
- let sized_did = tcx.require_lang_item(hir::LangItem::Sized, span);
+ let sized_did = tcx.require_lang_item(LangItem::Sized, span);
let sized = collect_bounds(hir_bounds, context, sized_did);
- let meta_sized_did = tcx.require_lang_item(hir::LangItem::MetaSized, span);
+ let meta_sized_did = tcx.require_lang_item(LangItem::MetaSized, span);
let meta_sized = collect_bounds(hir_bounds, context, meta_sized_did);
- let pointee_sized_did = tcx.require_lang_item(hir::LangItem::PointeeSized, span);
+ let pointee_sized_did = tcx.require_lang_item(LangItem::PointeeSized, span);
let pointee_sized = collect_bounds(hir_bounds, context, pointee_sized_did);
CollectedSizednessBounds { sized, meta_sized, pointee_sized }
@@ -160,8 +161,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
return;
}
- let meta_sized_did = tcx.require_lang_item(hir::LangItem::MetaSized, span);
- let pointee_sized_did = tcx.require_lang_item(hir::LangItem::PointeeSized, span);
+ let meta_sized_did = tcx.require_lang_item(LangItem::MetaSized, span);
+ let pointee_sized_did = tcx.require_lang_item(LangItem::PointeeSized, span);
// If adding sizedness bounds to a trait, then there are some relevant early exits
match context {
@@ -200,7 +201,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
| ImpliedBoundsContext::AssociatedTypeOrImplTrait => {
// If there are no explicit sizedness bounds on a parameter then add a default
// `Sized` bound.
- let sized_did = tcx.require_lang_item(hir::LangItem::Sized, span);
+ let sized_did = tcx.require_lang_item(LangItem::Sized, span);
add_trait_bound(tcx, bounds, self_ty, sized_did, span);
}
}
@@ -225,7 +226,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
/// Doesn't add the bound if the HIR bounds contain any of `Trait`, `?Trait` or `!Trait`.
pub(crate) fn add_default_trait(
&self,
- trait_: hir::LangItem,
+ trait_: LangItem,
bounds: &mut Vec<(ty::Clause<'tcx>, Span)>,
self_ty: Ty<'tcx>,
hir_bounds: &[hir::GenericBound<'tcx>],
@@ -268,7 +269,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let tcx = self.tcx();
if let Res::Def(DefKind::Trait, def_id) = trait_ref.path.res
- && (tcx.is_lang_item(def_id, hir::LangItem::Sized) || tcx.is_default_trait(def_id))
+ && (tcx.is_lang_item(def_id, LangItem::Sized) || tcx.is_default_trait(def_id))
{
return;
}
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs
index 720dcf89523b5..3d8c23ebdf8d3 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs
@@ -5,9 +5,10 @@ use rustc_errors::{
Applicability, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, StashKey,
Suggestions, struct_span_code_err,
};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::DefId;
-use rustc_hir::{self as hir, HirId, LangItem};
+use rustc_hir::{self as hir, HirId};
use rustc_lint_defs::builtin::{BARE_TRAIT_OBJECTS, UNUSED_ASSOCIATED_TYPE_BOUNDS};
use rustc_middle::ty::elaborate::ClauseWithSupertraitSpan;
use rustc_middle::ty::{
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
index ebdedab9bb03b..c65e9bdbd211e 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
@@ -31,6 +31,7 @@ use rustc_errors::{
Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, FatalError, StashKey,
struct_span_code_err,
};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::{self as hir, AnonConst, GenericArg, GenericArgs, HirId};
@@ -53,11 +54,11 @@ use rustc_trait_selection::traits::{self, FulfillmentError};
use tracing::{debug, instrument};
use crate::check::check_abi;
-use crate::diagnostics::{self, BadReturnTypeNotation, NoFieldOnType};
+use crate::check_c_variadic_abi;
+use crate::diagnostics::{self, BadReturnTypeNotation, NoFieldOnType, NoVariantNamed};
use crate::hir_ty_lowering::errors::{GenericsArgsErrExtend, prohibit_assoc_item_constraint};
use crate::hir_ty_lowering::generics::{check_generic_arg_count, lower_generic_args};
use crate::middle::resolve_bound_vars as rbv;
-use crate::{NoVariantNamed, check_c_variadic_abi};
/// The context in which an implied bound is being added to a item being lowered (i.e. a sizedness
/// trait or a default trait)
@@ -983,7 +984,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// non-global where-clauses being preferred over item bounds (where `PointeeSized`
// bounds would be proven) -- which can result in errors when a `PointeeSized`
// supertrait / bound / predicate is added to some items.
- tcx.is_lang_item(trait_def_id, hir::LangItem::PointeeSized)
+ tcx.is_lang_item(trait_def_id, LangItem::PointeeSized)
}
hir::BoundPolarity::Negative(_) => false,
hir::BoundPolarity::Maybe(_) => {
@@ -1054,7 +1055,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// This may have performance implications, so please check perf when
// removing it.
// This was added in .
- if tcx.is_lang_item(trait_def_id, rustc_hir::LangItem::Sized) {
+ if tcx.is_lang_item(trait_def_id, LangItem::Sized) {
bounds.insert(0, bound);
} else {
bounds.push(bound);
diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs
index ebbf63b947a93..572200dbd7634 100644
--- a/compiler/rustc_hir_analysis/src/lib.rs
+++ b/compiler/rustc_hir_analysis/src/lib.rs
@@ -81,7 +81,6 @@ mod impl_wf_check;
mod outlives;
mod variance;
-pub use diagnostics::NoVariantNamed;
use rustc_abi::{CVariadicStatus, ExternAbi};
use rustc_hir as hir;
use rustc_hir::def::DefKind;
diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs
index d2430a06a0072..e250ec4c7af40 100644
--- a/compiler/rustc_hir_typeck/src/callee.rs
+++ b/compiler/rustc_hir_typeck/src/callee.rs
@@ -4,9 +4,10 @@ use rustc_abi::{CanonAbi, ExternAbi};
use rustc_ast::util::parser::ExprPrecedence;
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, StashKey, msg};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{self, CtorKind, Namespace, Res};
use rustc_hir::def_id::DefId;
-use rustc_hir::{self as hir, HirId, LangItem, find_attr};
+use rustc_hir::{self as hir, HirId, find_attr};
use rustc_hir_analysis::autoderef::Autoderef;
use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes};
use rustc_infer::traits::{Obligation, ObligationCause, ObligationCauseCode};
@@ -636,7 +637,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{
self.register_bound(
ty,
- self.tcx.require_lang_item(hir::LangItem::Tuple, sp),
+ self.tcx.require_lang_item(LangItem::Tuple, sp),
self.cause(sp, ObligationCauseCode::RustCall),
);
self.require_type_is_sized(ty, sp, ObligationCauseCode::RustCall);
diff --git a/compiler/rustc_hir_typeck/src/check.rs b/compiler/rustc_hir_typeck/src/check.rs
index 1780430567a80..60fc0b8f9b214 100644
--- a/compiler/rustc_hir_typeck/src/check.rs
+++ b/compiler/rustc_hir_typeck/src/check.rs
@@ -1,8 +1,8 @@
use std::cell::RefCell;
use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::DefKind;
-use rustc_hir::lang_items::LangItem;
use rustc_hir_analysis::check::check_function_signature;
use rustc_infer::infer::RegionVariableOrigin;
use rustc_infer::traits::WellFormedLoc;
@@ -177,7 +177,7 @@ fn check_panic_info_fn(tcx: TyCtxt<'_>, fn_id: LocalDefId, fn_sig: ty::FnSig<'_>
tcx.dcx().span_err(span, "should have no const parameters");
}
- let panic_info_did = tcx.require_lang_item(hir::LangItem::PanicInfo, span);
+ let panic_info_did = tcx.require_lang_item(LangItem::PanicInfo, span);
// build type `for<'a, 'b> fn(&'a PanicInfo<'b>) -> !`
let panic_info_ty = tcx
diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs
index a8c32f19c6a13..a9ce46b68527f 100644
--- a/compiler/rustc_hir_typeck/src/closure.rs
+++ b/compiler/rustc_hir_typeck/src/closure.rs
@@ -6,7 +6,7 @@ use std::ops::ControlFlow;
use rustc_abi::ExternAbi;
use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir;
-use rustc_hir::lang_items::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferOk, InferResult};
use rustc_infer::traits::{ObligationCauseCode, PredicateObligations};
@@ -136,12 +136,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Ty::new_adt(
tcx,
- tcx.adt_def(tcx.require_lang_item(hir::LangItem::Poll, expr_span)),
+ tcx.adt_def(tcx.require_lang_item(LangItem::Poll, expr_span)),
tcx.mk_args(&[Ty::new_adt(
tcx,
- tcx.adt_def(
- tcx.require_lang_item(hir::LangItem::Option, expr_span),
- ),
+ tcx.adt_def(tcx.require_lang_item(LangItem::Option, expr_span)),
tcx.mk_args(&[yield_ty.into()]),
)
.into()]),
diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs
index f0f61edaa8c94..6aa88ee627e83 100644
--- a/compiler/rustc_hir_typeck/src/coercion.rs
+++ b/compiler/rustc_hir_typeck/src/coercion.rs
@@ -39,9 +39,10 @@ use std::ops::{ControlFlow, Deref};
use rustc_errors::codes::*;
use rustc_errors::{Applicability, Diag, struct_span_code_err};
+use rustc_hir as hir;
use rustc_hir::attrs::InlineAttr;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::{DefId, LocalDefId};
-use rustc_hir::{self as hir, LangItem};
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
use rustc_infer::infer::relate::RelateResult;
use rustc_infer::infer::{DefineOpaqueTypes, InferOk, InferResult, RegionVariableOrigin};
@@ -832,7 +833,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
) -> PredicateObligation<'tcx> {
let pred = ty::TraitRef::new(
self.tcx,
- self.tcx.require_lang_item(hir::LangItem::Unpin, self.cause.span),
+ self.tcx.require_lang_item(LangItem::Unpin, self.cause.span),
[ty],
);
let cause = self.cause(self.cause.span, ObligationCauseCode::Coercion { source, target });
@@ -2103,7 +2104,7 @@ impl<'tcx> CoerceMany<'tcx> {
fcx.param_env,
ty::TraitRef::new(
fcx.tcx,
- fcx.tcx.require_lang_item(hir::LangItem::Sized, DUMMY_SP),
+ fcx.tcx.require_lang_item(LangItem::Sized, DUMMY_SP),
[sig.output()],
),
))
diff --git a/compiler/rustc_hir_typeck/src/diagnostics.rs b/compiler/rustc_hir_typeck/src/diagnostics.rs
index 1a6df92957d00..722dfb0794ec1 100644
--- a/compiler/rustc_hir_typeck/src/diagnostics.rs
+++ b/compiler/rustc_hir_typeck/src/diagnostics.rs
@@ -1327,3 +1327,21 @@ pub(crate) struct FloatLiteralF32Fallback {
)]
pub span: Option,
}
+
+#[derive(Subdiagnostic)]
+#[multipart_suggestion(
+ "parentheses are required to parse this as an expression",
+ applicability = "machine-applicable"
+)]
+pub(crate) struct ExprParenthesesNeeded {
+ #[suggestion_part(code = "(")]
+ left: Span,
+ #[suggestion_part(code = ")")]
+ right: Span,
+}
+
+impl ExprParenthesesNeeded {
+ pub(crate) fn surrounding(s: Span) -> Self {
+ ExprParenthesesNeeded { left: s.shrink_to_lo(), right: s.shrink_to_hi() }
+ }
+}
diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs
index bfdd99b6277ba..37b8b194ed9ac 100644
--- a/compiler/rustc_hir_typeck/src/expr.rs
+++ b/compiler/rustc_hir_typeck/src/expr.rs
@@ -18,12 +18,11 @@ use rustc_errors::{
struct_span_code_err,
};
use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{CtorKind, DefKind, Res};
use rustc_hir::def_id::DefId;
-use rustc_hir::lang_items::LangItem;
use rustc_hir::{ExprKind, HirId, QPath, find_attr, is_range_literal};
-use rustc_hir_analysis::NoVariantNamed;
-use rustc_hir_analysis::diagnostics::NoFieldOnType;
+use rustc_hir_analysis::diagnostics::{NoFieldOnType, NoVariantNamed};
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer as _;
use rustc_infer::infer::{self, DefineOpaqueTypes, InferOk, RegionVariableOrigin};
use rustc_infer::traits::query::NoSolution;
@@ -31,7 +30,7 @@ use rustc_middle::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase};
use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::{self, AdtKind, GenericArgsRef, Ty, TypeVisitableExt, Unnormalized};
use rustc_middle::{bug, span_bug};
-use rustc_session::diagnostics::{ExprParenthesesNeeded, feature_err};
+use rustc_session::diagnostics::feature_err;
use rustc_span::edit_distance::find_best_match_for_name;
use rustc_span::hygiene::DesugaringKind;
use rustc_span::{Ident, Span, Spanned, Symbol, kw, sym};
@@ -44,10 +43,10 @@ use crate::callee::SplatLoweringInfo;
use crate::coercion::CoerceMany;
use crate::diagnostics::{
AddressOfTemporaryTaken, BaseExpressionDoubleDot, BaseExpressionDoubleDotAddExpr,
- BaseExpressionDoubleDotRemove, CantDereference, FieldMultiplySpecifiedInInitializer,
- FunctionalRecordUpdateOnNonStruct, HelpUseLatestEdition, NakedAsmOutsideNakedFn,
- NoFieldOnVariant, ReturnLikeStatementKind, ReturnStmtOutsideOfFnBody, StructExprNonExhaustive,
- TypeMismatchFruTypo, YieldExprOutsideOfCoroutine,
+ BaseExpressionDoubleDotRemove, CantDereference, ExprParenthesesNeeded,
+ FieldMultiplySpecifiedInInitializer, FunctionalRecordUpdateOnNonStruct, HelpUseLatestEdition,
+ NakedAsmOutsideNakedFn, NoFieldOnVariant, ReturnLikeStatementKind, ReturnStmtOutsideOfFnBody,
+ StructExprNonExhaustive, TypeMismatchFruTypo, YieldExprOutsideOfCoroutine,
};
use crate::op::contains_let_in_chain;
use crate::{
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
index 5faa3dfa494cb..8ff4c3bf28c34 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
@@ -7,10 +7,10 @@ use rustc_data_structures::thin_vec::ThinVec;
use rustc_errors::{
Applicability, Diag, DiagCtxtHandle, Diagnostic, ErrorGuaranteed, Level, MultiSpan,
};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{CtorOf, DefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::VisitorExt;
-use rustc_hir::lang_items::LangItem;
use rustc_hir::{self as hir, AmbigArg, ExprKind, GenericArg, HirId, Node, QPath, intravisit};
use rustc_hir_analysis::hir_ty_lowering::errors::GenericsArgsErrExtend;
use rustc_hir_analysis::hir_ty_lowering::generics::{
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
index b9262e40f6f31..46001b8b6d15d 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
@@ -9,10 +9,11 @@ use rustc_errors::codes::*;
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan, a_or_an, listify, pluralize};
use rustc_hir as hir;
use rustc_hir::attrs::DivergingBlockBehavior;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::Visitor;
-use rustc_hir::{Expr, ExprKind, FnRetTy, HirId, LangItem, Node, QPath, is_range_literal};
+use rustc_hir::{Expr, ExprKind, FnRetTy, HirId, Node, QPath, is_range_literal};
use rustc_hir_analysis::check::potentially_plural_count;
use rustc_hir_analysis::hir_ty_lowering::{HirTyLowerer, ResolvedStructPath};
use rustc_index::IndexVec;
@@ -23,7 +24,6 @@ use rustc_middle::ty::print::with_forced_trimmed_paths;
use rustc_middle::ty::{self, IsSuggestable, Ty, TyCtxt, TypeVisitableExt, Unnormalized};
use rustc_middle::{bug, span_bug};
use rustc_session::Session;
-use rustc_session::diagnostics::ExprParenthesesNeeded;
use rustc_span::{DUMMY_SP, Ident, Span, kw, sym};
use rustc_trait_selection::error_reporting::infer::{FailureCode, ObligationCauseExt};
use rustc_trait_selection::infer::InferCtxtExt;
@@ -35,7 +35,7 @@ use crate::Expectation::*;
use crate::TupleArgumentsFlag::*;
use crate::callee::SplatLoweringInfo;
use crate::coercion::CoerceMany;
-use crate::diagnostics::SuggestPtrNullMut;
+use crate::diagnostics::{ExprParenthesesNeeded, SuggestPtrNullMut};
use crate::fn_ctxt::arg_matrix::{ArgMatrix, Compatibility, Error, ExpectedIdx, ProvidedIdx};
use crate::gather_locals::Declaration;
use crate::inline_asm::InlineAsmCtxt;
@@ -1033,7 +1033,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ast::LitKind::CStr(_, _) => Ty::new_imm_ref(
tcx,
tcx.lifetimes.re_static,
- tcx.type_of(tcx.require_lang_item(hir::LangItem::CStr, lit.span)).skip_binder(),
+ tcx.type_of(tcx.require_lang_item(LangItem::CStr, lit.span)).skip_binder(),
),
ast::LitKind::Err(guar) => Ty::new_error(tcx, guar),
}
@@ -2359,10 +2359,10 @@ impl<'a, 'tcx> FnCallDiagCtxt<'a, 'tcx> {
fn detect_dotdot(&self, err: &mut Diag<'_>, ty: Ty<'tcx>, expr: &hir::Expr<'tcx>) {
if let ty::Adt(adt, _) = ty.kind()
- && self.tcx().is_lang_item(adt.did(), hir::LangItem::RangeFull)
+ && self.tcx().is_lang_item(adt.did(), LangItem::RangeFull)
&& is_range_literal(expr)
&& let hir::ExprKind::Struct(&path, [], _) = expr.kind
- && self.tcx().qpath_is_lang_item(path, hir::LangItem::RangeFull)
+ && self.tcx().qpath_is_lang_item(path, LangItem::RangeFull)
{
// We have `Foo(a, .., c)`, where the user might be trying to use the "rest" syntax
// from default field values, which is not supported on tuples.
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
index a09da3cec2f92..506e2822a8745 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
@@ -7,9 +7,9 @@ use itertools::Itertools;
use rustc_ast::util::parser::ExprPrecedence;
use rustc_data_structures::packed::Pu128;
use rustc_errors::{Applicability, Diag, MultiSpan, listify, msg};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
use rustc_hir::intravisit::Visitor;
-use rustc_hir::lang_items::LangItem;
use rustc_hir::{
self as hir, Arm, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, ExprKind,
GenericBound, HirId, LoopSource, Node, PatExpr, PatExprKind, Path, QPath, Stmt, StmtKind,
@@ -24,7 +24,6 @@ use rustc_middle::ty::{
self, Article, Binder, IsSuggestable, Ty, TyCtxt, TypeVisitableExt, Unnormalized, Upcast,
suggest_constraining_type_params,
};
-use rustc_session::diagnostics::ExprParenthesesNeeded;
use rustc_span::{ExpnKind, Ident, MacroKind, Span, Spanned, Symbol, sym};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::error_reporting::traits::DefIdOrName;
@@ -35,7 +34,7 @@ use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _
use tracing::{debug, instrument};
use super::FnCtxt;
-use crate::diagnostics::{self, SuggestBoxingForReturnImplTrait};
+use crate::diagnostics::{self, ExprParenthesesNeeded, SuggestBoxingForReturnImplTrait};
use crate::fn_ctxt::rustc_span::BytePos;
use crate::method::probe;
use crate::method::probe::{IsSuggestion, Mode, ProbeScope};
diff --git a/compiler/rustc_hir_typeck/src/inline_asm.rs b/compiler/rustc_hir_typeck/src/inline_asm.rs
index b720a75303c47..cfe64fce180e9 100644
--- a/compiler/rustc_hir_typeck/src/inline_asm.rs
+++ b/compiler/rustc_hir_typeck/src/inline_asm.rs
@@ -2,8 +2,9 @@ use rustc_abi::FieldIdx;
use rustc_ast::InlineAsmTemplatePiece;
use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level};
+use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::DefId;
-use rustc_hir::{self as hir, LangItem};
use rustc_middle::bug;
use rustc_middle::ty::{
self, Article, FloatTy, IntTy, Ty, TyCtxt, TypeVisitableExt, UintTy, Unnormalized,
diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs
index 05463cd9ae3f7..e31692492c263 100644
--- a/compiler/rustc_hir_typeck/src/method/confirm.rs
+++ b/compiler/rustc_hir_typeck/src/method/confirm.rs
@@ -3,6 +3,7 @@ use std::ops::Deref;
use rustc_hir as hir;
use rustc_hir::GenericArg;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::DefId;
use rustc_hir_analysis::hir_ty_lowering::generics::{
check_generic_arg_count_for_value_path, lower_generic_args,
@@ -257,7 +258,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
let region = self.next_region_var(RegionVariableOrigin::Autoref(self.span));
target = match target.kind() {
- ty::Adt(pin, args) if self.tcx.is_lang_item(pin.did(), hir::LangItem::Pin) => {
+ ty::Adt(pin, args) if self.tcx.is_lang_item(pin.did(), LangItem::Pin) => {
let inner_ty = match args[0].expect_ty().kind() {
ty::Ref(_, ty, _) => *ty,
_ => bug!("Expected a reference type for argument to Pin"),
diff --git a/compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs b/compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs
index 515a72f5041cb..87a64e4227b1d 100644
--- a/compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs
+++ b/compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs
@@ -5,6 +5,7 @@ use hir::{HirId, ItemKind};
use rustc_ast::join_path_idents;
use rustc_errors::{Applicability, Diag, DiagCtxtHandle, Diagnostic, Level};
use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_lint::{ARRAY_INTO_ITER, BOXED_SLICE_INTO_ITER};
use rustc_middle::span_bug;
use rustc_middle::ty::{self, Ty, TyCtxt};
@@ -176,7 +177,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// We check that the self type is `Pin<&mut _>` to avoid false positives for this common name.
if !span.at_least_rust_2024()
&& let ty::Adt(adt_def, args) = self_ty.kind()
- && self.tcx.is_lang_item(adt_def.did(), hir::LangItem::Pin)
+ && self.tcx.is_lang_item(adt_def.did(), LangItem::Pin)
&& let ty::Ref(_, _, ty::Mutability::Mut) =
args[0].as_type().unwrap().kind() =>
{
diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs
index 68f85d942ce2e..b2e0a3bd7a195 100644
--- a/compiler/rustc_hir_typeck/src/method/probe.rs
+++ b/compiler/rustc_hir_typeck/src/method/probe.rs
@@ -6,6 +6,7 @@ use std::ops::Deref;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sso::SsoHashSet;
use rustc_errors::{Applicability, Diag, DiagCtxtHandle, Diagnostic, Level};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::DefKind;
use rustc_hir::{self as hir, ExprKind, HirId, Node, find_attr};
use rustc_hir_analysis::autoderef::{self, Autoderef};
@@ -1580,7 +1581,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
ty::Adt(def, args)
if self.tcx.features().pin_ergonomics()
- && self.tcx.is_lang_item(def.did(), hir::LangItem::Pin) =>
+ && self.tcx.is_lang_item(def.did(), LangItem::Pin) =>
{
// make sure this is a pinned reference (and not a `Pin` or something)
if let ty::Ref(_, _, mutbl) = args[0].expect_ty().kind() {
@@ -1649,7 +1650,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
// make sure self is a Pin<&mut T>
let inner_ty = match self_ty.kind() {
- ty::Adt(def, args) if self.tcx.is_lang_item(def.did(), hir::LangItem::Pin) => {
+ ty::Adt(def, args) if self.tcx.is_lang_item(def.did(), LangItem::Pin) => {
match args[0].expect_ty().kind() {
ty::Ref(_, ty, hir::Mutability::Mut) => *ty,
_ => {
diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs
index f4c084022a845..a22b6f746a952 100644
--- a/compiler/rustc_hir_typeck/src/method/suggest.rs
+++ b/compiler/rustc_hir_typeck/src/method/suggest.rs
@@ -17,10 +17,10 @@ use rustc_errors::{
Applicability, Diag, MultiSpan, StashKey, StringPart, listify, pluralize, struct_span_code_err,
};
use rustc_hir::attrs::diagnostic::CustomDiagnostic;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{CtorKind, DefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::{self, Visitor};
-use rustc_hir::lang_items::LangItem;
use rustc_hir::{
self as hir, ExprKind, HirId, Node, PathSegment, QPath, find_attr, is_range_literal,
};
@@ -3812,8 +3812,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
return;
};
let is_inclusive = match lang_item {
- hir::LangItem::RangeTo => false,
- hir::LangItem::RangeToInclusive | hir::LangItem::RangeInclusiveCopy => true,
+ LangItem::RangeTo => false,
+ LangItem::RangeToInclusive | LangItem::RangeInclusiveCopy => true,
_ => return,
};
diff --git a/compiler/rustc_hir_typeck/src/op.rs b/compiler/rustc_hir_typeck/src/op.rs
index 99833a5f81cb9..c28976555432b 100644
--- a/compiler/rustc_hir_typeck/src/op.rs
+++ b/compiler/rustc_hir_typeck/src/op.rs
@@ -14,7 +14,6 @@ use rustc_middle::ty::adjustment::{
};
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{self, IsSuggestable, Ty, TyCtxt, TypeVisitableExt};
-use rustc_session::diagnostics::ExprParenthesesNeeded;
use rustc_span::{Span, Spanned, Symbol, sym};
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{FulfillmentError, Obligation, ObligationCtxt};
@@ -22,6 +21,7 @@ use tracing::debug;
use super::FnCtxt;
use super::method::MethodCallee;
+use crate::diagnostics::ExprParenthesesNeeded;
use crate::method::TreatNotYetDefinedOpaques;
use crate::{Expectation, diagnostics};
diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs
index 01c48c0ae790c..f7ba6a78c65bd 100644
--- a/compiler/rustc_hir_typeck/src/pat.rs
+++ b/compiler/rustc_hir_typeck/src/pat.rs
@@ -9,12 +9,13 @@ use rustc_errors::{
Applicability, Diag, DiagCtxtHandle, Diagnostic, ErrorGuaranteed, Level, MultiSpan, pluralize,
struct_span_code_err,
};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{CtorKind, DefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_hir::pat_util::EnumerateAndAdjustIterator;
use rustc_hir::{
- self as hir, BindingMode, ByRef, ExprKind, HirId, LangItem, Mutability, Pat, PatExpr,
- PatExprKind, PatKind, expr_needs_parens,
+ self as hir, BindingMode, ByRef, ExprKind, HirId, Mutability, Pat, PatExpr, PatExprKind,
+ PatKind, expr_needs_parens,
};
use rustc_hir_analysis::autoderef::report_autoderef_recursion_limit_error;
use rustc_infer::infer::RegionVariableOrigin;
@@ -1212,7 +1213,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{
self.register_bound(
expected,
- self.tcx.require_lang_item(hir::LangItem::Unpin, pat.span),
+ self.tcx.require_lang_item(LangItem::Unpin, pat.span),
self.misc(pat.span),
)
}
@@ -2752,14 +2753,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let tcx = self.tcx;
self.register_bound(
source_ty,
- tcx.require_lang_item(hir::LangItem::DerefPure, span),
+ tcx.require_lang_item(LangItem::DerefPure, span),
self.misc(span),
);
// The expected type for the deref pat's inner pattern is `::Target`.
let target_ty = Ty::new_projection(
tcx,
ty::IsRigid::No,
- tcx.require_lang_item(hir::LangItem::DerefTarget, span),
+ tcx.require_lang_item(LangItem::DerefTarget, span),
[source_ty],
);
let target_ty = self.normalize(span, Unnormalized::new_wip(target_ty));
@@ -2780,7 +2781,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
for mutably_derefed_ty in derefed_tys {
self.register_bound(
mutably_derefed_ty,
- self.tcx.require_lang_item(hir::LangItem::DerefMut, span),
+ self.tcx.require_lang_item(LangItem::DerefMut, span),
self.misc(span),
);
}
diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs
index d75d346e712e0..91771fb37d18a 100644
--- a/compiler/rustc_hir_typeck/src/upvar.rs
+++ b/compiler/rustc_hir_typeck/src/upvar.rs
@@ -36,6 +36,7 @@ use rustc_abi::FIRST_VARIANT;
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_data_structures::unord::{ExtendUnord, UnordSet};
use rustc_errors::{Applicability, Diag, DiagCtxtHandle, Diagnostic, Level, MultiSpan};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::LocalDefId;
use rustc_hir::intravisit::{self, Visitor};
use rustc_hir::{self as hir, HirId, find_attr};
@@ -1637,7 +1638,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
};
let is_drop_defined_for_ty = |ty: Ty<'tcx>| {
- let drop_trait = self.tcx.require_lang_item(hir::LangItem::Drop, closure_span);
+ let drop_trait = self.tcx.require_lang_item(LangItem::Drop, closure_span);
self.infcx
.type_implements_trait(drop_trait, [ty], self.tcx.param_env(closure_def_id))
.must_apply_modulo_regions()
diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs
index 35b0785c7847d..627fb962d5dbf 100644
--- a/compiler/rustc_lint/src/builtin.rs
+++ b/compiler/rustc_lint/src/builtin.rs
@@ -24,6 +24,7 @@ use rustc_ast_pretty::pprust::expr_to_string;
use rustc_attr_parsing::AttributeParser;
use rustc_errors::{Applicability, Diagnostic, msg};
use rustc_feature::GateIssue;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::attrs::{AttributeKind, DocAttribute};
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LocalDefId};
@@ -555,8 +556,7 @@ fn type_implements_negative_copy_modulo_regions<'tcx>(
typing_env: ty::TypingEnv<'tcx>,
) -> bool {
let (infcx, param_env) = tcx.infer_ctxt().build_with_typing_env(typing_env);
- let trait_ref =
- ty::TraitRef::new(tcx, tcx.require_lang_item(hir::LangItem::Copy, DUMMY_SP), [ty]);
+ let trait_ref = ty::TraitRef::new(tcx, tcx.require_lang_item(LangItem::Copy, DUMMY_SP), [ty]);
let pred = ty::TraitPredicate { trait_ref, polarity: ty::PredicatePolarity::Negative };
let obligation = traits::Obligation {
cause: traits::ObligationCause::dummy(),
diff --git a/compiler/rustc_lint/src/c_void_returns.rs b/compiler/rustc_lint/src/c_void_returns.rs
index b9d9e9ef54c4d..c3c15c60cadbf 100644
--- a/compiler/rustc_lint/src/c_void_returns.rs
+++ b/compiler/rustc_lint/src/c_void_returns.rs
@@ -1,8 +1,9 @@
use rustc_abi::ExternAbi;
+use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::Res;
use rustc_hir::def_id::LocalDefId;
use rustc_hir::intravisit::FnKind;
-use rustc_hir::{self as hir, LangItem};
use rustc_session::{declare_lint, declare_lint_pass};
use rustc_span::Span;
diff --git a/compiler/rustc_lint/src/dangling.rs b/compiler/rustc_lint/src/dangling.rs
index 54356422a11ad..de061ceb6fd8d 100644
--- a/compiler/rustc_lint/src/dangling.rs
+++ b/compiler/rustc_lint/src/dangling.rs
@@ -1,8 +1,9 @@
use rustc_ast::visit::{visit_opt, walk_list};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::Res;
use rustc_hir::def_id::LocalDefId;
use rustc_hir::intravisit::{FnKind, Visitor, walk_expr};
-use rustc_hir::{Block, Body, Expr, ExprKind, FnDecl, FnRetTy, LangItem, TyKind, find_attr};
+use rustc_hir::{Block, Body, Expr, ExprKind, FnDecl, FnRetTy, TyKind, find_attr};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_session::{declare_lint, impl_lint_pass};
use rustc_span::{Span, sym};
diff --git a/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs b/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs
index caaf115c9133a..5fb4f5278938f 100644
--- a/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs
+++ b/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs
@@ -1,4 +1,5 @@
-use rustc_hir::{self as hir, LangItem};
+use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_middle::ty;
use rustc_session::{declare_lint, declare_lint_pass};
use rustc_span::{Ident, sym};
diff --git a/compiler/rustc_lint/src/for_loops_over_fallibles.rs b/compiler/rustc_lint/src/for_loops_over_fallibles.rs
index 24f6be087fefa..9da3861adb943 100644
--- a/compiler/rustc_lint/src/for_loops_over_fallibles.rs
+++ b/compiler/rustc_lint/src/for_loops_over_fallibles.rs
@@ -1,5 +1,6 @@
use hir::{Expr, Pat};
-use rustc_hir::{self as hir, LangItem};
+use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_infer::infer::TyCtxtInferExt;
use rustc_infer::traits::ObligationCause;
use rustc_middle::ty;
diff --git a/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs b/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs
index 766365134a3f4..5999bce2fe435 100644
--- a/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs
+++ b/compiler/rustc_lint/src/multiple_supertrait_upcastable.rs
@@ -1,4 +1,5 @@
use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_middle::ty::Unnormalized;
use rustc_session::{declare_lint, declare_lint_pass};
@@ -49,7 +50,7 @@ impl<'tcx> LateLintPass<'tcx> for MultipleSupertraitUpcastable {
.iter_identity_copied()
.map(Unnormalized::skip_norm_wip)
.filter_map(|(clause, _)| clause.as_trait_clause())
- .filter(|pred| !cx.tcx.is_lang_item(pred.def_id(), hir::LangItem::MetaSized))
+ .filter(|pred| !cx.tcx.is_lang_item(pred.def_id(), LangItem::MetaSized))
.filter(|pred| !cx.tcx.is_default_trait(pred.def_id()));
if direct_super_traits_iter.count() > 1 {
cx.emit_span_lint(
diff --git a/compiler/rustc_lint/src/non_fmt_panic.rs b/compiler/rustc_lint/src/non_fmt_panic.rs
index 055d2c1702406..8722bcd570682 100644
--- a/compiler/rustc_lint/src/non_fmt_panic.rs
+++ b/compiler/rustc_lint/src/non_fmt_panic.rs
@@ -1,7 +1,8 @@
use rustc_ast as ast;
use rustc_errors::{Applicability, Diag, DiagCtxtHandle, Diagnostic, Level, msg};
+use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::DefId;
-use rustc_hir::{self as hir, LangItem};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::{bug, ty};
use rustc_parse_format::{ParseMode, Parser, Piece};
diff --git a/compiler/rustc_lint/src/shadowed_into_iter.rs b/compiler/rustc_lint/src/shadowed_into_iter.rs
index c03e7396fd2b7..4732fda76b33a 100644
--- a/compiler/rustc_lint/src/shadowed_into_iter.rs
+++ b/compiler/rustc_lint/src/shadowed_into_iter.rs
@@ -1,4 +1,5 @@
-use rustc_hir::{self as hir, LangItem};
+use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_middle::ty::{self, Ty};
use rustc_session::lint::fcw;
use rustc_session::{declare_lint, impl_lint_pass};
diff --git a/compiler/rustc_lint/src/traits.rs b/compiler/rustc_lint/src/traits.rs
index 9ffc3246a5f38..4b68de5cc69f3 100644
--- a/compiler/rustc_lint/src/traits.rs
+++ b/compiler/rustc_lint/src/traits.rs
@@ -1,4 +1,5 @@
-use rustc_hir::{self as hir, AmbigArg, LangItem};
+use rustc_hir::attrs::lang_items::LangItem;
+use rustc_hir::{self as hir, AmbigArg};
use rustc_session::{declare_lint, declare_lint_pass};
use rustc_span::sym;
diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs
index 44167af19f1e7..49a14c2676c10 100644
--- a/compiler/rustc_lint/src/types.rs
+++ b/compiler/rustc_lint/src/types.rs
@@ -3,7 +3,8 @@ use std::iter;
use rustc_abi::{BackendRepr, TagEncoding, Variants, WrappingRange};
use rustc_ast as ast;
use rustc_hir as hir;
-use rustc_hir::{Expr, ExprKind, HirId, LangItem, find_attr};
+use rustc_hir::attrs::lang_items::LangItem;
+use rustc_hir::{Expr, ExprKind, HirId, find_attr};
use rustc_middle::bug;
use rustc_middle::ty::layout::{LayoutOf, SizeSkeleton};
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, Unnormalized};
diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs
index 7dea17ac55140..0236ac75c2d64 100644
--- a/compiler/rustc_lint/src/unused.rs
+++ b/compiler/rustc_lint/src/unused.rs
@@ -2,7 +2,7 @@ use rustc_ast::util::{classify, parser};
use rustc_ast::{self as ast, ExprKind, FnRetTy, ForLoop, HasAttrs as _, StmtKind};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::MultiSpan;
-use rustc_hir::{self as hir};
+use rustc_hir as hir;
use rustc_middle::ty::{self, adjustment};
use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass};
use rustc_span::edition::Edition::Edition2015;
diff --git a/compiler/rustc_lint/src/unused/must_use.rs b/compiler/rustc_lint/src/unused/must_use.rs
index 3f10b521883ef..dcbffa394a1a0 100644
--- a/compiler/rustc_lint/src/unused/must_use.rs
+++ b/compiler/rustc_lint/src/unused/must_use.rs
@@ -1,9 +1,10 @@
use std::iter;
use rustc_errors::pluralize;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::DefId;
-use rustc_hir::{self as hir, LangItem, find_attr};
+use rustc_hir::{self as hir, find_attr};
use rustc_infer::traits::util::elaborate;
use rustc_middle::ty::{self, Ty, Unnormalized};
use rustc_session::{declare_lint, declare_lint_pass};
diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs
index 09d6290fcd2fc..3a7cffb5989fc 100644
--- a/compiler/rustc_metadata/src/rmeta/decoder.rs
+++ b/compiler/rustc_metadata/src/rmeta/decoder.rs
@@ -17,10 +17,10 @@ use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, DeriveProcMacro};
use rustc_hir::Safety;
use rustc_hir::attrs::CanonicalSymbols;
+use rustc_hir::attrs::diagnostic_items::DiagnosticItems;
use rustc_hir::def::Res;
use rustc_hir::def_id::{CRATE_DEF_INDEX, LOCAL_CRATE};
use rustc_hir::definitions::{DefPath, DefPathData};
-use rustc_hir::diagnostic_items::DiagnosticItems;
use rustc_index::Idx;
use rustc_middle::middle::lib_features::LibFeatures;
use rustc_middle::mir::interpret::{AllocDecodingSession, AllocDecodingState};
diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs
index f4180af492345..3273013466245 100644
--- a/compiler/rustc_metadata/src/rmeta/mod.rs
+++ b/compiler/rustc_metadata/src/rmeta/mod.rs
@@ -13,10 +13,10 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::svh::Svh;
use rustc_hir as hir;
use rustc_hir::attrs::StrippedCfgItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{CtorKind, DefKind, DocLinkResMap, MacroKinds};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIndex, DefPathHash, StableCrateId};
use rustc_hir::definitions::DefKey;
-use rustc_hir::lang_items::LangItem;
use rustc_hir::{PreciseCapturingArgKind, attrs};
use rustc_index::IndexVec;
use rustc_index::bit_set::DenseBitSet;
diff --git a/compiler/rustc_metadata/src/rmeta/parameterized.rs b/compiler/rustc_metadata/src/rmeta/parameterized.rs
index 25cb620ee1d80..75b86f8dda274 100644
--- a/compiler/rustc_metadata/src/rmeta/parameterized.rs
+++ b/compiler/rustc_metadata/src/rmeta/parameterized.rs
@@ -91,7 +91,6 @@ trivially_parameterized_over_tcx! {
rustc_hir::CoroutineKind,
rustc_hir::DefaultBodyStability,
rustc_hir::Defaultness,
- rustc_hir::LangItem,
rustc_hir::OpaqueTyOrigin,
rustc_hir::PreciseCapturingArgKind,
rustc_hir::Safety,
@@ -100,6 +99,7 @@ trivially_parameterized_over_tcx! {
rustc_hir::attrs::EiiDecl,
rustc_hir::attrs::EiiImpl,
rustc_hir::attrs::StrippedCfgItem,
+ rustc_hir::attrs::lang_items::LangItem,
rustc_hir::def::DefKind,
rustc_hir::def::DocLinkResMap,
rustc_hir::def_id::DefId,
diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs
index 13bda2991fa92..5099859218187 100644
--- a/compiler/rustc_middle/src/hir/mod.rs
+++ b/compiler/rustc_middle/src/hir/mod.rs
@@ -11,6 +11,7 @@ use rustc_data_structures::sorted_map::SortedMap;
use rustc_data_structures::stable_hash::{StableHash, StableHasher};
use rustc_data_structures::steal::Steal;
use rustc_data_structures::sync::{DynSend, DynSync, try_par_for_each_in};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{DefId, LocalDefId, LocalDefIdMap, LocalModId};
use rustc_hir::lints::DelayedLints;
diff --git a/compiler/rustc_middle/src/middle/lang_items.rs b/compiler/rustc_middle/src/middle/lang_items.rs
index b6db67342a072..829df12ff543c 100644
--- a/compiler/rustc_middle/src/middle/lang_items.rs
+++ b/compiler/rustc_middle/src/middle/lang_items.rs
@@ -7,7 +7,7 @@
//! * Traits that represent operators; e.g., `Add`, `Sub`, `Index`.
//! * Functions called by the compiler itself.
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::DefId;
use rustc_span::Span;
use rustc_target::spec::PanicStrategy;
diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs
index b005cf0c8d10f..4e2d16625266c 100644
--- a/compiler/rustc_middle/src/mir/syntax.rs
+++ b/compiler/rustc_middle/src/mir/syntax.rs
@@ -1684,12 +1684,14 @@ pub enum BinOp {
/// The `<=>` operator (three-way comparison, like `Ord::cmp`)
///
/// This is supported only on the integer types and `char`, always returning
- /// [`rustc_hir::LangItem::OrderingEnum`] (aka [`std::cmp::Ordering`]).
+ /// [`LangItem::OrderingEnum`] (aka [`std::cmp::Ordering`]).
///
/// [`Rvalue::BinaryOp`]`(BinOp::Cmp, A, B)` returns
/// - `Ordering::Less` (`-1_i8`, as a Scalar) if `A < B`
/// - `Ordering::Equal` (`0_i8`, as a Scalar) if `A == B`
/// - `Ordering::Greater` (`+1_i8`, as a Scalar) if `A > B`
+ ///
+ /// [`LangItem::OrderingEnum`]: rustc_hir::attrs::lang_items::LangItem
Cmp,
/// The `ptr.offset` operator
Offset,
diff --git a/compiler/rustc_middle/src/mir/terminator.rs b/compiler/rustc_middle/src/mir/terminator.rs
index ed86b192f6dcc..2f800c38cd4ac 100644
--- a/compiler/rustc_middle/src/mir/terminator.rs
+++ b/compiler/rustc_middle/src/mir/terminator.rs
@@ -4,8 +4,8 @@ use std::slice;
use rustc_ast::InlineAsmOptions;
use rustc_data_structures::packed::Pu128;
-use rustc_hir::LangItem;
use rustc_hir::attrs::AttributeKind;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_macros::{StableHash, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
use smallvec::{SmallVec, smallvec};
use thin_vec::ThinVec;
diff --git a/compiler/rustc_middle/src/queries.rs b/compiler/rustc_middle/src/queries.rs
index f90274460e379..ca1cd2f45975f 100644
--- a/compiler/rustc_middle/src/queries.rs
+++ b/compiler/rustc_middle/src/queries.rs
@@ -60,10 +60,10 @@ use rustc_data_structures::svh::Svh;
use rustc_data_structures::unord::{UnordMap, UnordSet};
use rustc_errors::{ErrorGuaranteed, catch_fatal_errors};
use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::{LangItem, LanguageItems};
use rustc_hir::attrs::{CanonicalSymbols, EiiDecl, EiiImpl, StrippedCfgItem};
use rustc_hir::def::{DefKind, DocLinkResMap};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdSet, LocalModId};
-use rustc_hir::lang_items::{LangItem, LanguageItems};
use rustc_hir::{ItemLocalId, PreciseCapturingArgKind};
use rustc_index::IndexVec;
use rustc_lint_defs::LintId;
@@ -2274,7 +2274,7 @@ rustc_queries! {
}
/// Returns all diagnostic items defined in all crates.
- query all_diagnostic_items(_: ()) -> &'tcx rustc_hir::diagnostic_items::DiagnosticItems {
+ query all_diagnostic_items(_: ()) -> &'tcx rustc_hir::attrs::diagnostic_items::DiagnosticItems {
arena_cache
eval_always
desc { "calculating the diagnostic items map" }
@@ -2294,7 +2294,7 @@ rustc_queries! {
}
/// Returns the diagnostic items defined in a crate.
- query diagnostic_items(_: CrateNum) -> &'tcx rustc_hir::diagnostic_items::DiagnosticItems {
+ query diagnostic_items(_: CrateNum) -> &'tcx rustc_hir::attrs::diagnostic_items::DiagnosticItems {
arena_cache
desc { "calculating the diagnostic items map in a crate" }
separate_provide_extern
diff --git a/compiler/rustc_middle/src/ty/adjustment.rs b/compiler/rustc_middle/src/ty/adjustment.rs
index 7174427e517dd..00efbe912b883 100644
--- a/compiler/rustc_middle/src/ty/adjustment.rs
+++ b/compiler/rustc_middle/src/ty/adjustment.rs
@@ -1,7 +1,7 @@
use rustc_abi::FieldIdx;
use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::DefId;
-use rustc_hir::lang_items::LangItem;
use rustc_macros::{StableHash, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
use rustc_span::Span;
diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs
index e141ae49bcb90..0eea804b7cb53 100644
--- a/compiler/rustc_middle/src/ty/adt.rs
+++ b/compiler/rustc_middle/src/ty/adt.rs
@@ -11,9 +11,10 @@ use rustc_data_structures::stable_hash::{
StableHash, StableHashControls, StableHashCtxt, StableHasher,
};
use rustc_errors::ErrorGuaranteed;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{CtorKind, DefKind, Res};
use rustc_hir::def_id::DefId;
-use rustc_hir::{self as hir, LangItem, find_attr};
+use rustc_hir::{self as hir, find_attr};
use rustc_index::{IndexSlice, IndexVec};
use rustc_macros::{StableHash, TyDecodable, TyEncodable};
use rustc_session::DataTypeKind;
diff --git a/compiler/rustc_middle/src/ty/consts/lit.rs b/compiler/rustc_middle/src/ty/consts/lit.rs
index 4d8fcdcd5204a..08dadf6ad9f5f 100644
--- a/compiler/rustc_middle/src/ty/consts/lit.rs
+++ b/compiler/rustc_middle/src/ty/consts/lit.rs
@@ -1,5 +1,6 @@
use rustc_ast::{LitFloatType, LitIntType, LitKind};
use rustc_hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_macros::StableHash;
use crate::ty::{self, Ty, TyCtxt};
@@ -43,7 +44,7 @@ pub fn const_lit_matches_ty<'tcx>(
(LitKind::Byte(..), ty::Uint(ty::UintTy::U8)) => true,
(LitKind::CStr(..), ty::Ref(_, inner_ty, _))
if matches!(inner_ty.kind(), ty::Adt(def, _)
- if tcx.is_lang_item(def.did(), rustc_hir::LangItem::CStr)) =>
+ if tcx.is_lang_item(def.did(), LangItem::CStr)) =>
{
true
}
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index 3d146508ec287..136a9e6ca464e 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -28,11 +28,11 @@ use rustc_data_structures::sync::{
};
use rustc_data_structures::{Limit, defer};
use rustc_errors::{Applicability, Diag, DiagCtxtHandle, Diagnostic, MultiSpan};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE, LocalDefId};
use rustc_hir::definitions::{DefPathData, Definitions, PerParentDisambiguatorState};
use rustc_hir::intravisit::VisitorExt;
-use rustc_hir::lang_items::LangItem;
use rustc_hir::{self as hir, CRATE_HIR_ID, HirId, Node, TraitCandidate, find_attr};
use rustc_index::IndexVec;
use rustc_macros::Diagnostic;
@@ -896,7 +896,7 @@ impl<'tcx> TyCtxt<'tcx> {
}
/// Traits added on all bounds by default, excluding `Sized` which is treated separately.
- pub fn default_traits(self) -> &'static [rustc_hir::LangItem] {
+ pub fn default_traits(self) -> &'static [LangItem] {
if self.sess.opts.unstable_opts.experimental_default_bounds {
&[
LangItem::DefaultTrait1,
@@ -986,14 +986,14 @@ impl<'tcx> TyCtxt<'tcx> {
}
/// Obtain all lang items of this crate and all dependencies (recursively)
- pub fn lang_items(self) -> &'tcx rustc_hir::lang_items::LanguageItems {
+ pub fn lang_items(self) -> &'tcx rustc_hir::attrs::lang_items::LanguageItems {
self.get_lang_items(())
}
/// Gets a `Ty` representing the [`LangItem::OrderingEnum`]
#[track_caller]
pub fn ty_ordering_enum(self, span: Span) -> Ty<'tcx> {
- let ordering_enum = self.require_lang_item(hir::LangItem::OrderingEnum, span);
+ let ordering_enum = self.require_lang_item(LangItem::OrderingEnum, span);
self.type_of(ordering_enum).no_bound_vars().unwrap()
}
diff --git a/compiler/rustc_middle/src/ty/context/impl_interner.rs b/compiler/rustc_middle/src/ty/context/impl_interner.rs
index ecc8d8867a279..1cce69353c14a 100644
--- a/compiler/rustc_middle/src/ty/context/impl_interner.rs
+++ b/compiler/rustc_middle/src/ty/context/impl_interner.rs
@@ -6,9 +6,10 @@ use rustc_data_structures::Limit;
use rustc_data_structures::intern::Interned;
use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir;
+use rustc_hir::CRATE_HIR_ID;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{CtorKind, DefKind, Namespace};
use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId};
-use rustc_hir::{CRATE_HIR_ID, LangItem};
use rustc_span::{DUMMY_SP, Span, Symbol};
use rustc_type_ir::lang_items::{SolverAdtLangItem, SolverProjectionLangItem, SolverTraitLangItem};
use rustc_type_ir::{
diff --git a/compiler/rustc_middle/src/ty/diagnostics.rs b/compiler/rustc_middle/src/ty/diagnostics.rs
index 31caaee970715..94a6ae918a703 100644
--- a/compiler/rustc_middle/src/ty/diagnostics.rs
+++ b/compiler/rustc_middle/src/ty/diagnostics.rs
@@ -5,9 +5,10 @@ use std::ops::ControlFlow;
use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::{Applicability, Diag, DiagArgValue, IntoDiagArg, listify, pluralize};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{DefKind, Namespace};
use rustc_hir::def_id::DefId;
-use rustc_hir::{self as hir, AmbigArg, LangItem, PredicateOrigin, WherePredicateKind};
+use rustc_hir::{self as hir, AmbigArg, PredicateOrigin, WherePredicateKind};
use rustc_span::{BytePos, Span};
use rustc_type_ir::TyKind::*;
diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs
index 9e11bc83ac7cd..dcd0ee601aa9d 100644
--- a/compiler/rustc_middle/src/ty/instance.rs
+++ b/compiler/rustc_middle/src/ty/instance.rs
@@ -3,9 +3,9 @@ use std::{assert_matches, fmt};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{CtorKind, DefKind, Namespace};
use rustc_hir::def_id::{CrateNum, DefId};
-use rustc_hir::lang_items::LangItem;
use rustc_macros::{Lift, StableHash, TyDecodable, TyEncodable};
use rustc_span::def_id::LOCAL_CRATE;
use rustc_span::{DUMMY_SP, Span};
@@ -866,22 +866,22 @@ impl<'tcx> Instance<'tcx> {
coroutine_kind,
hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::Async, _)
);
- hir::LangItem::FuturePoll
+ LangItem::FuturePoll
} else if tcx.is_lang_item(trait_id, LangItem::Iterator) {
assert_matches!(
coroutine_kind,
hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::Gen, _)
);
- hir::LangItem::IteratorNext
+ LangItem::IteratorNext
} else if tcx.is_lang_item(trait_id, LangItem::AsyncIterator) {
assert_matches!(
coroutine_kind,
hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::AsyncGen, _)
);
- hir::LangItem::AsyncIteratorPollNext
+ LangItem::AsyncIteratorPollNext
} else if tcx.is_lang_item(trait_id, LangItem::Coroutine) {
assert_matches!(coroutine_kind, hir::CoroutineKind::Coroutine(_));
- hir::LangItem::CoroutineResume
+ LangItem::CoroutineResume
} else {
return None;
};
diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs
index 41672a7b92710..562a40f182312 100644
--- a/compiler/rustc_middle/src/ty/layout.rs
+++ b/compiler/rustc_middle/src/ty/layout.rs
@@ -11,7 +11,7 @@ use rustc_errors::{
Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level,
};
use rustc_hir as hir;
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::DefId;
use rustc_macros::{StableHash, TyDecodable, TyEncodable, extension};
use rustc_session::config::OptLevel;
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs
index f5905cdefdec6..5328b29561e07 100644
--- a/compiler/rustc_middle/src/ty/mod.rs
+++ b/compiler/rustc_middle/src/ty/mod.rs
@@ -38,10 +38,11 @@ use rustc_data_structures::steal::Steal;
use rustc_data_structures::unord::{UnordMap, UnordSet};
use rustc_errors::{Diag, ErrorGuaranteed, LintBuffer};
use rustc_hir::attrs::StrippedCfgItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{CtorKind, CtorOf, DefKind, DocLinkResMap, LifetimeRes, Res};
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap};
use rustc_hir::definitions::PerParentDisambiguatorState;
-use rustc_hir::{self as hir, LangItem, MissingLifetimeKind, attrs as attr, find_attr};
+use rustc_hir::{self as hir, MissingLifetimeKind, attrs as attr, find_attr};
use rustc_index::IndexVec;
use rustc_index::bit_set::BitMatrix;
use rustc_macros::{
diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs
index 0d1d09d70572c..85a18775cb873 100644
--- a/compiler/rustc_middle/src/ty/print/pretty.rs
+++ b/compiler/rustc_middle/src/ty/print/pretty.rs
@@ -10,7 +10,7 @@ use rustc_data_structures::Limit;
use rustc_data_structures::fx::{FxIndexMap, IndexEntry};
use rustc_data_structures::unord::UnordMap;
use rustc_hir as hir;
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{self, CtorKind, DefKind, Namespace};
use rustc_hir::def_id::{DefIdMap, DefIdSet, LOCAL_CRATE, ModId};
use rustc_hir::definitions::{DefKey, DefPathDataName};
diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs
index 0e1519f5a27f9..054d4e18d3b70 100644
--- a/compiler/rustc_middle/src/ty/sty.rs
+++ b/compiler/rustc_middle/src/ty/sty.rs
@@ -10,7 +10,7 @@ use hir::def::{CtorKind, DefKind};
use rustc_abi::{FIRST_VARIANT, FieldIdx, NumScalableVectors, ScalableElt, VariantIdx};
use rustc_errors::{ErrorGuaranteed, MultiSpan};
use rustc_hir as hir;
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::DefId;
use rustc_macros::{StableHash, TyDecodable, TyEncodable, TypeFoldable, extension};
use rustc_span::{DUMMY_SP, Span, Symbol, kw, sym};
@@ -1734,7 +1734,7 @@ impl<'tcx> Ty<'tcx> {
ty::Param(_) | ty::Alias(..) | ty::Infer(ty::TyVar(_)) => {
let assoc_items = tcx.associated_item_def_ids(
- tcx.require_lang_item(hir::LangItem::DiscriminantKind, DUMMY_SP),
+ tcx.require_lang_item(LangItem::DiscriminantKind, DUMMY_SP),
);
Ty::new_projection_from_args(
tcx,
diff --git a/compiler/rustc_mir_build/src/builder/expr/as_constant.rs b/compiler/rustc_mir_build/src/builder/expr/as_constant.rs
index caf4f8d295c8a..6e09c365dbf7c 100644
--- a/compiler/rustc_mir_build/src/builder/expr/as_constant.rs
+++ b/compiler/rustc_mir_build/src/builder/expr/as_constant.rs
@@ -2,7 +2,7 @@
use rustc_abi::Size;
use rustc_ast as ast;
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_middle::mir::interpret::{CTFE_ALLOC_SALT, Scalar};
use rustc_middle::mir::*;
use rustc_middle::thir::*;
diff --git a/compiler/rustc_mir_build/src/builder/expr/into.rs b/compiler/rustc_mir_build/src/builder/expr/into.rs
index bdf45e0c85cb5..977c126e588e3 100644
--- a/compiler/rustc_mir_build/src/builder/expr/into.rs
+++ b/compiler/rustc_mir_build/src/builder/expr/into.rs
@@ -5,7 +5,7 @@ use rustc_ast::{AsmMacro, InlineAsmOptions};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_hir as hir;
-use rustc_hir::lang_items::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_middle::mir::*;
use rustc_middle::span_bug;
use rustc_middle::thir::*;
diff --git a/compiler/rustc_mir_build/src/builder/matches/mod.rs b/compiler/rustc_mir_build/src/builder/matches/mod.rs
index 109f4de2698a4..22da174c5ca77 100644
--- a/compiler/rustc_mir_build/src/builder/matches/mod.rs
+++ b/compiler/rustc_mir_build/src/builder/matches/mod.rs
@@ -13,7 +13,8 @@ use itertools::Itertools;
use rustc_abi::{FIRST_VARIANT, FieldIdx, VariantIdx};
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::stack::ensure_sufficient_stack;
-use rustc_hir::{BindingMode, ByRef, LangItem, LetStmt, LocalSource, Node};
+use rustc_hir::attrs::lang_items::LangItem;
+use rustc_hir::{BindingMode, ByRef, LetStmt, LocalSource, Node};
use rustc_middle::middle::region::{self, TempLifetime};
use rustc_middle::mir::*;
use rustc_middle::thir::{self, *};
diff --git a/compiler/rustc_mir_build/src/builder/matches/test.rs b/compiler/rustc_mir_build/src/builder/matches/test.rs
index 1c234bb8d70dc..6c499315143c3 100644
--- a/compiler/rustc_mir_build/src/builder/matches/test.rs
+++ b/compiler/rustc_mir_build/src/builder/matches/test.rs
@@ -8,7 +8,8 @@
use std::sync::Arc;
use rustc_data_structures::fx::FxIndexMap;
-use rustc_hir::{LangItem, RangeEnd};
+use rustc_hir::RangeEnd;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_middle::bug;
use rustc_middle::mir::*;
use rustc_middle::ty::util::IntTypeExt;
diff --git a/compiler/rustc_mir_build/src/check_tail_calls.rs b/compiler/rustc_mir_build/src/check_tail_calls.rs
index e148620cc62e2..057e9e727a39e 100644
--- a/compiler/rustc_mir_build/src/check_tail_calls.rs
+++ b/compiler/rustc_mir_build/src/check_tail_calls.rs
@@ -1,7 +1,7 @@
use rustc_abi::ExternAbi;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::Applicability;
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::CRATE_DEF_ID;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs
index 69590fc351320..0ca3e26d9867f 100644
--- a/compiler/rustc_mir_build/src/check_unsafety.rs
+++ b/compiler/rustc_mir_build/src/check_unsafety.rs
@@ -4,6 +4,7 @@ use std::mem;
use rustc_ast::AsmMacro;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::DiagArgValue;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::DefKind;
use rustc_hir::{self as hir, BindingMode, ByRef, HirId, Mutability, find_attr};
use rustc_middle::middle::codegen_fn_attrs::{TargetFeature, TargetFeatureKind};
@@ -459,7 +460,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
);
}
if let Some(trait_did) = self.tcx.trait_of_assoc(func_did)
- && self.tcx.is_lang_item(trait_did, hir::LangItem::Drop)
+ && self.tcx.is_lang_item(trait_did, LangItem::Drop)
{
self.requires_unsafe(expr.span, CallDropExplicitly(func_did));
}
diff --git a/compiler/rustc_mir_build/src/thir/constant.rs b/compiler/rustc_mir_build/src/thir/constant.rs
index 019af24613541..bf1dacceee46b 100644
--- a/compiler/rustc_mir_build/src/thir/constant.rs
+++ b/compiler/rustc_mir_build/src/thir/constant.rs
@@ -1,6 +1,6 @@
use rustc_abi::Size;
use rustc_ast::{self as ast, UintTy};
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_middle::bug;
use rustc_middle::ty::{self, LitToConstInput, ScalarInt, Ty, TyCtxt, TypeVisitableExt as _};
use tracing::trace;
diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs
index fcf2432b4d8dc..8e93c50f82005 100644
--- a/compiler/rustc_mir_build/src/thir/cx/expr.rs
+++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs
@@ -4,9 +4,10 @@ use rustc_ast::UnsafeBinderCastKind;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::thin_vec::ThinVec;
use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::attrs::{AttributeKind, HasAttrs};
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
-use rustc_hir::{HirId, LangItem, find_attr};
+use rustc_hir::{HirId, find_attr};
use rustc_index::Idx;
use rustc_middle::hir::place::{
Place as HirPlace, PlaceBase as HirPlaceBase, ProjectionKind as HirProjectionKind,
@@ -279,7 +280,7 @@ impl<'tcx> ThirBuildCx<'tcx> {
});
// kind = Pin { pointer }
- let pin_did = self.tcx.require_lang_item(rustc_hir::LangItem::Pin, span);
+ let pin_did = self.tcx.require_lang_item(LangItem::Pin, span);
let args = self.tcx.mk_args(&[new_pin_target.into()]);
let kind = ExprKind::Adt(Box::new(AdtExpr {
adt_def: self.tcx.adt_def(pin_did),
@@ -547,7 +548,7 @@ impl<'tcx> ThirBuildCx<'tcx> {
// Make `&pin mut $expr` and `&pin const $expr` into
// `Pin { __pointer: &mut { $expr } }` and `Pin { __pointer: &$expr }`.
hir::ExprKind::AddrOf(hir::BorrowKind::Pin, mutbl, arg_expr) => match expr_ty.kind() {
- &ty::Adt(adt_def, args) if tcx.is_lang_item(adt_def.did(), hir::LangItem::Pin) => {
+ &ty::Adt(adt_def, args) if tcx.is_lang_item(adt_def.did(), LangItem::Pin) => {
let ty = args.type_at(0);
let arg_ty = self.typeck_results.expr_ty(arg_expr);
let mut arg = self.mirror_expr(arg_expr);
diff --git a/compiler/rustc_mir_build/src/thir/cx/mod.rs b/compiler/rustc_mir_build/src/thir/cx/mod.rs
index 8e654032e8b71..aad87a99c0036 100644
--- a/compiler/rustc_mir_build/src/thir/cx/mod.rs
+++ b/compiler/rustc_mir_build/src/thir/cx/mod.rs
@@ -4,9 +4,9 @@
use rustc_data_structures::steal::Steal;
use rustc_errors::ErrorGuaranteed;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId};
-use rustc_hir::lang_items::LangItem;
use rustc_hir::{self as hir, HirId, find_attr};
use rustc_middle::bug;
use rustc_middle::thir::*;
diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs
index 143df22452987..0230840ef2fb8 100644
--- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs
+++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs
@@ -5,6 +5,7 @@ use rustc_apfloat::Float;
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{Diag, msg};
use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::find_attr;
use rustc_index::Idx;
use rustc_infer::infer::TyCtxtInferExt;
@@ -615,9 +616,8 @@ fn type_has_partial_eq_impl<'tcx>(
// (If there isn't, then we can safely issue a hard
// error, because that's never worked, due to compiler
// using `PartialEq::eq` in this scenario in the past.)
- let partial_eq_trait_id = tcx.require_lang_item(hir::LangItem::PartialEq, DUMMY_SP);
- let structural_partial_eq_trait_id =
- tcx.require_lang_item(hir::LangItem::StructuralPeq, DUMMY_SP);
+ let partial_eq_trait_id = tcx.require_lang_item(LangItem::PartialEq, DUMMY_SP);
+ let structural_partial_eq_trait_id = tcx.require_lang_item(LangItem::StructuralPeq, DUMMY_SP);
// This *could* accept a type that isn't actually `PartialEq`, because region bounds get
// ignored. However that should be pretty much impossible since consts that do not depend on
diff --git a/compiler/rustc_mir_transform/src/check_alignment.rs b/compiler/rustc_mir_transform/src/check_alignment.rs
index ee4fe5b2005c7..eeb96d109545e 100644
--- a/compiler/rustc_mir_transform/src/check_alignment.rs
+++ b/compiler/rustc_mir_transform/src/check_alignment.rs
@@ -1,5 +1,5 @@
use rustc_abi::Align;
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_index::IndexVec;
use rustc_middle::mir::interpret::Scalar;
use rustc_middle::mir::visit::PlaceContext;
diff --git a/compiler/rustc_mir_transform/src/check_call_recursion.rs b/compiler/rustc_mir_transform/src/check_call_recursion.rs
index 1a3f8fcf5f678..493d9d40f47e1 100644
--- a/compiler/rustc_mir_transform/src/check_call_recursion.rs
+++ b/compiler/rustc_mir_transform/src/check_call_recursion.rs
@@ -3,7 +3,7 @@ use std::ops::ControlFlow;
use rustc_data_structures::graph::iterate::{
NodeStatus, TriColorDepthFirstSearch, TriColorVisitor,
};
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::DefKind;
use rustc_middle::mir::{self, BasicBlock, BasicBlocks, Body, Terminator, TerminatorKind};
use rustc_middle::ty::{self, GenericArg, GenericArgs, Instance, Ty, TyCtxt, Unnormalized};
diff --git a/compiler/rustc_mir_transform/src/check_enums.rs b/compiler/rustc_mir_transform/src/check_enums.rs
index 438463d199c66..3233d7022c520 100644
--- a/compiler/rustc_mir_transform/src/check_enums.rs
+++ b/compiler/rustc_mir_transform/src/check_enums.rs
@@ -1,6 +1,6 @@
use rustc_abi::{Scalar, Size, TagEncoding, Variants, WrappingRange};
use rustc_data_structures::thin_vec::ThinVec;
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_index::IndexVec;
use rustc_middle::bug;
use rustc_middle::mir::visit::Visitor;
diff --git a/compiler/rustc_mir_transform/src/check_null.rs b/compiler/rustc_mir_transform/src/check_null.rs
index 03208458f2907..7b4ccb11c7cf4 100644
--- a/compiler/rustc_mir_transform/src/check_null.rs
+++ b/compiler/rustc_mir_transform/src/check_null.rs
@@ -1,4 +1,4 @@
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_index::IndexVec;
use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext};
use rustc_middle::mir::*;
diff --git a/compiler/rustc_mir_transform/src/check_pointers.rs b/compiler/rustc_mir_transform/src/check_pointers.rs
index 0a87e0ed5c78e..a8c2626757e05 100644
--- a/compiler/rustc_mir_transform/src/check_pointers.rs
+++ b/compiler/rustc_mir_transform/src/check_pointers.rs
@@ -1,5 +1,5 @@
use rustc_data_structures::thin_vec::ThinVec;
-use rustc_hir::lang_items::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_index::IndexVec;
use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor};
use rustc_middle::mir::*;
diff --git a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs
index 259b4b813f6a1..88ffe5861a697 100644
--- a/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs
+++ b/compiler/rustc_mir_transform/src/coroutine/by_move_body.rs
@@ -70,10 +70,10 @@
use rustc_abi::{FieldIdx, VariantIdx};
use rustc_data_structures::steal::Steal;
use rustc_data_structures::unord::UnordMap;
+use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::definitions::PerParentDisambiguatorState;
-use rustc_hir::{self as hir};
use rustc_middle::bug;
use rustc_middle::hir::place::{Projection, ProjectionKind};
use rustc_middle::mir::visit::MutVisitor;
diff --git a/compiler/rustc_mir_transform/src/coroutine/layout.rs b/compiler/rustc_mir_transform/src/coroutine/layout.rs
index 850b933a9f0bc..b460c1e82b7e9 100644
--- a/compiler/rustc_mir_transform/src/coroutine/layout.rs
+++ b/compiler/rustc_mir_transform/src/coroutine/layout.rs
@@ -26,6 +26,7 @@ use itertools::izip;
use rustc_abi::{FieldIdx, VariantIdx};
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::pluralize;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::{self as hir, find_attr};
use rustc_index::bit_set::{BitMatrix, DenseBitSet};
use rustc_index::{Idx, IndexVec};
@@ -504,7 +505,7 @@ fn check_field_tys_sized<'tcx>(
),
param_env,
field_ty.ty,
- tcx.require_lang_item(hir::LangItem::Sized, field_ty.source_info.span),
+ tcx.require_lang_item(LangItem::Sized, field_ty.source_info.span),
);
}
diff --git a/compiler/rustc_mir_transform/src/coroutine/mod.rs b/compiler/rustc_mir_transform/src/coroutine/mod.rs
index 6d9d0d35d3ed6..c5c65553dae8c 100644
--- a/compiler/rustc_mir_transform/src/coroutine/mod.rs
+++ b/compiler/rustc_mir_transform/src/coroutine/mod.rs
@@ -64,7 +64,7 @@ pub(super) use layout::mir_coroutine_witnesses;
use layout::{CoroutineSavedLocals, compute_layout, locals_live_across_suspend_points};
use rustc_abi::{FieldIdx, VariantIdx};
use rustc_data_structures::thin_vec::ThinVec;
-use rustc_hir::lang_items::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::{self as hir, CoroutineDesugaring, CoroutineKind};
use rustc_index::bit_set::{BitMatrix, DenseBitSet, GrowableBitSet};
use rustc_index::{Idx, IndexVec, indexvec};
diff --git a/compiler/rustc_mir_transform/src/elaborate_drop.rs b/compiler/rustc_mir_transform/src/elaborate_drop.rs
index 4a309607fdf4e..492759d666c83 100644
--- a/compiler/rustc_mir_transform/src/elaborate_drop.rs
+++ b/compiler/rustc_mir_transform/src/elaborate_drop.rs
@@ -3,7 +3,7 @@ use std::{fmt, iter, mem};
use itertools::Itertools;
use rustc_abi::{FIRST_VARIANT, FieldIdx, VariantIdx};
use rustc_data_structures::thin_vec::ThinVec;
-use rustc_hir::lang_items::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::{CoroutineDesugaring, CoroutineKind};
use rustc_index::Idx;
use rustc_middle::mir::*;
diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs
index 765fd8984b446..47df95a37a60f 100644
--- a/compiler/rustc_mir_transform/src/inline.rs
+++ b/compiler/rustc_mir_transform/src/inline.rs
@@ -5,6 +5,7 @@ use std::{debug_assert_matches, iter};
use rustc_abi::{ExternAbi, FieldIdx};
use rustc_data_structures::thin_vec::ThinVec;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::attrs::{InlineAttr, OptimizeAttr};
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
@@ -774,9 +775,7 @@ fn check_mir_is_available<'tcx, I: Inliner<'tcx>>(
}
if let Some(callee_def_id) = callee_def_id.as_local()
- && !inliner
- .tcx()
- .is_lang_item(inliner.tcx().parent(caller_def_id), rustc_hir::LangItem::FnOnce)
+ && !inliner.tcx().is_lang_item(inliner.tcx().parent(caller_def_id), LangItem::FnOnce)
{
// If we know for sure that the function we're calling will itself try to
// call us, then we avoid inlining that function.
diff --git a/compiler/rustc_mir_transform/src/instsimplify.rs b/compiler/rustc_mir_transform/src/instsimplify.rs
index 9d92ac29870b5..8f8b4aec7cbbc 100644
--- a/compiler/rustc_mir_transform/src/instsimplify.rs
+++ b/compiler/rustc_mir_transform/src/instsimplify.rs
@@ -1,7 +1,8 @@
//! Performs various peephole optimizations.
use rustc_abi::{ExternAbi, Integer};
-use rustc_hir::{LangItem, find_attr};
+use rustc_hir::attrs::lang_items::LangItem;
+use rustc_hir::find_attr;
use rustc_index::IndexVec;
use rustc_middle::bug;
use rustc_middle::mir::visit::MutVisitor;
diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs
index 9743d7b552862..0561c04bc1db3 100644
--- a/compiler/rustc_mir_transform/src/shim.rs
+++ b/compiler/rustc_mir_transform/src/shim.rs
@@ -3,8 +3,8 @@ use std::{assert_matches, fmt, iter};
use rustc_abi::{ExternAbi, FIRST_VARIANT, FieldIdx, VariantIdx};
use rustc_data_structures::thin_vec::ThinVec;
use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::DefId;
-use rustc_hir::lang_items::LangItem;
use rustc_index::{Idx, IndexVec};
use rustc_middle::mir::visit::{MutVisitor, PlaceContext};
use rustc_middle::mir::*;
diff --git a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs
index 085a978b9956d..1d91bc1cab988 100644
--- a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs
+++ b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs
@@ -1,5 +1,5 @@
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::DefId;
-use rustc_hir::lang_items::LangItem;
use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource};
use rustc_index::{Idx, IndexVec};
use rustc_middle::mir::{
diff --git a/compiler/rustc_mir_transform/src/sroa.rs b/compiler/rustc_mir_transform/src/sroa.rs
index b16336fb9150c..a2bda3032f567 100644
--- a/compiler/rustc_mir_transform/src/sroa.rs
+++ b/compiler/rustc_mir_transform/src/sroa.rs
@@ -1,6 +1,6 @@
use rustc_abi::FieldIdx;
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_index::IndexVec;
use rustc_index::bit_set::{DenseBitSet, GrowableBitSet};
use rustc_middle::bug;
diff --git a/compiler/rustc_mir_transform/src/validate.rs b/compiler/rustc_mir_transform/src/validate.rs
index b4eb90f4507c9..8fe2263a7c1af 100644
--- a/compiler/rustc_mir_transform/src/validate.rs
+++ b/compiler/rustc_mir_transform/src/validate.rs
@@ -2,8 +2,8 @@
use rustc_abi::{ExternAbi, FIRST_VARIANT, Size};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
-use rustc_hir::LangItem;
use rustc_hir::attrs::InlineAttr;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_index::IndexVec;
use rustc_index::bit_set::DenseBitSet;
use rustc_infer::infer::TyCtxtInferExt;
diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs
index fae1ee7256683..105c8e0ed7388 100644
--- a/compiler/rustc_monomorphize/src/collector.rs
+++ b/compiler/rustc_monomorphize/src/collector.rs
@@ -214,9 +214,9 @@ use rustc_data_structures::sync::{Lock, par_for_each_in};
use rustc_data_structures::unord::{UnordMap, UnordSet};
use rustc_hir as hir;
use rustc_hir::attrs::InlineAttr;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId};
-use rustc_hir::lang_items::LangItem;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::mir::interpret::{AllocId, ErrorHandled, GlobalAlloc, Scalar};
use rustc_middle::mir::visit::Visitor as MirVisitor;
diff --git a/compiler/rustc_monomorphize/src/lib.rs b/compiler/rustc_monomorphize/src/lib.rs
index 0b5a3d1f267da..c72ee9dd23393 100644
--- a/compiler/rustc_monomorphize/src/lib.rs
+++ b/compiler/rustc_monomorphize/src/lib.rs
@@ -4,7 +4,7 @@
#![feature(once_cell_get_mut)]
// tidy-alphabetical-end
-use rustc_hir::lang_items::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_middle::query::TyCtxtAt;
use rustc_middle::ty::adjustment::CustomCoerceUnsized;
use rustc_middle::ty::{self, Ty};
diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs
index 5cfae525d7e5e..cdd18654f0930 100644
--- a/compiler/rustc_monomorphize/src/partitioning.rs
+++ b/compiler/rustc_monomorphize/src/partitioning.rs
@@ -102,7 +102,7 @@ use rustc_data_structures::either::Either;
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_data_structures::sync::par_join;
use rustc_data_structures::unord::{UnordMap, UnordSet};
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::attrs::{InlineAttr, Linkage};
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, DefIdSet, LOCAL_CRATE};
diff --git a/compiler/rustc_parse/src/diagnostics.rs b/compiler/rustc_parse/src/diagnostics.rs
index 7145037f187e6..7897239d248ea 100644
--- a/compiler/rustc_parse/src/diagnostics.rs
+++ b/compiler/rustc_parse/src/diagnostics.rs
@@ -11,7 +11,6 @@ use rustc_errors::{
Level, Subdiagnostic, SuggestionStyle, msg,
};
use rustc_macros::{Diagnostic, Subdiagnostic};
-use rustc_session::diagnostics::ExprParenthesesNeeded;
use rustc_span::edition::{Edition, LATEST_STABLE_EDITION};
use rustc_span::{Ident, Span, Symbol};
@@ -923,6 +922,24 @@ pub(crate) struct FoundExprWouldBeStmt {
pub suggestion: ExprParenthesesNeeded,
}
+#[derive(Subdiagnostic)]
+#[multipart_suggestion(
+ "parentheses are required to parse this as an expression",
+ applicability = "machine-applicable"
+)]
+pub(crate) struct ExprParenthesesNeeded {
+ #[suggestion_part(code = "(")]
+ left: Span,
+ #[suggestion_part(code = ")")]
+ right: Span,
+}
+
+impl ExprParenthesesNeeded {
+ pub(crate) fn surrounding(s: Span) -> Self {
+ ExprParenthesesNeeded { left: s.shrink_to_lo(), right: s.shrink_to_hi() }
+ }
+}
+
#[derive(Diagnostic)]
#[diag("extra characters after frontmatter close are not allowed")]
pub(crate) struct FrontmatterExtraCharactersAfterClose {
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs
index f63064002c559..0b91828639d36 100644
--- a/compiler/rustc_parse/src/parser/diagnostics.rs
+++ b/compiler/rustc_parse/src/parser/diagnostics.rs
@@ -15,7 +15,6 @@ use rustc_errors::{
Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, PResult, Subdiagnostic, Suggestions, msg,
pluralize,
};
-use rustc_session::diagnostics::ExprParenthesesNeeded;
use rustc_span::symbol::used_keywords;
use rustc_span::{BytePos, DUMMY_SP, Ident, Span, SpanSnippetError, Spanned, Symbol, kw, sym};
use thin_vec::{ThinVec, thin_vec};
@@ -31,7 +30,7 @@ use crate::diagnostics::{
AwaitSuggestion, BadQPathStage2, BadTypePlus, BadTypePlusSub, ColonAsSemi,
ComparisonOperatorsCannotBeChained, ComparisonOperatorsCannotBeChainedSugg,
DocCommentDoesNotDocumentAnything, DocCommentOnParamType, DoubleColonInBound,
- ExpectedIdentifier, ExpectedSemi, ExpectedSemiSugg, FoundPathInGenerics,
+ ExpectedIdentifier, ExpectedSemi, ExpectedSemiSugg, ExprParenthesesNeeded, FoundPathInGenerics,
GenericParamsWithoutAngleBrackets, GenericParamsWithoutAngleBracketsSugg,
HelpIdentifierStartsWithNumber, HelpUseLatestEdition, InInTypo, IncorrectAwait,
IncorrectSemicolon, IncorrectUseOfAwait, IncorrectUseOfUse, MisspelledKw,
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs
index 5afb292580a01..af20b0957ecee 100644
--- a/compiler/rustc_parse/src/parser/expr.rs
+++ b/compiler/rustc_parse/src/parser/expr.rs
@@ -21,7 +21,7 @@ use rustc_ast_pretty::pprust;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::{Applicability, Diag, PResult, StashKey, Subdiagnostic};
use rustc_literal_escaper::unescape_char;
-use rustc_session::diagnostics::{ExprParenthesesNeeded, report_lit_error};
+use rustc_session::diagnostics::report_lit_error;
use rustc_session::lint::builtin::BREAK_WITH_LABEL_AND_LOOP;
use rustc_span::edition::Edition;
use rustc_span::{BytePos, ErrorGuaranteed, Ident, Pos, Span, Spanned, Symbol, kw, respan, sym};
@@ -35,6 +35,7 @@ use super::{
AttrWrapper, BlockMode, ClosureSpans, ExpTokenPair, ForceCollect, Parser, PathStyle,
Restrictions, SemiColonMode, SeqSep, TokenType, Trailing, UsePreAttrPos,
};
+use crate::diagnostics::ExprParenthesesNeeded;
use crate::{diagnostics, exp, maybe_recover_from_interpolated_ty_qpath};
#[derive(Debug)]
diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs
index 026fe8acb35cd..d017a27e8f77f 100644
--- a/compiler/rustc_parse/src/parser/pat.rs
+++ b/compiler/rustc_parse/src/parser/pat.rs
@@ -12,7 +12,6 @@ use rustc_ast::{
};
use rustc_ast_pretty::pprust;
use rustc_errors::{Applicability, Diag, DiagArgValue, PResult, StashKey};
-use rustc_session::diagnostics::ExprParenthesesNeeded;
use rustc_span::{BytePos, ErrorGuaranteed, Ident, Span, Spanned, kw, respan, sym};
use thin_vec::{ThinVec, thin_vec};
@@ -21,12 +20,12 @@ use crate::diagnostics::{
self, AmbiguousRangePattern, AtDotDotInStructPattern, AtInStructPattern,
DotDotDotForRemainingFields, DotDotDotRangeToPatternNotAllowed, DotDotDotRestPattern,
EnumPatternInsteadOfIdentifier, ExpectedBindingLeftOfAt, ExpectedCommaAfterPatternField,
- GenericArgsInPatRequireTurbofishSyntax, InclusiveRangeExtraEquals, InclusiveRangeMatchArrow,
- InclusiveRangeNoEnd, InvalidMutInPattern, ParenRangeSuggestion, PatternOnWrongSideOfAt,
- RemoveLet, RepeatedMutInPattern, SwitchRefBoxOrder, TopLevelOrPatternNotAllowed,
- TopLevelOrPatternNotAllowedSugg, TrailingVertNotAllowed, TrailingVertSuggestion,
- UnexpectedExpressionInPattern, UnexpectedExpressionInPatternSugg, UnexpectedLifetimeInPattern,
- UnexpectedParenInRangePat, UnexpectedParenInRangePatSugg,
+ ExprParenthesesNeeded, GenericArgsInPatRequireTurbofishSyntax, InclusiveRangeExtraEquals,
+ InclusiveRangeMatchArrow, InclusiveRangeNoEnd, InvalidMutInPattern, ParenRangeSuggestion,
+ PatternOnWrongSideOfAt, RemoveLet, RepeatedMutInPattern, SwitchRefBoxOrder,
+ TopLevelOrPatternNotAllowed, TopLevelOrPatternNotAllowedSugg, TrailingVertNotAllowed,
+ TrailingVertSuggestion, UnexpectedExpressionInPattern, UnexpectedExpressionInPatternSugg,
+ UnexpectedLifetimeInPattern, UnexpectedParenInRangePat, UnexpectedParenInRangePatSugg,
UnexpectedVertVertBeforeFunctionParam, UnexpectedVertVertInPattern, WrapInParens,
};
use crate::parser::expr::{DestructuredFloat, could_be_unclosed_char_literal};
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs
index d29d5280e77e9..44c34a2abddd1 100644
--- a/compiler/rustc_passes/src/check_attr.rs
+++ b/compiler/rustc_passes/src/check_attr.rs
@@ -15,6 +15,7 @@ use rustc_data_structures::thin_vec::ThinVec;
use rustc_errors::{DiagCtxtHandle, IntoDiagArg, MultiSpan, msg};
use rustc_feature::BUILTIN_ATTRIBUTE_MAP;
use rustc_hir::attrs::diagnostic::Directive;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::attrs::{
AttributeKind, DocAttribute, DocInline, EiiDecl, EiiImpl, EiiImplResolution, InlineAttr,
OptimizeAttr, ReprAttr,
@@ -1130,7 +1131,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
&& let hir::ItemKind::Impl(impl_) = item.kind
&& let Some(of_trait) = impl_.of_trait
&& let Some(def_id) = of_trait.trait_ref.trait_def_id()
- && self.tcx.is_lang_item(def_id, hir::LangItem::Drop)
+ && self.tcx.is_lang_item(def_id, LangItem::Drop)
{
return;
}
diff --git a/compiler/rustc_passes/src/diagnostic_items.rs b/compiler/rustc_passes/src/diagnostic_items.rs
index e950a26af91a3..74cd94259f4b4 100644
--- a/compiler/rustc_passes/src/diagnostic_items.rs
+++ b/compiler/rustc_passes/src/diagnostic_items.rs
@@ -9,7 +9,7 @@
//!
//! * Compiler internal types like `Ty` and `TyCtxt`
-use rustc_hir::diagnostic_items::DiagnosticItems;
+use rustc_hir::attrs::diagnostic_items::DiagnosticItems;
use rustc_hir::{CRATE_OWNER_ID, OwnerId, find_attr};
use rustc_middle::query::{LocalCrate, Providers};
use rustc_middle::ty::TyCtxt;
diff --git a/compiler/rustc_passes/src/lang_items.rs b/compiler/rustc_passes/src/lang_items.rs
index bf8f071c822d3..d26069b07b854 100644
--- a/compiler/rustc_passes/src/lang_items.rs
+++ b/compiler/rustc_passes/src/lang_items.rs
@@ -9,9 +9,9 @@
use rustc_ast as ast;
use rustc_ast::visit;
+use rustc_hir::Target;
+use rustc_hir::attrs::lang_items::{GenericRequirement, LangItem, LanguageItems};
use rustc_hir::def_id::{DefId, LocalDefId};
-use rustc_hir::lang_items::GenericRequirement;
-use rustc_hir::{LangItem, LanguageItems, Target};
use rustc_middle::query::Providers;
use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
use rustc_session::cstore::ExternCrate;
diff --git a/compiler/rustc_passes/src/weak_lang_items.rs b/compiler/rustc_passes/src/weak_lang_items.rs
index 6c151378d2e73..3d451fde8adb8 100644
--- a/compiler/rustc_passes/src/weak_lang_items.rs
+++ b/compiler/rustc_passes/src/weak_lang_items.rs
@@ -1,8 +1,8 @@
//! Validity checking for weak lang items
use rustc_data_structures::fx::FxHashSet;
-use rustc_hir::lang_items::{self, LangItem};
-use rustc_hir::weak_lang_items::WEAK_LANG_ITEMS;
+use rustc_hir::attrs::lang_items::{self, LangItem};
+use rustc_hir::attrs::weak_lang_items::WEAK_LANG_ITEMS;
use rustc_middle::middle::lang_items::required;
use rustc_middle::ty::TyCtxt;
use rustc_session::config::CrateType;
diff --git a/compiler/rustc_public_bridge/src/context/impls.rs b/compiler/rustc_public_bridge/src/context/impls.rs
index f648a85249dfc..345e83ca21b69 100644
--- a/compiler/rustc_public_bridge/src/context/impls.rs
+++ b/compiler/rustc_public_bridge/src/context/impls.rs
@@ -5,8 +5,9 @@
use std::iter;
use rustc_abi::{Endian, Layout, ReprOptions};
+use rustc_hir::Attribute;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::DefKind;
-use rustc_hir::{Attribute, LangItem};
use rustc_middle::mir::interpret::{AllocId, ConstAllocation, ErrorHandled, GlobalAlloc, Scalar};
use rustc_middle::mir::{BinOp, Body, Const as MirConst, ConstValue, UnOp};
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf};
diff --git a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs
index 6bc1647c4b05b..1d4accd8ad3b6 100644
--- a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs
+++ b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs
@@ -6,7 +6,8 @@
use std::iter;
-use rustc_hir::{self as hir, LangItem, find_attr};
+use rustc_hir::attrs::lang_items::LangItem;
+use rustc_hir::{self as hir, find_attr};
use rustc_middle::bug;
use rustc_middle::ty::{
self, AssocContainer, ExistentialPredicateStableCmpExt as _, Instance, IntTy, List, TraitRef,
diff --git a/compiler/rustc_session/src/diagnostics.rs b/compiler/rustc_session/src/diagnostics.rs
index 9efc4bc4a1df8..c229adf5aef4d 100644
--- a/compiler/rustc_session/src/diagnostics.rs
+++ b/compiler/rustc_session/src/diagnostics.rs
@@ -451,24 +451,6 @@ pub(crate) struct InvalidCharacterInCrateNameSuggestion {
pub(crate) suggested_name: String,
}
-#[derive(Subdiagnostic)]
-#[multipart_suggestion(
- "parentheses are required to parse this as an expression",
- applicability = "machine-applicable"
-)]
-pub struct ExprParenthesesNeeded {
- #[suggestion_part(code = "(")]
- left: Span,
- #[suggestion_part(code = ")")]
- right: Span,
-}
-
-impl ExprParenthesesNeeded {
- pub fn surrounding(s: Span) -> Self {
- ExprParenthesesNeeded { left: s.shrink_to_lo(), right: s.shrink_to_hi() }
- }
-}
-
#[derive(Diagnostic)]
#[diag("skipping const checks")]
pub(crate) struct SkippingConstChecks {
diff --git a/compiler/rustc_span/src/analyze_source_file.rs b/compiler/rustc_span/src/analyze_source_file.rs
index bb2cda77dffff..59cda1238cc77 100644
--- a/compiler/rustc_span/src/analyze_source_file.rs
+++ b/compiler/rustc_span/src/analyze_source_file.rs
@@ -193,7 +193,7 @@ cfg_select! {
assert!(intra_chunk_offset == 0);
// Check for newlines in the chunk
- let newlines_test = lsx_vseqi_b::<{b'\n' as i32}>(chunk);
+ let newlines_test = lsx_vseqi_b::<{ b'\n' as i32 }>(chunk);
let newlines_mask = lsx_vmskltz_b(newlines_test);
let mut newlines_mask = lsx_vpickve2gr_w::<0>(newlines_mask);
diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs
index 7fcc53c2b4348..c28970829f0a4 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/infer/note_and_explain.rs
@@ -1,7 +1,8 @@
use rustc_errors::Applicability::{MachineApplicable, MaybeIncorrect};
use rustc_errors::{Diag, MultiSpan, pluralize};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::DefKind;
-use rustc_hir::{self as hir, LangItem, find_attr};
+use rustc_hir::{self as hir, find_attr};
use rustc_middle::traits::{ObligationCause, ObligationCauseCode};
use rustc_middle::ty::error::{ExpectedFound, TypeError};
use rustc_middle::ty::fast_reject::DeepRejectCtxt;
diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs
index 3ef350613ee16..ec855b4debd04 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs
@@ -2,7 +2,7 @@ use std::ops::ControlFlow;
use rustc_errors::{Applicability, Diag, E0283, E0284, E0790, MultiSpan, struct_span_code_err};
use rustc_hir as hir;
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{CRATE_DEF_ID, DefId};
use rustc_hir::intravisit::Visitor as _;
diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/call_kind.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/call_kind.rs
index bdd22f89923f9..3b1feeaa1424a 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/traits/call_kind.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/traits/call_kind.rs
@@ -2,9 +2,9 @@
//! as well as errors when attempting to call a non-const function in a const
//! context.
+use rustc_hir::attrs::lang_items::{self, LangItem};
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
-use rustc_hir::{LangItem, lang_items};
use rustc_middle::ty::{
self, AssocContainer, GenericArgsRef, Instance, Ty, TyCtxt, TypingEnv, Unnormalized,
};
diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
index 95054de6d0734..d90c3e81b68ea 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
@@ -14,9 +14,10 @@ use rustc_errors::{
pluralize, struct_span_code_err,
};
use rustc_hir::attrs::diagnostic::CustomDiagnostic;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId};
use rustc_hir::intravisit::Visitor;
-use rustc_hir::{self as hir, LangItem, Node, expr_needs_parens, find_attr};
+use rustc_hir::{self as hir, Node, expr_needs_parens, find_attr};
use rustc_infer::infer::{InferOk, TypeTrace};
use rustc_infer::traits::solve::Goal;
use rustc_infer::traits::{ImplSource, TraitErrors};
diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
index d2e8f136d7491..15f82012b75ab 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
@@ -13,10 +13,10 @@ use rustc_errors::{
Applicability, Diag, EmissionGuarantee, MultiSpan, Style, SuggestionStyle, pluralize,
struct_span_code_err,
};
+use rustc_hir::attrs::lang_items::{self, LangItem};
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::{Visitor, VisitorExt};
-use rustc_hir::lang_items::LangItem;
use rustc_hir::{
self as hir, AmbigArg, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, HirId, Node,
expr_needs_parens,
@@ -822,7 +822,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
&& let Some(rhs_ty) = typeck_results.expr_ty_opt(rhs)
&& let trait_pred = predicate.unwrap_or(trait_pred)
// Only run this code on binary operators
- && hir::lang_items::BINARY_OPERATORS
+ && lang_items::BINARY_OPERATORS
.iter()
.filter_map(|&op| self.tcx.lang_items().get(op))
.any(|op| {
diff --git a/compiler/rustc_trait_selection/src/infer.rs b/compiler/rustc_trait_selection/src/infer.rs
index a633f5de16c6f..f0fb44523d651 100644
--- a/compiler/rustc_trait_selection/src/infer.rs
+++ b/compiler/rustc_trait_selection/src/infer.rs
@@ -1,7 +1,7 @@
use std::fmt::Debug;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::DefId;
-use rustc_hir::lang_items::LangItem;
pub use rustc_infer::infer::*;
use rustc_infer::traits::TraitErrors;
use rustc_macros::extension;
diff --git a/compiler/rustc_trait_selection/src/solve/delegate.rs b/compiler/rustc_trait_selection/src/solve/delegate.rs
index bb1e6c168c47b..edfc988dca71f 100644
--- a/compiler/rustc_trait_selection/src/solve/delegate.rs
+++ b/compiler/rustc_trait_selection/src/solve/delegate.rs
@@ -2,7 +2,7 @@ use std::collections::hash_map::Entry;
use std::ops::Deref;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::{CRATE_DEF_ID, DefId};
use rustc_infer::infer::canonical::query_response::make_query_region_constraints;
use rustc_infer::infer::canonical::{
diff --git a/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs b/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs
index 18c228d5ddc55..a25848b30e2fc 100644
--- a/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs
+++ b/compiler/rustc_trait_selection/src/solve/fulfill/derive_errors.rs
@@ -1,6 +1,6 @@
use std::ops::ControlFlow;
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_infer::infer::InferCtxt;
use rustc_infer::traits::solve::{CandidateSource, GoalSource, MaybeCause};
use rustc_infer::traits::{
diff --git a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs
index 3c5d473dcc045..6d86a2cce6400 100644
--- a/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs
+++ b/compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs
@@ -7,8 +7,9 @@
use std::ops::ControlFlow;
use rustc_errors::FatalError;
+use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::DefId;
-use rustc_hir::{self as hir, LangItem};
use rustc_middle::query::Providers;
use rustc_middle::ty::{
self, EarlyBinder, GenericArgs, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable,
diff --git a/compiler/rustc_trait_selection/src/traits/effects.rs b/compiler/rustc_trait_selection/src/traits/effects.rs
index 567845a34bd8b..c0a18f9d14fcb 100644
--- a/compiler/rustc_trait_selection/src/traits/effects.rs
+++ b/compiler/rustc_trait_selection/src/traits/effects.rs
@@ -1,4 +1,5 @@
-use rustc_hir::{self as hir, LangItem};
+use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes};
use rustc_infer::traits::{
ImplDerivedHostCause, ImplSource, Obligation, ObligationCause, ObligationCauseCode,
diff --git a/compiler/rustc_trait_selection/src/traits/misc.rs b/compiler/rustc_trait_selection/src/traits/misc.rs
index c5c4288ea64b2..97f6e2ed0b122 100644
--- a/compiler/rustc_trait_selection/src/traits/misc.rs
+++ b/compiler/rustc_trait_selection/src/traits/misc.rs
@@ -1,8 +1,8 @@
//! Miscellaneous type-system utilities that are too small to deserve their own modules.
-use hir::LangItem;
use rustc_ast::Mutability;
use rustc_hir as hir;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_infer::infer::{RegionResolutionError, TyCtxtInferExt};
use rustc_infer::traits::TraitErrors;
use rustc_middle::bug;
@@ -69,16 +69,8 @@ pub fn type_allowed_to_implement_copy<'tcx>(
_ => return Err(CopyImplementationError::NotAnAdt),
};
- all_fields_implement_trait(
- tcx,
- param_env,
- self_type,
- adt,
- args,
- parent_cause,
- hir::LangItem::Copy,
- )
- .map_err(CopyImplementationError::InfringingFields)?;
+ all_fields_implement_trait(tcx, param_env, self_type, adt, args, parent_cause, LangItem::Copy)
+ .map_err(CopyImplementationError::InfringingFields)?;
if let Some(did) = adt.destructor(tcx).map(|dtor| dtor.did) {
return Err(CopyImplementationError::HasDestructor(did));
diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs
index 71cbe0a28c780..72954c0818415 100644
--- a/compiler/rustc_trait_selection/src/traits/project.rs
+++ b/compiler/rustc_trait_selection/src/traits/project.rs
@@ -5,8 +5,8 @@ use std::ops::ControlFlow;
use rustc_data_structures::sso::SsoHashSet;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::ErrorGuaranteed;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::DefId;
-use rustc_hir::lang_items::LangItem;
use rustc_infer::infer::DefineOpaqueTypes;
use rustc_infer::infer::resolve::OpportunisticRegionResolver;
use rustc_infer::traits::{ObligationCauseCode, PredicateObligations};
diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
index 84b51f42c411e..db863cb42f63e 100644
--- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
@@ -8,9 +8,9 @@
use std::ops::ControlFlow;
-use hir::LangItem;
use hir::def_id::DefId;
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::{self as hir, CoroutineDesugaring, CoroutineKind};
use rustc_infer::traits::{Obligation, PolyTraitObligation, PredicateObligation, SelectionError};
use rustc_middle::ty::fast_reject::DeepRejectCtxt;
diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs
index 83387e4b7331e..d04f4ea587dc5 100644
--- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs
@@ -10,7 +10,7 @@
use std::ops::ControlFlow;
use rustc_data_structures::stack::ensure_sufficient_stack;
-use rustc_hir::lang_items::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_infer::infer::{BoundRegionConversionTime, DefineOpaqueTypes, InferOk};
use rustc_infer::traits::ObligationCauseCode;
use rustc_middle::traits::{BuiltinImplSource, SignatureMismatchData};
diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs
index ea71d3f7da234..4af20d1ad59a2 100644
--- a/compiler/rustc_trait_selection/src/traits/select/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs
@@ -11,8 +11,9 @@ use hir::def::DefKind;
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::{Diag, EmissionGuarantee};
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::DefId;
-use rustc_hir::{self as hir, LangItem, find_attr};
+use rustc_hir::{self as hir, find_attr};
use rustc_infer::infer::BoundRegionConversionTime::{self, HigherRankedType};
use rustc_infer::infer::DefineOpaqueTypes;
use rustc_infer::infer::at::ToTrace;
diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs
index 019214c210e7d..e611b4fc6b6ac 100644
--- a/compiler/rustc_trait_selection/src/traits/util.rs
+++ b/compiler/rustc_trait_selection/src/traits/util.rs
@@ -1,7 +1,7 @@
use std::collections::VecDeque;
use rustc_data_structures::fx::FxHashSet;
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def_id::DefId;
use rustc_infer::infer::InferCtxt;
use rustc_infer::traits::PolyTraitObligation;
diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs
index 1b2e19fd05316..28efd58ca48fd 100644
--- a/compiler/rustc_trait_selection/src/traits/wf.rs
+++ b/compiler/rustc_trait_selection/src/traits/wf.rs
@@ -6,7 +6,7 @@
use std::iter;
use rustc_hir as hir;
-use rustc_hir::lang_items::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_infer::traits::{ObligationCauseCode, PredicateObligations};
use rustc_middle::bug;
use rustc_middle::ty::{
diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs
index e504ce0051398..0c031d978d6ac 100644
--- a/compiler/rustc_transmute/src/lib.rs
+++ b/compiler/rustc_transmute/src/lib.rs
@@ -89,7 +89,7 @@ pub enum Reason {
#[cfg(feature = "rustc")]
mod rustc {
- use rustc_hir::lang_items::LangItem;
+ use rustc_hir::attrs::lang_items::LangItem;
use rustc_middle::ty::{Const, Region, Ty, TyCtxt};
use super::*;
diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs
index ad8918f70a582..1f2c054c9323a 100644
--- a/compiler/rustc_ty_utils/src/abi.rs
+++ b/compiler/rustc_ty_utils/src/abi.rs
@@ -2,7 +2,7 @@ use std::{assert_matches, iter};
use rustc_abi::Primitive::Pointer;
use rustc_abi::{Align, BackendRepr, ExternAbi, PointerKind, Scalar, Size};
-use rustc_hir::lang_items::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::{self as hir, find_attr};
use rustc_middle::bug;
use rustc_middle::middle::deduced_param_attrs::DeducedParamAttrs;
diff --git a/compiler/rustc_ty_utils/src/common_traits.rs b/compiler/rustc_ty_utils/src/common_traits.rs
index a3f1be77f47a6..4d25a2886fa27 100644
--- a/compiler/rustc_ty_utils/src/common_traits.rs
+++ b/compiler/rustc_ty_utils/src/common_traits.rs
@@ -1,6 +1,6 @@
//! Queries for checking whether a type implements one of a few common traits.
-use rustc_hir::lang_items::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::query::Providers;
use rustc_middle::ty::{self, Ty, TyCtxt};
diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs
index 3862f043fea09..c0f476a7feaca 100644
--- a/compiler/rustc_ty_utils/src/instance.rs
+++ b/compiler/rustc_ty_utils/src/instance.rs
@@ -1,5 +1,5 @@
use rustc_errors::ErrorGuaranteed;
-use rustc_hir::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefId;
use rustc_infer::infer::TyCtxtInferExt;
diff --git a/compiler/rustc_ty_utils/src/structural_match.rs b/compiler/rustc_ty_utils/src/structural_match.rs
index a3b9d49b30900..85d13cfda743b 100644
--- a/compiler/rustc_ty_utils/src/structural_match.rs
+++ b/compiler/rustc_ty_utils/src/structural_match.rs
@@ -1,4 +1,4 @@
-use rustc_hir::lang_items::LangItem;
+use rustc_hir::attrs::lang_items::LangItem;
use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::query::Providers;
use rustc_middle::ty::{self, Ty, TyCtxt, TypingMode};
diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs
index 4ba4c4e8caa4c..00f802e5d9155 100644
--- a/library/std/src/net/tcp.rs
+++ b/library/std/src/net/tcp.rs
@@ -1058,7 +1058,7 @@ impl TcpListener {
/// use std::net::TcpListener;
///
/// let listener = TcpListener::bind("127.0.0.1:80").unwrap();
- /// listener.take_error().expect("No error was expected");
+ /// listener.take_error().expect("`take_error` should succeed");
/// ```
#[stable(feature = "net2_mutators", since = "1.9.0")]
pub fn take_error(&self) -> io::Result