diff --git a/Cargo.lock b/Cargo.lock index 5fc3a5ac71722..ff0501d2bbcf3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3725,10 +3725,10 @@ dependencies = [ "rustc_abi", "rustc_ast", "rustc_ast_pretty", + "rustc_attr_ir", "rustc_data_structures", "rustc_errors", "rustc_feature", - "rustc_hir", "rustc_lexer", "rustc_lint_defs", "rustc_macros", diff --git a/compiler/rustc_ast_lowering/src/block.rs b/compiler/rustc_ast_lowering/src/block.rs index b52af8fd3715a..68037bb835eac 100644 --- a/compiler/rustc_ast_lowering/src/block.rs +++ b/compiler/rustc_ast_lowering/src/block.rs @@ -1,6 +1,6 @@ use rustc_ast::{Block, BlockCheckMode, Local, LocalKind, Stmt, StmtKind}; use rustc_hir as hir; -use rustc_hir::Target; +use rustc_hir::attrs::target::Target; use rustc_span::sym; use smallvec::SmallVec; diff --git a/compiler/rustc_ast_lowering/src/contract.rs b/compiler/rustc_ast_lowering/src/contract.rs index 4b2ee21ca5980..d41e33c4a1f13 100644 --- a/compiler/rustc_ast_lowering/src/contract.rs +++ b/compiler/rustc_ast_lowering/src/contract.rs @@ -1,5 +1,7 @@ use std::sync::Arc; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::attrs::target::Target; use thin_vec::thin_vec; use crate::LoweringContext; @@ -146,7 +148,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 +167,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 +210,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, + LangItem::OptionSome, &*arena_vec![self; *postcond_checker], )); let then_block_stmts = self.block_all(span, stmts, Some(postcond_checker)); @@ -216,7 +218,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, + LangItem::OptionNone, Default::default(), )); let else_block = self.block_expr(none_expr); @@ -326,7 +328,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); @@ -349,7 +351,7 @@ impl<'hir> LoweringContext<'_, 'hir> { )); let attrs: rustc_ast::AttrVec = thin_vec![self.unreachable_code_attr(span)]; - self.lower_attrs(contract_check.hir_id, &attrs, span, rustc_hir::Target::Expression); + self.lower_attrs(contract_check.hir_id, &attrs, span, Target::Expression); let ret_block = self.block_all(span, arena_vec![self; ret_stmt], Some(contract_check)); self.arena.alloc(self.expr_block(self.arena.alloc(ret_block))) diff --git a/compiler/rustc_ast_lowering/src/delegation/mod.rs b/compiler/rustc_ast_lowering/src/delegation/mod.rs index 02fd6de314d3a..0dbb5260e48e2 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::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..f7e869d3892d8 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -7,8 +7,10 @@ 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::LangItem; +use rustc_hir::attrs::target::Target; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::{HirId, Target, find_attr}; +use rustc_hir::{HirId, find_attr}; use rustc_middle::span_bug; use rustc_middle::ty::TyCtxt; use rustc_session::diagnostics::report_lit_error; @@ -717,7 +719,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 +739,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 +838,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 +1037,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 +1068,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 +1079,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 +1099,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 +1141,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 +1445,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 +1460,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 +1495,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 +1512,7 @@ impl<'hir> LoweringContext<'_, 'hir> { ( if matches!( lang_item, - hir::LangItem::RangeInclusiveCopy | hir::LangItem::RangeToInclusiveCopy + LangItem::RangeInclusiveCopy | LangItem::RangeToInclusiveCopy ) { sym::last } else { @@ -1691,7 +1692,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 +1782,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 +1797,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 +1832,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 +1852,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 +1867,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 +1923,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 +1950,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 +2014,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 +2141,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 +2160,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 +2170,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 +2179,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 +2189,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/expr/closure.rs b/compiler/rustc_ast_lowering/src/expr/closure.rs index 32e2e5d40d132..88f9745eed11f 100644 --- a/compiler/rustc_ast_lowering/src/expr/closure.rs +++ b/compiler/rustc_ast_lowering/src/expr/closure.rs @@ -1,7 +1,8 @@ use rustc_ast::node_id::NodeMap; use rustc_ast::*; use rustc_hir as hir; -use rustc_hir::{HirId, Target, find_attr}; +use rustc_hir::attrs::target::Target; +use rustc_hir::{HirId, find_attr}; use rustc_middle::span_bug; use rustc_span::Span; diff --git a/compiler/rustc_ast_lowering/src/format.rs b/compiler/rustc_ast_lowering/src/format.rs index 602635af1324e..4ad123dc80c0e 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::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/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 3cc27be600965..baf749712432a 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -2,10 +2,11 @@ use rustc_abi::ExternAbi; use rustc_ast::visit::AssocCtxt; use rustc_ast::*; use rustc_errors::{E0570, ErrorGuaranteed, struct_span_code_err}; +use rustc_hir::attrs::target::Target; use rustc_hir::attrs::{AttributeKind, EiiImplResolution}; use rustc_hir::def::{DefKind, PerNS, Res}; use rustc_hir::{ - self as hir, CRATE_OWNER_ID, HirId, ImplItemImplKind, LifetimeSource, PredicateOrigin, Target, + self as hir, CRATE_OWNER_ID, HirId, ImplItemImplKind, LifetimeSource, PredicateOrigin, find_attr, }; use rustc_middle::span_bug; diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 7784fc17828aa..0a7997243740a 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -54,13 +54,15 @@ 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::LangItem; +use rustc_hir::attrs::target::Target; 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; use rustc_hir::lints::DelayedLint; use rustc_hir::{ self as hir, AngleBrackets, ConstArg, GenericArg, HirId, ItemLocalMap, LifetimeSource, - LifetimeSyntax, MissingLifetimeKind, ParamName, Target, TraitCandidate, find_attr, + LifetimeSyntax, MissingLifetimeKind, ParamName, TraitCandidate, find_attr, }; use rustc_index::{Idx, IndexVec}; use rustc_macros::extension; @@ -1012,7 +1014,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 +1023,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 +1586,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 +2137,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 +2461,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 +3129,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 +3164,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..b7fa0a8e6a02a 100644 --- a/compiler/rustc_ast_lowering/src/pat.rs +++ b/compiler/rustc_ast_lowering/src/pat.rs @@ -2,8 +2,10 @@ use std::sync::Arc; use rustc_ast::*; use rustc_data_structures::stack::ensure_sufficient_stack; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::attrs::target::Target; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::{self as hir, LangItem, Target}; +use rustc_hir::{self as hir}; use rustc_middle::span_bug; use rustc_span::{DesugaringKind, Ident, Span, Spanned, respan}; @@ -454,7 +456,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 +468,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 +501,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_attr_ir/src/data_structures.rs b/compiler/rustc_attr_ir/src/data_structures.rs index 5fb57606e14fd..dcf0470dbaf40 100644 --- a/compiler/rustc_attr_ir/src/data_structures.rs +++ b/compiler/rustc_attr_ir/src/data_structures.rs @@ -22,7 +22,7 @@ use thin_vec::ThinVec; pub use crate::canonical_symbols::{CanonicalSymbol, CanonicalSymbols}; use crate::diagnostic::*; -use crate::lang_items::LangItem; +use crate::lang::LangItem; use crate::pretty_printing::PrintAttribute; use crate::stability::{DefaultBodyStability, PartialConstStability, Stability}; diff --git a/compiler/rustc_attr_ir/src/lang_items.rs b/compiler/rustc_attr_ir/src/lang.rs similarity index 100% rename from compiler/rustc_attr_ir/src/lang_items.rs rename to compiler/rustc_attr_ir/src/lang.rs diff --git a/compiler/rustc_attr_ir/src/lib.rs b/compiler/rustc_attr_ir/src/lib.rs index 588bcfafb208d..f3d80b0af7e92 100644 --- a/compiler/rustc_attr_ir/src/lib.rs +++ b/compiler/rustc_attr_ir/src/lib.rs @@ -15,23 +15,27 @@ pub use attr::*; pub use data_structures::*; +pub use diagnostic_items::DiagnosticItems; pub use encode_cross_crate::EncodeCrossCrate; -pub use lang_items::*; pub use pretty_printing::PrintAttribute; pub use stability::*; +pub use weak_lang_items::*; + +// Public modules for things that both +// - have a lot of stuff in them +// - are *more* than just attributes +pub mod diagnostic; +pub mod lang; +pub mod target; -// FIXME remove pub on some of these modules? It's fairly inconsistent. mod attr; mod canonical_symbols; mod data_structures; -pub mod diagnostic; -pub mod diagnostic_items; +mod diagnostic_items; mod encode_cross_crate; -pub mod lang_items; mod pretty_printing; mod stability; -pub mod target; -pub mod weak_lang_items; +mod weak_lang_items; /// A trait for types that can provide a list of attributes given a `TyCtxt`. /// diff --git a/compiler/rustc_attr_ir/src/weak_lang_items.rs b/compiler/rustc_attr_ir/src/weak_lang_items.rs index 85b0e3958c2d6..3db8f10bbf80b 100644 --- a/compiler/rustc_attr_ir/src/weak_lang_items.rs +++ b/compiler/rustc_attr_ir/src/weak_lang_items.rs @@ -2,7 +2,7 @@ use rustc_span::{Symbol, sym}; -use crate::LangItem; +use crate::lang::LangItem; macro_rules! weak_lang_items { ($($item:ident, $sym:ident;)*) => { diff --git a/compiler/rustc_attr_parsing/Cargo.toml b/compiler/rustc_attr_parsing/Cargo.toml index 7542cb4bbec26..70161a7961815 100644 --- a/compiler/rustc_attr_parsing/Cargo.toml +++ b/compiler/rustc_attr_parsing/Cargo.toml @@ -8,10 +8,10 @@ edition = "2024" rustc_abi = { path = "../rustc_abi" } rustc_ast = { path = "../rustc_ast" } rustc_ast_pretty = { path = "../rustc_ast_pretty" } +rustc_attr_ir = { path = "../rustc_attr_ir" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_errors = { path = "../rustc_errors" } rustc_feature = { path = "../rustc_feature" } -rustc_hir = { path = "../rustc_hir" } rustc_lexer = { path = "../rustc_lexer" } rustc_lint_defs = { path = "../rustc_lint_defs" } rustc_macros = { path = "../rustc_macros" } diff --git a/compiler/rustc_attr_parsing/src/attributes/autodiff.rs b/compiler/rustc_attr_parsing/src/attributes/autodiff.rs index 78ed4ff46d997..111aca58e424c 100644 --- a/compiler/rustc_attr_parsing/src/attributes/autodiff.rs +++ b/compiler/rustc_attr_parsing/src/attributes/autodiff.rs @@ -2,9 +2,9 @@ use std::str::FromStr; use rustc_ast::LitKind; use rustc_ast::expand::autodiff_attrs::{DiffActivity, DiffMode}; +use rustc_attr_ir::target::{MethodKind, Target}; +use rustc_attr_ir::{AttributeKind, RustcAutodiff}; use rustc_feature::AttributeStability; -use rustc_hir::attrs::{AttributeKind, RustcAutodiff}; -use rustc_hir::{MethodKind, Target}; use rustc_span::{Symbol, sym}; use thin_vec::ThinVec; diff --git a/compiler/rustc_attr_parsing/src/attributes/cfg.rs b/compiler/rustc_attr_parsing/src/attributes/cfg.rs index ef37027f07b96..77f3be494267d 100644 --- a/compiler/rustc_attr_parsing/src/attributes/cfg.rs +++ b/compiler/rustc_attr_parsing/src/attributes/cfg.rs @@ -3,10 +3,10 @@ use std::convert::identity; use rustc_ast::token::Delimiter; use rustc_ast::tokenstream::{DelimSpan, WithTokens}; use rustc_ast::{AttrItem, Attribute, LitKind, ast, token}; +use rustc_attr_ir::target::Target; +use rustc_attr_ir::{AttrPath, CfgEntry, RustcVersion}; use rustc_errors::{Applicability, Diagnostic, PResult, msg}; use rustc_feature::{Features, GatedCfg, find_gated_cfg}; -use rustc_hir::attrs::{CfgEntry, RustcVersion}; -use rustc_hir::{AttrPath, Target}; use rustc_parse::parser::{ForceCollect, Parser, Recovery}; use rustc_parse::{exp, parse_in}; use rustc_session::Session; diff --git a/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs b/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs index 6d2ee2426dd4a..63a289691794b 100644 --- a/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs +++ b/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs @@ -1,11 +1,11 @@ use rustc_ast::token::Token; use rustc_ast::tokenstream::TokenStream; use rustc_ast::{AttrStyle, NodeId, token}; +use rustc_attr_ir::target::Target; +use rustc_attr_ir::{AttrPath, CfgEntry}; use rustc_data_structures::fx::FxHashMap; use rustc_errors::{Diagnostic, MultiSpan}; use rustc_feature::Features; -use rustc_hir::attrs::CfgEntry; -use rustc_hir::{AttrPath, Target}; use rustc_parse::exp; use rustc_parse::parser::{Parser, Recovery}; use rustc_session::Session; diff --git a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs index d9ae0aa0b2307..86d6a6be0ef97 100644 --- a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs @@ -1,8 +1,7 @@ -use rustc_feature::AttributeStability; -use rustc_hir::attrs::{ - CoverageAttrKind, InstrumentFnAttr, OptimizeAttr, RtsanSetting, SanitizerSet, UsedBy, +use rustc_attr_ir::{ + CoverageAttrKind, InstrumentFnAttr, OptimizeAttr, RtsanSetting, SanitizerSet, UsedBy, find_attr, }; -use rustc_hir::find_attr; +use rustc_feature::AttributeStability; use rustc_session::diagnostics::feature_err; use rustc_span::edition::Edition::Edition2024; diff --git a/compiler/rustc_attr_parsing/src/attributes/crate_level.rs b/compiler/rustc_attr_parsing/src/attributes/crate_level.rs index bc8b4a71697e1..d9d93579805c6 100644 --- a/compiler/rustc_attr_parsing/src/attributes/crate_level.rs +++ b/compiler/rustc_attr_parsing/src/attributes/crate_level.rs @@ -1,6 +1,6 @@ +use rustc_attr_ir::{CrateType, WindowsSubsystemKind}; use rustc_data_structures::fx::FxIndexSet; use rustc_feature::AttributeStability; -use rustc_hir::attrs::{CrateType, WindowsSubsystemKind}; use rustc_session::lint::builtin::{DUPLICATE_TOOLS, UNKNOWN_CRATE_TYPES}; use rustc_span::Symbol; use rustc_span::edit_distance::find_best_match_for_name_with_substrings; diff --git a/compiler/rustc_attr_parsing/src/attributes/debugger.rs b/compiler/rustc_attr_parsing/src/attributes/debugger.rs index b514235a48eca..956aafcf5ec7a 100644 --- a/compiler/rustc_attr_parsing/src/attributes/debugger.rs +++ b/compiler/rustc_attr_parsing/src/attributes/debugger.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::{DebugVisualizer, DebuggerVisualizerType}; use rustc_feature::AttributeStability; -use rustc_hir::attrs::{DebugVisualizer, DebuggerVisualizerType}; use super::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/deprecation.rs b/compiler/rustc_attr_parsing/src/attributes/deprecation.rs index 46f99691b602d..cff2f693f89e5 100644 --- a/compiler/rustc_attr_parsing/src/attributes/deprecation.rs +++ b/compiler/rustc_attr_parsing/src/attributes/deprecation.rs @@ -1,7 +1,6 @@ use rustc_ast::LitKind; +use rustc_attr_ir::{DeprecatedSince, Deprecation, RustcVersion, VERSION_PLACEHOLDER}; use rustc_feature::AttributeStability; -use rustc_hir::VERSION_PLACEHOLDER; -use rustc_hir::attrs::{DeprecatedSince, Deprecation, RustcVersion}; use super::prelude::*; use super::util::parse_version; diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/do_not_recommend.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/do_not_recommend.rs index 250326db42bb7..868c77517052a 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/do_not_recommend.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/do_not_recommend.rs @@ -1,6 +1,6 @@ +use rustc_attr_ir::AttributeKind; +use rustc_attr_ir::target::Target; use rustc_feature::AttributeStability; -use rustc_hir::Target; -use rustc_hir::attrs::AttributeKind; use rustc_session::lint::builtin::MALFORMED_DIAGNOSTIC_ATTRIBUTES; use rustc_span::{Symbol, sym}; diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs index a813e0ba02a89..60d80310b0f85 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/mod.rs @@ -1,11 +1,11 @@ use std::ops::Range; use rustc_ast::PathSegment; -use rustc_errors::{Diagnostic, MultiSpan}; -use rustc_hir::attrs::diagnostic::{ +use rustc_attr_ir::diagnostic::{ Directive, Filter, FilterFormatString, Flag, FormatArg, FormatString, LitOrArg, Name, NameValue, Piece, Predicate, }; +use rustc_errors::{Diagnostic, MultiSpan}; use rustc_lint_defs::LintId; use rustc_parse_format::{ Argument, FormatSpec, ParseError, ParseMode, Parser, Piece as RpfPiece, Position, diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_const.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_const.rs index f92a7694ec357..61ebe13bfb98d 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_const.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_const.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::diagnostic::Directive; use rustc_feature::AttributeStability; -use rustc_hir::attrs::diagnostic::Directive; use crate::attributes::diagnostic::*; use crate::attributes::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_move.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_move.rs index dcba5d5b301a6..9f8e120353c7f 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_move.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_move.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::AttributeKind; use rustc_feature::AttributeStability; -use rustc_hir::attrs::AttributeKind; use rustc_span::sym; use crate::attributes::diagnostic::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_type_error.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_type_error.rs index 1bdde3af7f0eb..ea980c7da0cd5 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_type_error.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_type_error.rs @@ -1,4 +1,4 @@ -use rustc_hir::attrs::AttributeKind; +use rustc_attr_ir::AttributeKind; use rustc_span::sym; use crate::attributes::AttributeStability; diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unimplemented.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unimplemented.rs index bd82a532c1c3c..9975b2795be4f 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unimplemented.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unimplemented.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::diagnostic::Directive; use rustc_feature::AttributeStability; -use rustc_hir::attrs::diagnostic::Directive; use crate::attributes::diagnostic::*; use crate::attributes::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unknown.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unknown.rs index 029d971910e5e..58e2d37f7cdaf 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unknown.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unknown.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::diagnostic::Directive; use rustc_feature::AttributeStability; -use rustc_hir::attrs::diagnostic::Directive; use crate::attributes::diagnostic::*; use crate::attributes::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unmatched_args.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unmatched_args.rs index 41ed6df43063e..14918b26e8dc2 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unmatched_args.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unmatched_args.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::diagnostic::Directive; use rustc_feature::AttributeStability; -use rustc_hir::attrs::diagnostic::Directive; use crate::attributes::diagnostic::*; use crate::attributes::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/opaque.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/opaque.rs index 0864b76f0e030..d29c2ee654d20 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/opaque.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/opaque.rs @@ -1,6 +1,6 @@ +use rustc_attr_ir::AttributeKind; +use rustc_attr_ir::target::Target; use rustc_feature::AttributeStability; -use rustc_hir::Target; -use rustc_hir::attrs::AttributeKind; use rustc_session::lint::builtin::MALFORMED_DIAGNOSTIC_ATTRIBUTES; use rustc_span::{Span, sym}; diff --git a/compiler/rustc_attr_parsing/src/attributes/doc.rs b/compiler/rustc_attr_parsing/src/attributes/doc.rs index cba00f5f068a6..fc3a279513c25 100644 --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs @@ -1,12 +1,12 @@ use rustc_ast::ast::{AttrStyle, LitKind, MetaItemLit}; -use rustc_data_structures::fx::{FxHashSet, FxIndexMap, IndexEntry}; -use rustc_errors::{Applicability, msg}; -use rustc_feature::AttributeStability; -use rustc_hir::Target; -use rustc_hir::attrs::{ +use rustc_attr_ir::target::Target; +use rustc_attr_ir::{ AttributeKind, CfgEntry, CfgHideShow, DocAttribute, DocCfgHideShow, DocCfgHideShowValue, DocInline, HideOrShow, }; +use rustc_data_structures::fx::{FxHashSet, FxIndexMap, IndexEntry}; +use rustc_errors::{Applicability, msg}; +use rustc_feature::AttributeStability; use rustc_session::diagnostics::feature_err; use rustc_span::{Span, Symbol, edition, sym}; diff --git a/compiler/rustc_attr_parsing/src/attributes/dummy.rs b/compiler/rustc_attr_parsing/src/attributes/dummy.rs index 425637b694e98..fec42f43d035a 100644 --- a/compiler/rustc_attr_parsing/src/attributes/dummy.rs +++ b/compiler/rustc_attr_parsing/src/attributes/dummy.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::AttributeKind; use rustc_feature::AttributeStability; -use rustc_hir::attrs::AttributeKind; use rustc_span::{Symbol, sym}; use crate::attributes::{OnDuplicate, SingleAttributeParser}; diff --git a/compiler/rustc_attr_parsing/src/attributes/inline.rs b/compiler/rustc_attr_parsing/src/attributes/inline.rs index 52960ae220a59..68b68a5e5945b 100644 --- a/compiler/rustc_attr_parsing/src/attributes/inline.rs +++ b/compiler/rustc_attr_parsing/src/attributes/inline.rs @@ -1,6 +1,5 @@ +use rustc_attr_ir::{AttributeKind, InlineAttr, find_attr}; use rustc_feature::AttributeStability; -use rustc_hir::attrs::{AttributeKind, InlineAttr}; -use rustc_hir::find_attr; use rustc_session::lint::builtin::ILL_FORMED_ATTRIBUTE_INPUT; use super::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs b/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs index 3a4bb926f759c..a38f2f5acf49f 100644 --- a/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs +++ b/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::InstructionSetAttr; use rustc_feature::AttributeStability; -use rustc_hir::attrs::InstructionSetAttr; use super::prelude::*; use crate::session_diagnostics; diff --git a/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs index 935265924d7da..3b361ce8d3dec 100644 --- a/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/link_attrs.rs @@ -1,7 +1,7 @@ +use rustc_attr_ir::AttributeKind::{LinkName, LinkOrdinal, LinkSection}; +use rustc_attr_ir::*; use rustc_errors::msg; use rustc_feature::{AttributeStability, Features}; -use rustc_hir::attrs::AttributeKind::{LinkName, LinkOrdinal, LinkSection}; -use rustc_hir::attrs::*; use rustc_session::Session; use rustc_session::diagnostics::feature_err; use rustc_session::lint::builtin::ILL_FORMED_ATTRIBUTE_INPUT; diff --git a/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs b/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs index 8011beb05546f..afe1cbd402c8f 100644 --- a/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs +++ b/compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs @@ -1,6 +1,5 @@ +use rustc_attr_ir::{ReprAttr, find_attr}; use rustc_feature::AttributeStability; -use rustc_hir::attrs::ReprAttr; -use rustc_hir::find_attr; use super::prelude::*; use crate::session_diagnostics::RustcPubTransparent; diff --git a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs index 3dec77d3a3550..b5f999bc23a8e 100644 --- a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs @@ -1,6 +1,5 @@ +use rustc_attr_ir::{CollapseMacroDebuginfo, MacroUseArgs, find_attr}; use rustc_feature::AttributeStability; -use rustc_hir::attrs::{CollapseMacroDebuginfo, MacroUseArgs}; -use rustc_hir::find_attr; use rustc_session::lint::builtin::INVALID_MACRO_EXPORT_ARGUMENTS; use super::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/mod.rs b/compiler/rustc_attr_parsing/src/attributes/mod.rs index 1f88d2ab95e9b..fcdfbd26c987e 100644 --- a/compiler/rustc_attr_parsing/src/attributes/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/mod.rs @@ -20,8 +20,8 @@ use std::marker::PhantomData; +use rustc_attr_ir::AttributeKind; use rustc_feature::AttributeStability; -use rustc_hir::attrs::AttributeKind; use rustc_span::edition::Edition; use rustc_span::{Span, Symbol}; use thin_vec::ThinVec; diff --git a/compiler/rustc_attr_parsing/src/attributes/non_exhaustive.rs b/compiler/rustc_attr_parsing/src/attributes/non_exhaustive.rs index cbbaad445f70f..48e97784a2286 100644 --- a/compiler/rustc_attr_parsing/src/attributes/non_exhaustive.rs +++ b/compiler/rustc_attr_parsing/src/attributes/non_exhaustive.rs @@ -1,6 +1,6 @@ +use rustc_attr_ir::AttributeKind; +use rustc_attr_ir::target::Target; use rustc_feature::AttributeStability; -use rustc_hir::Target; -use rustc_hir::attrs::AttributeKind; use rustc_span::{Span, Symbol, sym}; use crate::attributes::{NoArgsAttributeParser, OnDuplicate}; diff --git a/compiler/rustc_attr_parsing/src/attributes/pin_v2.rs b/compiler/rustc_attr_parsing/src/attributes/pin_v2.rs index 59c35690d3c93..acd64b0c7be39 100644 --- a/compiler/rustc_attr_parsing/src/attributes/pin_v2.rs +++ b/compiler/rustc_attr_parsing/src/attributes/pin_v2.rs @@ -1,6 +1,6 @@ +use rustc_attr_ir::AttributeKind; +use rustc_attr_ir::target::Target; use rustc_feature::AttributeStability; -use rustc_hir::Target; -use rustc_hir::attrs::AttributeKind; use rustc_span::{Span, Symbol, sym}; use crate::attributes::NoArgsAttributeParser; diff --git a/compiler/rustc_attr_parsing/src/attributes/prelude.rs b/compiler/rustc_attr_parsing/src/attributes/prelude.rs index 744d5368580d8..0721d6f1926ae 100644 --- a/compiler/rustc_attr_parsing/src/attributes/prelude.rs +++ b/compiler/rustc_attr_parsing/src/attributes/prelude.rs @@ -1,8 +1,8 @@ // data structures #[doc(hidden)] -pub(super) use rustc_hir::attrs::AttributeKind; +pub(super) use rustc_attr_ir::AttributeKind; #[doc(hidden)] -pub(super) use rustc_hir::{MethodKind, Target}; +pub(super) use rustc_attr_ir::target::{MethodKind, Target}; #[doc(hidden)] pub(super) use rustc_span::{Ident, Span, Symbol, sym}; #[doc(hidden)] diff --git a/compiler/rustc_attr_parsing/src/attributes/prototype.rs b/compiler/rustc_attr_parsing/src/attributes/prototype.rs index a41010395e7c1..527cf9dd151bd 100644 --- a/compiler/rustc_attr_parsing/src/attributes/prototype.rs +++ b/compiler/rustc_attr_parsing/src/attributes/prototype.rs @@ -1,8 +1,8 @@ //! Attributes that are only used on function prototypes. +use rustc_attr_ir::target::Target; +use rustc_attr_ir::{AttributeKind, MirDialect, MirPhase}; use rustc_feature::AttributeStability; -use rustc_hir::Target; -use rustc_hir::attrs::{AttributeKind, MirDialect, MirPhase}; use rustc_span::{Span, Symbol, sym}; use crate::attributes::SingleAttributeParser; diff --git a/compiler/rustc_attr_parsing/src/attributes/repr.rs b/compiler/rustc_attr_parsing/src/attributes/repr.rs index bb0da73df015c..9ebd64c08f10f 100644 --- a/compiler/rustc_attr_parsing/src/attributes/repr.rs +++ b/compiler/rustc_attr_parsing/src/attributes/repr.rs @@ -1,8 +1,8 @@ use rustc_abi::{Align, Size}; use rustc_ast::{IntTy, LitIntType, LitKind, UintTy}; +use rustc_attr_ir::IntType::{SignedInt, UnsignedInt}; +use rustc_attr_ir::ReprAttr; use rustc_feature::AttributeStability; -use rustc_hir::attrs::IntType::{SignedInt, UnsignedInt}; -use rustc_hir::attrs::ReprAttr; use rustc_session::diagnostics::feature_err; use super::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs index e20d4585925c3..975013ba065d4 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs @@ -1,6 +1,6 @@ +use rustc_attr_ir::target::{MethodKind, Target}; +use rustc_attr_ir::{AttributeKind, RustcDumpLayoutKind}; use rustc_feature::AttributeStability; -use rustc_hir::attrs::{AttributeKind, RustcDumpLayoutKind}; -use rustc_hir::{MethodKind, Target}; use rustc_span::{Span, Symbol, sym}; use super::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index b101d378bab98..63a168e257e9e 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -1,14 +1,14 @@ use std::path::PathBuf; use rustc_ast::{LitIntType, LitKind, MetaItemLit}; -use rustc_data_structures::fx::FxHashMap; -use rustc_feature::AttributeStability; -use rustc_hir::LangItem; -use rustc_hir::attrs::{ +use rustc_attr_ir::lang::LangItem; +use rustc_attr_ir::target::GenericParamKind; +use rustc_attr_ir::{ BorrowckGraphvizFormatKind, CguFields, CguKind, DivergingBlockBehavior, DivergingFallbackBehavior, RustcCleanAttribute, RustcCleanQueries, RustcMirKind, }; -use rustc_hir::target::GenericParamKind; +use rustc_data_structures::fx::FxHashMap; +use rustc_feature::AttributeStability; use rustc_span::Symbol; use super::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/semantics.rs b/compiler/rustc_attr_parsing/src/attributes/semantics.rs index fa19d51c397eb..7a8475c12eada 100644 --- a/compiler/rustc_attr_parsing/src/attributes/semantics.rs +++ b/compiler/rustc_attr_parsing/src/attributes/semantics.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::target::GenericParamKind; use rustc_feature::AttributeStability; -use rustc_hir::target::GenericParamKind; use super::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/stability.rs b/compiler/rustc_attr_parsing/src/attributes/stability.rs index 62f16d9719d23..3962fa2fecc56 100644 --- a/compiler/rustc_attr_parsing/src/attributes/stability.rs +++ b/compiler/rustc_attr_parsing/src/attributes/stability.rs @@ -1,13 +1,12 @@ use std::num::NonZero; +use rustc_attr_ir::target::{GenericParamKind, MethodKind, Target}; +use rustc_attr_ir::{ + DefaultBodyStability, PartialConstStability, Stability, StabilityLevel, StableSince, + UnstableReason, UnstableRemovedFeature, VERSION_PLACEHOLDER, +}; use rustc_errors::ErrorGuaranteed; use rustc_feature::{ACCEPTED_LANG_FEATURES, AttributeStability}; -use rustc_hir::attrs::UnstableRemovedFeature; -use rustc_hir::target::GenericParamKind; -use rustc_hir::{ - DefaultBodyStability, MethodKind, PartialConstStability, Stability, StabilityLevel, - StableSince, Target, UnstableReason, VERSION_PLACEHOLDER, -}; use super::prelude::*; use super::util::parse_version; diff --git a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs index 780b9e185b0ed..22dd77ce45737 100644 --- a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::RustcAbiAttrKind; use rustc_feature::AttributeStability; -use rustc_hir::attrs::RustcAbiAttrKind; use rustc_session::lint::builtin::ILL_FORMED_ATTRIBUTE_INPUT; use super::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/unroll.rs b/compiler/rustc_attr_parsing/src/attributes/unroll.rs index 5a49feca2a1ea..2626adb24ec9d 100644 --- a/compiler/rustc_attr_parsing/src/attributes/unroll.rs +++ b/compiler/rustc_attr_parsing/src/attributes/unroll.rs @@ -1,6 +1,6 @@ use rustc_ast::{LitIntType, LitKind}; +use rustc_attr_ir::UnrollAttr; use rustc_feature::AttributeStability; -use rustc_hir::attrs::UnrollAttr; use super::prelude::*; diff --git a/compiler/rustc_attr_parsing/src/attributes/util.rs b/compiler/rustc_attr_parsing/src/attributes/util.rs index 7969d1bb9ce2c..130ca330e5527 100644 --- a/compiler/rustc_attr_parsing/src/attributes/util.rs +++ b/compiler/rustc_attr_parsing/src/attributes/util.rs @@ -1,9 +1,9 @@ use std::num::IntErrorKind; use rustc_ast::{LitKind, ast}; +use rustc_attr_ir::RustcVersion; use rustc_data_structures::Limit; use rustc_feature::is_builtin_attr_name; -use rustc_hir::attrs::RustcVersion; use rustc_span::Symbol; use crate::context::AcceptContext; diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 55732edfbd166..c57d576d2dcbb 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -9,11 +9,11 @@ use std::sync::LazyLock; use std::sync::atomic::{AtomicBool, Ordering}; use rustc_ast::{AttrStyle, MetaItemLit, Safety}; +use rustc_attr_ir::target::Target; +use rustc_attr_ir::{AttrPath, Attribute, AttributeKind}; use rustc_data_structures::sync::{DynSend, DynSync}; use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level, MultiSpan}; use rustc_feature::AttributeStability; -use rustc_hir::attrs::AttributeKind; -use rustc_hir::{AttrPath, Attribute}; use rustc_parse::parser::Recovery; use rustc_session::Session; use rustc_session::lint::{Lint, LintId}; @@ -775,7 +775,7 @@ pub struct SharedContext<'p, 'sess> { pub(crate) cx: &'p mut AttributeParser<'sess>, /// The span of the syntactical component this attribute was applied to pub(crate) target_span: Span, - pub(crate) target: rustc_hir::Target, + pub(crate) target: Target, pub(crate) emit_lint: &'p mut dyn FnMut(LintId, MultiSpan, EmitAttribute), diff --git a/compiler/rustc_attr_parsing/src/diagnostics.rs b/compiler/rustc_attr_parsing/src/diagnostics.rs index 1e76ab44826a9..5dc716f05dc58 100644 --- a/compiler/rustc_attr_parsing/src/diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/diagnostics.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::AttrPath; use rustc_errors::{Applicability, DiagArgValue, E0264, MultiSpan}; -use rustc_hir::AttrPath; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{Ident, Span, Symbol}; diff --git a/compiler/rustc_attr_parsing/src/interface.rs b/compiler/rustc_attr_parsing/src/interface.rs index 73108e42d5ab5..c18149ae48e09 100644 --- a/compiler/rustc_attr_parsing/src/interface.rs +++ b/compiler/rustc_attr_parsing/src/interface.rs @@ -6,11 +6,11 @@ use std::sync::atomic::{AtomicBool, Ordering}; use rustc_ast as ast; use rustc_ast::token::DocFragmentKind; use rustc_ast::{AttrStyle, CRATE_NODE_ID, NodeId, Safety}; +use rustc_attr_ir::target::Target; +use rustc_attr_ir::{AttrArgs, AttrItem, AttrPath, Attribute, AttributeKind, HashIgnoredAttrId}; use rustc_data_structures::sync::{DynSend, DynSync}; use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level, MultiSpan}; use rustc_feature::{BUILTIN_ATTRIBUTE_MAP, Features}; -use rustc_hir::attrs::AttributeKind; -use rustc_hir::{AttrArgs, AttrItem, AttrPath, Attribute, HashIgnoredAttrId, Target}; use rustc_lint_defs::RegisteredTools; use rustc_session::Session; use rustc_session::lint::LintId; diff --git a/compiler/rustc_attr_parsing/src/lib.rs b/compiler/rustc_attr_parsing/src/lib.rs index bcdb401bc08c3..682103d95a2b7 100644 --- a/compiler/rustc_attr_parsing/src/lib.rs +++ b/compiler/rustc_attr_parsing/src/lib.rs @@ -2,12 +2,12 @@ //! //! ## Architecture //! This crate is part of a series of crates and modules that handle attribute processing. -//! - [`rustc_hir::attrs`]: Defines the data structures that store parsed attributes +//! - [`rustc_attr_ir`]: Defines the data structures that store parsed attributes //! - `rustc_attr_parsing`: This crate, handles the parsing of attributes //! - [`rustc_passes::check_attr`] handles attribute validation that cannot be done in this crate //! //! The separation between data structures and parsing follows the principle of separation of concerns. -//! Data structures (`rustc_hir::attrs`) define what attributes look like after parsing. +//! Data structures (`rustc_attr_ir`) define what attributes look like after parsing. //! This crate (`rustc_attr_parsing`) handles how to convert raw tokens into those structures. //! This split allows other parts of the compiler to use the data structures without needing //! the parsing logic, making the codebase more modular and maintainable. @@ -62,7 +62,7 @@ //! a "stability" of an item. So, the stability attribute has an //! [`AttributeParser`](attributes::AttributeParser) that recognizes both the `#[stable()]` //! and `#[unstable()]` syntactic attributes, and at the end produces a single -//! [`AttributeKind::Stability`](rustc_hir::attrs::AttributeKind::Stability). +//! [`AttributeKind::Stability`](rustc_attr_ir::AttributeKind::Stability). //! //! When multiple instances of the same attribute are allowed, they're combined into a single //! semantic attribute. For example: diff --git a/compiler/rustc_attr_parsing/src/parser.rs b/compiler/rustc_attr_parsing/src/parser.rs index 5f1fc8ba90d5e..4c16029f611f3 100644 --- a/compiler/rustc_attr_parsing/src/parser.rs +++ b/compiler/rustc_attr_parsing/src/parser.rs @@ -19,8 +19,8 @@ use rustc_ast::{ AttrArgs, Expr, ExprKind, LitKind, MetaItemLit, Path, PathSegment, StmtKind, UnOp, }; use rustc_ast_pretty::pprust; +use rustc_attr_ir::AttrPath; use rustc_errors::{Applicability, Diag, PResult}; -use rustc_hir::{self as hir, AttrPath}; use rustc_parse::exp; use rustc_parse::parser::{ForceCollect, Parser, PathStyle, Recovery, token_descr}; use rustc_session::diagnostics::create_lit_error; @@ -41,7 +41,7 @@ pub type OwnedPathParser = PathParser; pub type RefPathParser<'p> = PathParser<&'p Path>; impl> PathParser

{ - pub fn get_attribute_path(&self) -> hir::AttrPath { + pub fn get_attribute_path(&self) -> AttrPath { AttrPath { segments: self.segments().map(|s| s.name).collect::>().into_boxed_slice(), span: self.span(), diff --git a/compiler/rustc_attr_parsing/src/safety.rs b/compiler/rustc_attr_parsing/src/safety.rs index 5b3d52c18aae1..313f9513e873e 100644 --- a/compiler/rustc_attr_parsing/src/safety.rs +++ b/compiler/rustc_attr_parsing/src/safety.rs @@ -1,6 +1,6 @@ use rustc_ast::Safety; +use rustc_attr_ir::AttrPath; use rustc_errors::{Diagnostic, MultiSpan}; -use rustc_hir::AttrPath; use rustc_lint_defs::builtin::UNSAFE_CODE; use rustc_session::lint::LintId; use rustc_session::lint::builtin::UNSAFE_ATTR_OUTSIDE_UNSAFE; diff --git a/compiler/rustc_attr_parsing/src/session_diagnostics.rs b/compiler/rustc_attr_parsing/src/session_diagnostics.rs index b7c7b39bcb48b..5cf796127dd36 100644 --- a/compiler/rustc_attr_parsing/src/session_diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/session_diagnostics.rs @@ -1,11 +1,10 @@ use std::num::IntErrorKind; +use rustc_attr_ir::{AttrPath, MirDialect, MirPhase}; use rustc_errors::codes::*; use rustc_errors::{ Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, }; -use rustc_hir::AttrPath; -use rustc_hir::attrs::{MirDialect, MirPhase}; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{Span, Symbol}; use rustc_target::spec::TargetTuple; diff --git a/compiler/rustc_attr_parsing/src/stability.rs b/compiler/rustc_attr_parsing/src/stability.rs index 5fe86a4a3e569..b0ab2649c4078 100644 --- a/compiler/rustc_attr_parsing/src/stability.rs +++ b/compiler/rustc_attr_parsing/src/stability.rs @@ -1,5 +1,5 @@ +use rustc_attr_ir::AttrPath; use rustc_feature::AttributeStability; -use rustc_hir::AttrPath; use rustc_session::diagnostics::feature_err; use rustc_span::{Span, sym}; diff --git a/compiler/rustc_attr_parsing/src/synthetic.rs b/compiler/rustc_attr_parsing/src/synthetic.rs index 290730aaee132..adf69b8912382 100644 --- a/compiler/rustc_attr_parsing/src/synthetic.rs +++ b/compiler/rustc_attr_parsing/src/synthetic.rs @@ -1,7 +1,6 @@ use rustc_ast::SyntheticAttr; use rustc_ast::attr::data_structures::CfgEntry; -use rustc_hir::Attribute; -use rustc_hir::attrs::AttributeKind; +use rustc_attr_ir::{Attribute, AttributeKind}; use rustc_span::Span; use thin_vec::ThinVec; diff --git a/compiler/rustc_attr_parsing/src/target_checking.rs b/compiler/rustc_attr_parsing/src/target_checking.rs index 6b0d1b094ca0f..8a921190b988d 100644 --- a/compiler/rustc_attr_parsing/src/target_checking.rs +++ b/compiler/rustc_attr_parsing/src/target_checking.rs @@ -1,10 +1,10 @@ use std::borrow::Cow; use rustc_ast::{AttrStyle, Safety}; +use rustc_attr_ir::target::{GenericParamKind, MethodKind, Target}; +use rustc_attr_ir::{AttrItem, Attribute, AttributeKind}; use rustc_errors::{DiagArgValue, MultiSpan, StashKey}; use rustc_feature::Features; -use rustc_hir::attrs::AttributeKind; -use rustc_hir::{AttrItem, Attribute, MethodKind, Target}; use rustc_span::{BytePos, FileName, RemapPathScopeComponents, Span, Symbol, sym}; use crate::context::AcceptContext; @@ -525,30 +525,12 @@ pub(crate) const ALL_TARGETS: &[Policy] = { Allow(Target::Crate), Allow(Target::Delegation { mac: false }), Allow(Target::Delegation { mac: true }), - Allow(Target::GenericParam { - kind: rustc_hir::target::GenericParamKind::Const, - has_default: false, - }), - Allow(Target::GenericParam { - kind: rustc_hir::target::GenericParamKind::Const, - has_default: true, - }), - Allow(Target::GenericParam { - kind: rustc_hir::target::GenericParamKind::Lifetime, - has_default: false, - }), - Allow(Target::GenericParam { - kind: rustc_hir::target::GenericParamKind::Lifetime, - has_default: true, - }), - Allow(Target::GenericParam { - kind: rustc_hir::target::GenericParamKind::Type, - has_default: false, - }), - Allow(Target::GenericParam { - kind: rustc_hir::target::GenericParamKind::Type, - has_default: true, - }), + Allow(Target::GenericParam { kind: GenericParamKind::Const, has_default: false }), + Allow(Target::GenericParam { kind: GenericParamKind::Const, has_default: true }), + Allow(Target::GenericParam { kind: GenericParamKind::Lifetime, has_default: false }), + Allow(Target::GenericParam { kind: GenericParamKind::Lifetime, has_default: true }), + Allow(Target::GenericParam { kind: GenericParamKind::Type, has_default: false }), + Allow(Target::GenericParam { kind: GenericParamKind::Type, has_default: true }), Allow(Target::Loop), Allow(Target::ForLoop), Allow(Target::While), diff --git a/compiler/rustc_attr_parsing/src/validate_attr.rs b/compiler/rustc_attr_parsing/src/validate_attr.rs index 08c73352f27eb..a125a36b30a47 100644 --- a/compiler/rustc_attr_parsing/src/validate_attr.rs +++ b/compiler/rustc_attr_parsing/src/validate_attr.rs @@ -9,9 +9,9 @@ use rustc_ast::{ self as ast, AttrArgs, AttrKind, Attribute, DelimArgs, MetaItem, MetaItemInner, MetaItemKind, Safety, }; +use rustc_attr_ir::AttrPath; use rustc_errors::{Applicability, Diagnostic, PResult}; use rustc_feature::BUILTIN_ATTRIBUTE_MAP; -use rustc_hir::AttrPath; use rustc_parse::parse_in; use rustc_session::diagnostics::report_lit_error; use rustc_session::lint::builtin::ILL_FORMED_ATTRIBUTE_INPUT; diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index d40f611150233..c04baf562f258 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::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..69bde56991273 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::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..00c5e7dadd2fd 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::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..213d13c58a183 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::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..97aa5edf22c73 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::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_builtin_macros/src/cfg.rs b/compiler/rustc_builtin_macros/src/cfg.rs index f2771f125ff54..8750424ae537c 100644 --- a/compiler/rustc_builtin_macros/src/cfg.rs +++ b/compiler/rustc_builtin_macros/src/cfg.rs @@ -10,8 +10,8 @@ use rustc_attr_parsing::{ parse_cfg_entry, }; use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult}; -use rustc_hir::attrs::CfgEntry; -use rustc_hir::{AttrPath, Target}; +use rustc_hir::attrs::target::Target; +use rustc_hir::attrs::{AttrPath, CfgEntry}; use rustc_parse::exp; use rustc_parse::parser::Recovery; use rustc_span::{ErrorGuaranteed, Span, sym}; diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs index d57f662fc1938..49c8deacb2814 100644 --- a/compiler/rustc_codegen_cranelift/src/base.rs +++ b/compiler/rustc_codegen_cranelift/src/base.rs @@ -390,7 +390,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) { codegen_panic_inner( fx, - rustc_hir::LangItem::PanicBoundsCheck, + rustc_hir::attrs::lang::LangItem::PanicBoundsCheck, &[index, len, location], *unwind, source_info.span, @@ -403,7 +403,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) { codegen_panic_inner( fx, - rustc_hir::LangItem::PanicMisalignedPointerDereference, + rustc_hir::attrs::lang::LangItem::PanicMisalignedPointerDereference, &[required, found, location], *unwind, source_info.span, @@ -414,7 +414,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) { codegen_panic_inner( fx, - rustc_hir::LangItem::PanicNullPointerDereference, + rustc_hir::attrs::lang::LangItem::PanicNullPointerDereference, &[location], *unwind, source_info.span, @@ -425,7 +425,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) { codegen_panic_inner( fx, - rustc_hir::LangItem::PanicNullReferenceConstructed, + rustc_hir::attrs::lang::LangItem::PanicNullReferenceConstructed, &[location], *unwind, source_info.span, @@ -437,7 +437,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) { codegen_panic_inner( fx, - rustc_hir::LangItem::PanicInvalidEnumConstruction, + rustc_hir::attrs::lang::LangItem::PanicInvalidEnumConstruction, &[source, location], *unwind, source_info.span, @@ -1082,7 +1082,7 @@ pub(crate) fn codegen_panic_nounwind<'tcx>( codegen_panic_inner( fx, - rustc_hir::LangItem::PanicNounwind, + rustc_hir::attrs::lang::LangItem::PanicNounwind, &args, UnwindAction::Terminate(UnwindTerminateReason::Abi), span, @@ -1099,7 +1099,7 @@ pub(crate) fn codegen_unwind_terminate<'tcx>( fn codegen_panic_inner<'tcx>( fx: &mut FunctionCx<'_, '_, 'tcx>, - lang_item: rustc_hir::LangItem, + lang_item: rustc_hir::attrs::lang::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..b774b245f0d36 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::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..b2351ea478b43 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::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..4fb44fc810249 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::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_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index 40ff5fa58de69..0f69ea00a9f40 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -13,10 +13,11 @@ 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::LangItem; +use rustc_hir::attrs::target::Target; 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_hir::{ItemId, find_attr}; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile; use rustc_middle::middle::dependency_format::{Dependencies, Linkage}; diff --git a/compiler/rustc_codegen_ssa/src/common.rs b/compiler/rustc_codegen_ssa/src/common.rs index 777f3f6b53fd4..3c39c71053f17 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::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..cda3e7480634e 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::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..184fb707208f9 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::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..3ddeca60b7e6d 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::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..2f95d22c2f326 100644 --- a/compiler/rustc_const_eval/src/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/check_consts/check.rs @@ -6,9 +6,11 @@ use std::ops::Deref; use std::{assert_matches, mem}; use rustc_errors::{Diag, ErrorGuaranteed}; +use rustc_hir as hir; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::attrs::{self, find_attr}; use rustc_hir::def::DefKind; use rustc_hir::def_id::DefId; -use rustc_hir::{self as hir, LangItem, find_attr}; use rustc_index::bit_set::DenseBitSet; use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::mir::visit::Visitor; @@ -465,7 +467,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> { /// Check the const stability of the given item (fn or trait). fn check_callee_stability(&mut self, def_id: DefId) { match self.tcx.lookup_const_stability(def_id) { - Some(hir::ConstStability { level: hir::StabilityLevel::Stable { .. }, .. }) => { + Some(attrs::ConstStability { level: attrs::StabilityLevel::Stable { .. }, .. }) => { // All good. } None => { @@ -481,8 +483,8 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> { }); } } - Some(hir::ConstStability { - level: hir::StabilityLevel::Unstable { implied_by: implied_feature, issue, .. }, + Some(attrs::ConstStability { + level: attrs::StabilityLevel::Unstable { implied_by: implied_feature, issue, .. }, feature, .. }) => { @@ -890,8 +892,8 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { }); } } - Some(hir::ConstStability { - level: hir::StabilityLevel::Unstable { .. }, + Some(attrs::ConstStability { + level: attrs::StabilityLevel::Unstable { .. }, feature, .. }) => { @@ -910,8 +912,8 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { const_stable_indirect: is_const_stable, }); } - Some(hir::ConstStability { - level: hir::StabilityLevel::Stable { .. }, + Some(attrs::ConstStability { + level: attrs::StabilityLevel::Stable { .. }, .. }) => { // All good. Note that a `#[rustc_const_stable]` intrinsic (meaning it diff --git a/compiler/rustc_const_eval/src/check_consts/ops.rs b/compiler/rustc_const_eval/src/check_consts/ops.rs index 76c0c5f0d3bdf..a9f46dc91cfb9 100644 --- a/compiler/rustc_const_eval/src/check_consts/ops.rs +++ b/compiler/rustc_const_eval/src/check_consts/ops.rs @@ -1,6 +1,7 @@ //! Concrete error types for all operations which may be invalid in a certain const context. -use hir::{ConstContext, LangItem}; +use hir::ConstContext; +use hir::attrs::lang::LangItem; use rustc_errors::codes::*; use rustc_errors::{Applicability, Diag, MultiSpan, msg}; use rustc_hir as hir; diff --git a/compiler/rustc_const_eval/src/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/check_consts/qualifs.rs index fa54d1ed4e562..374ed0e732a48 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::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..724425f11cc9c 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::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..b160f1a0073e1 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::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/util/caller_location.rs b/compiler/rustc_const_eval/src/util/caller_location.rs index 18464df1e03f1..e6fbd586b9118 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::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_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index f15b005960c9f..6a7859c343cff 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -15,9 +15,8 @@ use rustc_data_structures::{Limit, sync}; use rustc_errors::{BufferedEarlyLint, DiagCtxtHandle, ErrorGuaranteed, PResult}; use rustc_feature::Features; use rustc_hir as hir; -use rustc_hir::attrs::{CfgEntry, CollapseMacroDebuginfo, Deprecation}; +use rustc_hir::attrs::{CfgEntry, CollapseMacroDebuginfo, Deprecation, Stability, find_attr}; use rustc_hir::def::MacroKinds; -use rustc_hir::{Stability, find_attr}; use rustc_lint_defs::RegisteredTools; use rustc_parse::MACRO_ARGUMENTS; use rustc_parse::parser::Parser; diff --git a/compiler/rustc_expand/src/config.rs b/compiler/rustc_expand/src/config.rs index af017bea67697..15a2ece0b068d 100644 --- a/compiler/rustc_expand/src/config.rs +++ b/compiler/rustc_expand/src/config.rs @@ -23,9 +23,8 @@ use rustc_feature::{ UNSTABLE_LANG_FEATURES, }; use rustc_hir::attrs::AttributeKind; -use rustc_hir::{ - Target, {self as hir}, -}; +use rustc_hir::attrs::target::Target; +use rustc_hir::{self as hir}; use rustc_parse::parser::Recovery; use rustc_session::Session; use rustc_session::diagnostics::feature_err; diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index c80ffe625f248..f568a0312bb16 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -23,7 +23,7 @@ use rustc_data_structures::flat_map_in_place::FlatMapInPlace; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_errors::PResult; use rustc_feature::Features; -use rustc_hir::Target; +use rustc_hir::attrs::target::Target; use rustc_hir::def::MacroKinds; use rustc_parse::parser::{ AllowConstBlockItems, AttemptLocalParseRecovery, CommaRecoveryMode, ForceCollect, Parser, @@ -1716,15 +1716,15 @@ impl InvocationCollectorNode for ast::GenericParam { Target::GenericParam { kind: match &self.kind { rustc_ast::GenericParamKind::Lifetime => { - rustc_hir::target::GenericParamKind::Lifetime + rustc_hir::attrs::target::GenericParamKind::Lifetime } rustc_ast::GenericParamKind::Type { default } => { has_default = default.is_some(); - rustc_hir::target::GenericParamKind::Type + rustc_hir::attrs::target::GenericParamKind::Type } rustc_ast::GenericParamKind::Const { default, .. } => { has_default = default.is_some(); - rustc_hir::target::GenericParamKind::Const + rustc_hir::attrs::target::GenericParamKind::Const } }, has_default, diff --git a/compiler/rustc_hir/src/lib.rs b/compiler/rustc_hir/src/lib.rs index b073ed4d8ed12..7d279bca10301 100644 --- a/compiler/rustc_hir/src/lib.rs +++ b/compiler/rustc_hir/src/lib.rs @@ -30,19 +30,8 @@ mod tests; #[doc(no_inline)] pub use hir::*; -pub use rustc_attr_ir::{self as attrs, find_attr}; +pub use rustc_attr_ir::{self as attrs, AttrArgs, AttrItem, Attribute, find_attr}; pub use rustc_hir_id::*; pub use rustc_span::def_id; -// FIXME: Remove this use tree, replace by `rustc_hir::attrs` or `rustc_attr_ir` imports -#[doc(hidden)] -pub use { - attrs::target::{self, MethodKind, Target}, - attrs::{ - AttrArgs, AttrItem, AttrPath, Attribute, ConstStability, DefaultBodyStability, - HashIgnoredAttrId, LangItem, LanguageItems, 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..0e9f740d2ce60 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::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..67998086ea068 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::attrs::lang::LangItem; +use rustc_hir::{self as hir}; 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..6bd339baa8edc 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::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..807b8e476c8fd 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::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..7d7f66421d4f6 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::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..9ec21a674e14a 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::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..d18b4b708c47f 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::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..3f702750914d4 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::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..fbf803444dace 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::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..055e8f8f1d1ba 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::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 953c6a469d11c..6c49baa3e8899 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::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}; @@ -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, rustc_hir::attrs::lang::LangItem::Sized) { bounds.insert(0, bound); } else { bounds.push(bound); diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index d2430a06a0072..54d86e2aa7005 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::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..5f38322b7a3f9 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::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..f1fac77d26064 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::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..7d18a11a893d4 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::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/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index bfdd99b6277ba..062c5a35f3edf 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -18,9 +18,9 @@ use rustc_errors::{ struct_span_code_err, }; use rustc_hir as hir; +use rustc_hir::attrs::lang::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; diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 5faa3dfa494cb..366c4ed20a5ab 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::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..0bf766648fd82 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::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; @@ -1033,7 +1034,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 +2360,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..bbda0de6dc10d 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::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, diff --git a/compiler/rustc_hir_typeck/src/inline_asm.rs b/compiler/rustc_hir_typeck/src/inline_asm.rs index b720a75303c47..bf766e82206c7 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::attrs::lang::LangItem; use rustc_hir::def_id::DefId; -use rustc_hir::{self as hir, LangItem}; +use rustc_hir::{self as hir}; 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..17f7910ef6eb7 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::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..d29e3d4fb0686 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::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..1edae93c1d67a 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::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..58343477ef330 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::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/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 01c48c0ae790c..86ad5acf2f8af 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::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..2ee8536131820 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::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 3382bbd761455..7897d8fc867dd 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::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 f4dd260dd5ae4..8b5c655137212 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::attrs::lang::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_hir::{self as hir}; 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 88161e99b1759..28481275b00e3 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::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 5d487ddfe25b8..924a2714c3cef 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::attrs::lang::LangItem; +use rustc_hir::{self as hir}; 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 25fc52540d4f9..09b13186a8cb4 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::attrs::lang::LangItem; +use rustc_hir::{self as hir}; 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 7f0c615923ef1..912e8aa116527 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::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 7f137d5bf0603..ca646b765c3f0 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::attrs::lang::LangItem; use rustc_hir::def_id::DefId; -use rustc_hir::{self as hir, LangItem}; +use rustc_hir::{self as hir}; 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 05bb2113db09e..d575db1521722 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::attrs::lang::LangItem; +use rustc_hir::{self as hir}; 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 f5b21792af3ce..5b45d51c63db5 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::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 083d2e4ee0499..6fd6f9591a815 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::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/must_use.rs b/compiler/rustc_lint/src/unused/must_use.rs index e72335c80d505..05d3de506f45e 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::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..1d07fd96e1725 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -16,11 +16,10 @@ use rustc_data_structures::unhash::UnhashMap; 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::{CanonicalSymbols, 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..f534f8ab9fd52 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -12,12 +12,12 @@ use rustc_ast as ast; 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::PreciseCapturingArgKind; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::attrs::{self, StrippedCfgItem}; 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; use rustc_macros::{ @@ -192,7 +192,7 @@ type ExpnHashTable = LazyTable>>; #[derive(MetadataEncodable, LazyDecodable)] pub(crate) struct ProcMacroData { proc_macro_decls_static: DefIndex, - stability: Option, + stability: Option, macros: LazyArray<(DefIndex, LazyValue)>, } @@ -416,7 +416,7 @@ define_tables! { impl_is_fully_generic_for_reflection: Table, - optional: - attributes: Table>, + attributes: Table>, // For non-reexported names in a module every name is associated with a separate `DefId`, // so we can take their names, visibilities etc from other encoded tables. module_children_non_reexports: Table>, @@ -425,9 +425,9 @@ define_tables! { visibility: Table>>, def_span: Table>, def_ident_span: Table>, - lookup_stability: Table>, - lookup_const_stability: Table>, - lookup_default_body_stability: Table>, + lookup_stability: Table>, + lookup_const_stability: Table>, + lookup_default_body_stability: Table>, lookup_deprecation_entry: Table>, explicit_clauses_of: Table>>, generics_of: Table>, diff --git a/compiler/rustc_metadata/src/rmeta/parameterized.rs b/compiler/rustc_metadata/src/rmeta/parameterized.rs index 25cb620ee1d80..ad738f01fe9d8 100644 --- a/compiler/rustc_metadata/src/rmeta/parameterized.rs +++ b/compiler/rustc_metadata/src/rmeta/parameterized.rs @@ -86,20 +86,20 @@ trivially_parameterized_over_tcx! { rustc_abi::ReprOptions, rustc_ast::DelimArgs, rustc_hir::Attribute, - rustc_hir::ConstStability, rustc_hir::Constness, rustc_hir::CoroutineKind, - rustc_hir::DefaultBodyStability, rustc_hir::Defaultness, - rustc_hir::LangItem, rustc_hir::OpaqueTyOrigin, rustc_hir::PreciseCapturingArgKind, rustc_hir::Safety, - rustc_hir::Stability, + rustc_hir::attrs::ConstStability, + rustc_hir::attrs::DefaultBodyStability, rustc_hir::attrs::Deprecation, rustc_hir::attrs::EiiDecl, rustc_hir::attrs::EiiImpl, + rustc_hir::attrs::Stability, rustc_hir::attrs::StrippedCfgItem, + rustc_hir::attrs::lang::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..2a2dbf194dd00 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::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 07153d688d477..4073d7c5d436c 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::LangItem; use rustc_hir::def_id::DefId; use rustc_span::Span; use rustc_target::spec::PanicStrategy; diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs index 6c8d2808eb65b..0bfb80771cd7d 100644 --- a/compiler/rustc_middle/src/middle/stability.rs +++ b/compiler/rustc_middle/src/middle/stability.rs @@ -6,9 +6,11 @@ use std::num::NonZero; use rustc_ast::NodeId; use rustc_errors::{Applicability, Diag, Diagnostic, EmissionGuarantee, LintBuffer, msg}; use rustc_feature::GateIssue; -use rustc_hir::attrs::{DeprecatedSince, Deprecation}; +use rustc_hir::attrs::{ + ConstStability, DefaultBodyStability, DeprecatedSince, Deprecation, Stability, +}; use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_hir::{self as hir, ConstStability, DefaultBodyStability, HirId, Stability}; +use rustc_hir::{self as hir, HirId, attrs}; use rustc_macros::{Decodable, Encodable, StableHash, Subdiagnostic}; use rustc_session::Session; use rustc_session::diagnostics::feature_err_issue; @@ -389,7 +391,7 @@ impl<'tcx> TyCtxt<'tcx> { match stability { Some(Stability { - level: hir::StabilityLevel::Unstable { reason, issue, implied_by, .. }, + level: attrs::StabilityLevel::Unstable { reason, issue, implied_by, .. }, feature, .. }) => { @@ -466,7 +468,7 @@ impl<'tcx> TyCtxt<'tcx> { match stability { Some(DefaultBodyStability { - level: hir::StabilityLevel::Unstable { reason, issue, .. }, + level: attrs::StabilityLevel::Unstable { reason, issue, .. }, feature, }) => { if span.allows_unstable(feature) { @@ -607,7 +609,7 @@ impl<'tcx> TyCtxt<'tcx> { match stability { Some(ConstStability { - level: hir::StabilityLevel::Unstable { reason, issue, implied_by, .. }, + level: attrs::StabilityLevel::Unstable { reason, issue, implied_by, .. }, feature, .. }) => { diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index b005cf0c8d10f..03a0c0e83a256 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -1684,7 +1684,7 @@ 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`]). + /// [`rustc_hir::attrs::lang::LangItem::OrderingEnum`] (aka [`std::cmp::Ordering`]). /// /// [`Rvalue::BinaryOp`]`(BinOp::Cmp, A, B)` returns /// - `Ordering::Less` (`-1_i8`, as a Scalar) if `A < B` diff --git a/compiler/rustc_middle/src/mir/terminator.rs b/compiler/rustc_middle/src/mir/terminator.rs index ed86b192f6dcc..37035a79e53fe 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::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..fd072bc042ba9 100644 --- a/compiler/rustc_middle/src/queries.rs +++ b/compiler/rustc_middle/src/queries.rs @@ -60,10 +60,13 @@ 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::{CanonicalSymbols, EiiDecl, EiiImpl, StrippedCfgItem}; +use rustc_hir::attrs::lang::{LangItem, LanguageItems}; +use rustc_hir::attrs::{ + CanonicalSymbols, ConstStability, DefaultBodyStability, DiagnosticItems, EiiDecl, EiiImpl, + Stability, 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; @@ -1467,19 +1470,19 @@ rustc_queries! { cache_on_disk } - query lookup_stability(def_id: DefId) -> Option { + query lookup_stability(def_id: DefId) -> Option { desc { "looking up stability of `{}`", tcx.def_path_str(def_id) } cache_on_disk separate_provide_extern } - query lookup_const_stability(def_id: DefId) -> Option { + query lookup_const_stability(def_id: DefId) -> Option { desc { "looking up const stability of `{}`", tcx.def_path_str(def_id) } cache_on_disk separate_provide_extern } - query lookup_default_body_stability(def_id: DefId) -> Option { + query lookup_default_body_stability(def_id: DefId) -> Option { desc { "looking up default body stability of `{}`", tcx.def_path_str(def_id) } separate_provide_extern } @@ -2274,7 +2277,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 DiagnosticItems { arena_cache eval_always desc { "calculating the diagnostic items map" } @@ -2294,7 +2297,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 DiagnosticItems { arena_cache desc { "calculating the diagnostic items map in a crate" } separate_provide_extern diff --git a/compiler/rustc_middle/src/query/erase.rs b/compiler/rustc_middle/src/query/erase.rs index 9a6ab2732953a..96e58487cb6a3 100644 --- a/compiler/rustc_middle/src/query/erase.rs +++ b/compiler/rustc_middle/src/query/erase.rs @@ -180,10 +180,10 @@ impl_erasable_for_types_with_no_type_params! { Option, Option, Option, - Option, Option, - Option, - Option, + Option, + Option, + Option, Option, Option, Option, diff --git a/compiler/rustc_middle/src/ty/adjustment.rs b/compiler/rustc_middle/src/ty/adjustment.rs index 7174427e517dd..2a186bd2852f0 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::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 bf8b650f4594e..daf8ebd99f8ab 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::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..453d09e6d31c4 100644 --- a/compiler/rustc_middle/src/ty/consts/lit.rs +++ b/compiler/rustc_middle/src/ty/consts/lit.rs @@ -43,7 +43,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(), rustc_hir::attrs::lang::LangItem::CStr)) => { true } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 30ee1d945dc18..4125876ef9ae0 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::{LangItem, LanguageItems}; 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 [rustc_hir::attrs::lang::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 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..ce2de9f2715f3 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::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..5efaa505e0b20 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::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 6a04357827360..3a369231c62ed 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::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 d798cf02f1e49..03a35939a7fee 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::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 149fa69f2abbb..b1db2174e49ed 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::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, find_attr}; use rustc_index::IndexVec; use rustc_index::bit_set::BitMatrix; use rustc_macros::{ @@ -1723,9 +1724,9 @@ impl<'tcx> TyCtxt<'tcx> { if let Some(reprs) = find_attr!(self, did, Repr { reprs, .. } => reprs) { for (r, _) in reprs { flags.insert(match *r { - attr::ReprRust => ReprFlags::empty(), - attr::ReprC => ReprFlags::IS_C, - attr::ReprPacked(pack) => { + attrs::ReprRust => ReprFlags::empty(), + attrs::ReprC => ReprFlags::IS_C, + attrs::ReprPacked(pack) => { min_pack = Some(if let Some(min_pack) = min_pack { min_pack.min(pack) } else { @@ -1733,11 +1734,11 @@ impl<'tcx> TyCtxt<'tcx> { }); ReprFlags::empty() } - attr::ReprTransparent => ReprFlags::IS_TRANSPARENT, - attr::ReprSimd => ReprFlags::IS_SIMD, - attr::ReprInt(i) => { + attrs::ReprTransparent => ReprFlags::IS_TRANSPARENT, + attrs::ReprSimd => ReprFlags::IS_SIMD, + attrs::ReprInt(i) => { size = Some(match i { - attr::IntType::SignedInt(x) => match x { + attrs::IntType::SignedInt(x) => match x { ast::IntTy::Isize => IntegerType::Pointer(true), ast::IntTy::I8 => IntegerType::Fixed(Integer::I8, true), ast::IntTy::I16 => IntegerType::Fixed(Integer::I16, true), @@ -1745,7 +1746,7 @@ impl<'tcx> TyCtxt<'tcx> { ast::IntTy::I64 => IntegerType::Fixed(Integer::I64, true), ast::IntTy::I128 => IntegerType::Fixed(Integer::I128, true), }, - attr::IntType::UnsignedInt(x) => match x { + attrs::IntType::UnsignedInt(x) => match x { ast::UintTy::Usize => IntegerType::Pointer(false), ast::UintTy::U8 => IntegerType::Fixed(Integer::I8, false), ast::UintTy::U16 => IntegerType::Fixed(Integer::I16, false), @@ -1756,7 +1757,7 @@ impl<'tcx> TyCtxt<'tcx> { }); ReprFlags::empty() } - attr::ReprAlign(align) => { + attrs::ReprAlign(align) => { max_align = max_align.max(Some(align)); ReprFlags::empty() } diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 0d1d09d70572c..e2ba0e829fe34 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::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..ad0b257263347 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::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..54f3a639dd785 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::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..062f7ca82fa72 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::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..ec9691ebe563a 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::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..2e1daf6f0cace 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::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..067357ceb7a80 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::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..006f063162457 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::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..dc6ee1e56fcde 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::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..503d905e6243a 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::{AttributeKind, HasAttrs}; +use rustc_hir::HirId; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::attrs::{AttributeKind, HasAttrs, find_attr}; use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; -use rustc_hir::{HirId, LangItem, find_attr}; use rustc_index::Idx; use rustc_middle::hir::place::{ Place as HirPlace, PlaceBase as HirPlaceBase, ProjectionKind as HirProjectionKind, @@ -279,7 +280,8 @@ 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(rustc_hir::attrs::lang::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 +549,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..93ce31163c578 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::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..bfb26e91a94bd 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::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..d40dbb007ecb4 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::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..9ef4d74e18460 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::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..0e5045cc1f931 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::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..39f8c481b1cdd 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::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..0c04bab81f81b 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::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/layout.rs b/compiler/rustc_mir_transform/src/coroutine/layout.rs index 850b933a9f0bc..abfc0fde1f871 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::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..ad77118200827 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::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..dc959d4a6ca58 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::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..cd6211f694b3e 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -774,9 +774,10 @@ 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), + rustc_hir::attrs::lang::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..4e8e9d0db51f2 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::find_attr; +use rustc_hir::attrs::lang::LangItem; 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..014d1008e732c 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::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..1742f054c46a5 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::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..5ac8aa2c41f94 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::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..9ca4a9026b3ba 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::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..7d3893c2c1abd 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::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..bdd0496659b84 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::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..377e28c340816 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::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_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index a5ba6d2f14d12..069e5871c763e 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -15,6 +15,8 @@ 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::LangItem; +use rustc_hir::attrs::target::{MethodKind, Target}; use rustc_hir::attrs::{ AttributeKind, DocAttribute, DocInline, EiiDecl, EiiImpl, EiiImplResolution, InlineAttr, OptimizeAttr, ReprAttr, @@ -24,8 +26,7 @@ use rustc_hir::def_id::LocalModId; use rustc_hir::intravisit::{self, Visitor}; use rustc_hir::{ self as hir, Attribute, CRATE_HIR_ID, Constness, FnSig, ForeignItem, GenericParam, - GenericParamKind, HirId, Item, ItemKind, MethodKind, Node, ParamName, Target, TraitItem, - find_attr, + GenericParamKind, HirId, Item, ItemKind, Node, ParamName, TraitItem, find_attr, }; use rustc_macros::Diagnostic; use rustc_middle::hir::nested_filter; @@ -1083,7 +1084,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..0d4e161664e9e 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::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..78396710e2db8 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::attrs::lang::{GenericRequirement, LangItem, LanguageItems}; +use rustc_hir::attrs::target::Target; 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/lib_features.rs b/compiler/rustc_passes/src/lib_features.rs index ceaad91d25982..064e4abbf09c3 100644 --- a/compiler/rustc_passes/src/lib_features.rs +++ b/compiler/rustc_passes/src/lib_features.rs @@ -4,9 +4,8 @@ //! but are not declared in one single location (unlike lang features), which means we need to //! collect them instead. -use rustc_hir::attrs::AttributeKind; +use rustc_hir::attrs::{Attribute, AttributeKind, StabilityLevel, StableSince}; use rustc_hir::intravisit::Visitor; -use rustc_hir::{Attribute, StabilityLevel, StableSince}; use rustc_middle::hir::nested_filter; use rustc_middle::middle::lib_features::{FeatureStability, LibFeatures}; use rustc_middle::query::{LocalCrate, Providers}; diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index 5d388bd44ecac..a0306a3c5228a 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -7,14 +7,16 @@ use rustc_ast_lowering::stability::extern_abi_stability; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::unord::{ExtendUnord, UnordMap, UnordSet}; use rustc_feature::{EnabledLangFeature, EnabledLibFeature, UNSTABLE_LANG_FEATURES}; -use rustc_hir::attrs::{AttributeKind, DeprecatedSince}; +use rustc_hir::attrs::{ + AttributeKind, ConstStability, DefaultBodyStability, DeprecatedSince, Stability, + StabilityLevel, StableSince, UnstableReason, VERSION_PLACEHOLDER, +}; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId, LocalModId}; use rustc_hir::intravisit::{self, Visitor, VisitorExt}; use rustc_hir::{ - self as hir, AmbigArg, ConstStability, Constness, DefaultBodyStability, FieldDef, HirId, Item, - ItemKind, Path, Stability, StabilityLevel, StableSince, TraitRef, Ty, TyKind, UnstableReason, - UsePath, VERSION_PLACEHOLDER, Variant, find_attr, + self as hir, AmbigArg, Constness, FieldDef, HirId, Item, ItemKind, Path, TraitRef, Ty, TyKind, + UsePath, Variant, find_attr, }; use rustc_middle::hir::nested_filter; use rustc_middle::middle::lib_features::{FeatureStability, LibFeatures}; diff --git a/compiler/rustc_passes/src/weak_lang_items.rs b/compiler/rustc_passes/src/weak_lang_items.rs index 6c151378d2e73..16949c5c0e7b4 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::WEAK_LANG_ITEMS; +use rustc_hir::attrs::lang::{LangItem, LanguageItems}; use rustc_middle::middle::lang_items::required; use rustc_middle::ty::TyCtxt; use rustc_session::config::CrateType; @@ -11,7 +11,7 @@ use crate::diagnostics::{MissingLangItem, MissingPanicHandler, PanicUnwindWithou /// Checks the crate for usage of weak lang items. Erroring on all the /// lang items required by this crate, but not defined yet. -pub(crate) fn check_crate(tcx: TyCtxt<'_>, items: &mut lang_items::LanguageItems) { +pub(crate) fn check_crate(tcx: TyCtxt<'_>, items: &mut LanguageItems) { // This is never called by user code, it's generated by the compiler. It // will never implicitly be added to the `missing` array unless we do so // here. @@ -24,7 +24,7 @@ pub(crate) fn check_crate(tcx: TyCtxt<'_>, items: &mut lang_items::LanguageItems verify(tcx, items); } -fn verify(tcx: TyCtxt<'_>, items: &lang_items::LanguageItems) { +fn verify(tcx: TyCtxt<'_>, items: &LanguageItems) { // We only need to check for the presence of weak lang items if we're // emitting something that's not an rlib. let needs_check = tcx.crate_types().iter().any(|kind| match *kind { diff --git a/compiler/rustc_public_bridge/src/context/impls.rs b/compiler/rustc_public_bridge/src/context/impls.rs index f648a85249dfc..b0caabfc7373f 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::attrs::Attribute; +use rustc_hir::attrs::lang::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_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs index 97ca994c37540..8f2de8b596c96 100644 --- a/compiler/rustc_resolve/src/def_collector.rs +++ b/compiler/rustc_resolve/src/def_collector.rs @@ -6,7 +6,7 @@ use rustc_attr_parsing as attr; use rustc_attr_parsing::{AttributeParser, OmitDoc, ShouldEmit}; use rustc_expand::expand::AstFragment; use rustc_hir as hir; -use rustc_hir::Target; +use rustc_hir::attrs::target::Target; use rustc_hir::def::DefKind; use rustc_hir::def::Namespace::{TypeNS, ValueNS}; use rustc_hir::def_id::LocalDefId; diff --git a/compiler/rustc_resolve/src/diagnostics/impls.rs b/compiler/rustc_resolve/src/diagnostics/impls.rs index 97c2c2f327ccf..a63bb3d7d14a2 100644 --- a/compiler/rustc_resolve/src/diagnostics/impls.rs +++ b/compiler/rustc_resolve/src/diagnostics/impls.rs @@ -18,12 +18,14 @@ use rustc_errors::{ pluralize, struct_span_code_err, }; use rustc_feature::BUILTIN_ATTRIBUTES; +use rustc_hir::PrimTy; use rustc_hir::attrs::diagnostic::{CustomDiagnostic, Directive, FormatArgs}; -use rustc_hir::attrs::{AttributeKind, CfgEntry, StrippedCfgItem}; +use rustc_hir::attrs::{ + Attribute, AttributeKind, CfgEntry, Stability, StabilityLevel, StrippedCfgItem, find_attr, +}; use rustc_hir::def::Namespace::{self, *}; use rustc_hir::def::{CtorKind, CtorOf, DefKind, MacroKinds, NonMacroAttrKind, PerNS}; use rustc_hir::def_id::{CRATE_DEF_ID, DefId}; -use rustc_hir::{Attribute, PrimTy, Stability, StabilityLevel, find_attr}; use rustc_middle::bug; use rustc_middle::ty::{TyCtxt, Visibility}; use rustc_session::Session; diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index 9747ebd4a8af8..0e59f9bbc435f 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -16,10 +16,9 @@ use rustc_expand::compile_declarative_macro; use rustc_expand::expand::{ AstFragment, AstFragmentKind, Invocation, InvocationKind, SupportsMacroExpansion, }; -use rustc_hir::attrs::{AttributeKind, CfgEntry, StrippedCfgItem}; +use rustc_hir::attrs::{Attribute, AttributeKind, CfgEntry, StabilityLevel, StrippedCfgItem}; use rustc_hir::def::{DefKind, MacroKinds, Namespace, NonMacroAttrKind}; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId}; -use rustc_hir::{Attribute, StabilityLevel}; use rustc_middle::middle::stability; use rustc_middle::ty::{RegisteredTools, TyCtxt}; use rustc_session::Session; 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..7ab8424d7b948 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::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_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..49d79f793c892 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::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..55b22650fd4e3 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::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..407f1b8a8126f 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::{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, }; @@ -102,7 +102,7 @@ pub fn call_kind<'tcx>( let fn_call = parent.filter(|&p| tcx.fn_trait_kind_from_def_id(p).is_some()); let operator = if !from_hir_call && let Some(p) = parent { - lang_items::OPERATORS.iter().filter_map(|&l| tcx.lang_items().get(l)).find(|&id| id == p) + lang::OPERATORS.iter().filter_map(|&l| tcx.lang_items().get(l)).find(|&id| id == p) } else { None }; 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..db30519335fea 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::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..961bf7dce2036 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::{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::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..b5342388389ad 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::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..1b755a0118d4c 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::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..1c3fa82656ab2 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::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..2bb015607dbab 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::attrs::lang::LangItem; use rustc_hir::def_id::DefId; -use rustc_hir::{self as hir, LangItem}; +use rustc_hir::{self as hir}; 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..dea3644908c1b 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::attrs::lang::LangItem; +use rustc_hir::{self as hir}; 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..c746cee7e1de7 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::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..9601c905a62cd 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::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..57e73b58dc019 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::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..7aa8cf2e5f39f 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::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..895a42b34e145 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::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..91f71424919bf 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::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..16b7cfd236937 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::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..14865eea7b416 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::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..6ceeb4178e103 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::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..ea1310d8f0a41 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::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..91318a63e4252 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::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..488263480071a 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::LangItem; use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::query::Providers; use rustc_middle::ty::{self, Ty, TyCtxt, TypingMode}; diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 9186b76f5d2b2..94810357cec52 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -39,10 +39,11 @@ use rustc_data_structures::thin_vec::ThinVec; use rustc_errors::codes::*; use rustc_errors::{FatalError, struct_span_code_err}; use rustc_hir as hir; -use rustc_hir::attrs::{AttributeKind, DocAttribute, DocInline}; +use rustc_hir::PredicateOrigin; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::attrs::{AttributeKind, DocAttribute, DocInline, find_attr}; use rustc_hir::def::{CtorKind, DefKind, MacroKinds, Res}; use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LOCAL_CRATE, LocalDefId}; -use rustc_hir::{LangItem, PredicateOrigin, find_attr}; use rustc_hir_analysis::{lower_const_arg_for_rustdoc, lower_ty}; use rustc_middle::metadata::Reexport; use rustc_middle::middle::resolve_bound_vars as rbv; diff --git a/src/librustdoc/clean/simplify.rs b/src/librustdoc/clean/simplify.rs index a3732fb727dbd..0607133a9a87e 100644 --- a/src/librustdoc/clean/simplify.rs +++ b/src/librustdoc/clean/simplify.rs @@ -14,6 +14,7 @@ use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::thin_vec::ThinVec; use rustc_hir as hir; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::def_id::DefId; use rustc_middle::ty::{TyCtxt, Unnormalized}; @@ -161,8 +162,8 @@ pub(crate) fn sizedness_bounds(cx: &mut DocContext<'_>, generics: &mut clean::Ge let Some(param_sizedness) = type_params.get_mut(param) else { return true }; let sizedness = match cx.tcx.as_lang_item(trait_ref.trait_.def_id()) { - Some(hir::LangItem::Sized) => Sizedness::Sized, - Some(hir::LangItem::MetaSized) => Sizedness::MetaSized, + Some(LangItem::Sized) => Sizedness::Sized, + Some(LangItem::MetaSized) => Sizedness::MetaSized, _ => return true, }; diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 56a73955abce0..542e6552decea 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -11,11 +11,14 @@ use rustc_ast as ast; use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; use rustc_data_structures::thin_vec::ThinVec; use rustc_hir as hir; -use rustc_hir::attrs::{AttributeKind, DeprecatedSince, Deprecation, DocAttribute}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::attrs::{ + self, Attribute, AttributeKind, ConstStability, DeprecatedSince, Deprecation, DocAttribute, + Stability, StableSince, find_attr, +}; use rustc_hir::def::{CtorKind, DefKind, MacroKinds, Res}; use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE, LocalDefId}; -use rustc_hir::lang_items::LangItem; -use rustc_hir::{Attribute, BodyId, ConstStability, Mutability, Stability, StableSince, find_attr}; +use rustc_hir::{BodyId, Mutability}; use rustc_index::IndexVec; use rustc_metadata::rendered_const; use rustc_middle::span_bug; @@ -446,7 +449,7 @@ impl Item { // versions; the paths that are exposed through it are "deprecated" because they // were never supposed to work at all. let stab = self.stability(tcx)?; - if let rustc_hir::StabilityLevel::Stable { + if let attrs::StabilityLevel::Stable { allowed_through_unstable_modules: Some(note), .. } = stab.level diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index ccee062584e01..2977761aa128a 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -1,7 +1,7 @@ use std::mem; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet}; -use rustc_hir::StabilityLevel; +use rustc_hir::attrs::StabilityLevel; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, DefIdSet}; use rustc_metadata::creader::CStore; use rustc_middle::ty::{self, TyCtxt}; diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 4b9bf8bbd3a07..f60a162b76ee9 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -15,9 +15,9 @@ use rustc_abi::ExternAbi; use rustc_ast::join_path_syms; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; +use rustc_hir::attrs::{ConstStability, StabilityLevel, StableSince}; use rustc_hir::def::{DefKind, MacroKinds}; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; -use rustc_hir::{ConstStability, StabilityLevel, StableSince}; use rustc_metadata::creader::CStore; use rustc_middle::ty::{self, TyCtxt, TypingMode}; use rustc_span::symbol::kw; diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 152a61beef405..fcf1cf872d891 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -53,10 +53,13 @@ use itertools::Either; use rustc_ast::join_path_syms; use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; use rustc_hir as hir; -use rustc_hir::attrs::{AttributeKind, DeprecatedSince, Deprecation, RustcVersion}; +use rustc_hir::Mutability; +use rustc_hir::attrs::{ + AttributeKind, ConstStability, DeprecatedSince, Deprecation, RustcVersion, StabilityLevel, + StableSince, +}; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, DefIdSet}; -use rustc_hir::{ConstStability, Mutability, StabilityLevel, StableSince}; use rustc_middle::ty::print::PrintTraitRefExt; use rustc_middle::ty::{self, TyCtxt}; use rustc_span::DUMMY_SP; diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index b19ed533d4953..83120a6c21b52 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -236,45 +236,45 @@ impl FromClean for Deprecation { } } -impl FromClean for Stability { - fn from_clean(stab: &hir::Stability, _renderer: &JsonRenderer<'_>) -> Self { +impl FromClean for Stability { + fn from_clean(stab: &attrs::Stability, _renderer: &JsonRenderer<'_>) -> Self { let feature = stab.feature.to_string(); let level = match stab.level { - hir::StabilityLevel::Stable { since, .. } => StabilityLevel::Stable { + attrs::StabilityLevel::Stable { since, .. } => StabilityLevel::Stable { since: match since { - hir::StableSince::Version(since) => Some(since.to_string()), - hir::StableSince::Current => Some(RustcVersion::CURRENT.to_string()), + attrs::StableSince::Version(since) => Some(since.to_string()), + attrs::StableSince::Current => Some(RustcVersion::CURRENT.to_string()), // Match rustdoc HTML: malformed stable-since values are omitted. - hir::StableSince::Err(_) => None, + attrs::StableSince::Err(_) => None, }, }, - hir::StabilityLevel::Unstable { .. } => StabilityLevel::Unstable, + attrs::StabilityLevel::Unstable { .. } => StabilityLevel::Unstable, }; Stability { feature, level } } } -impl FromClean for Stability { - fn from_clean(stab: &hir::ConstStability, _renderer: &JsonRenderer<'_>) -> Self { +impl FromClean for Stability { + fn from_clean(stab: &attrs::ConstStability, _renderer: &JsonRenderer<'_>) -> Self { let feature = stab.feature.to_string(); let level = match stab.level { - hir::StabilityLevel::Stable { since, .. } => StabilityLevel::Stable { + attrs::StabilityLevel::Stable { since, .. } => StabilityLevel::Stable { since: match since { - hir::StableSince::Version(since) => Some(since.to_string()), - hir::StableSince::Current => Some(RustcVersion::CURRENT.to_string()), + attrs::StableSince::Version(since) => Some(since.to_string()), + attrs::StableSince::Current => Some(RustcVersion::CURRENT.to_string()), // Match rustdoc HTML: malformed stable-since values are omitted. - hir::StableSince::Err(_) => None, + attrs::StableSince::Err(_) => None, }, }, - hir::StabilityLevel::Unstable { .. } => StabilityLevel::Unstable, + attrs::StabilityLevel::Unstable { .. } => StabilityLevel::Unstable, }; Stability { feature, level } } } -impl FromClean for Box { - fn from_clean(stab: &hir::DefaultBodyStability, _renderer: &JsonRenderer<'_>) -> Self { - let hir::StabilityLevel::Unstable { .. } = stab.level else { +impl FromClean for Box { + fn from_clean(stab: &attrs::DefaultBodyStability, _renderer: &JsonRenderer<'_>) -> Self { + let attrs::StabilityLevel::Unstable { .. } = stab.level else { bug!( "unexpected stable default-body stability, \ there's no stable equivalent of `#[rustc_default_body_unstable]`" @@ -1014,15 +1014,15 @@ impl FromClean for ItemKind { fn default_body_stability_for_def_id( tcx: TyCtxt<'_>, def_id: DefId, -) -> Option { +) -> Option { let stability = tcx.lookup_default_body_stability(def_id)?; match stability.level { - hir::StabilityLevel::Unstable { .. } => Some(stability), - hir::StabilityLevel::Stable { .. } => None, + attrs::StabilityLevel::Unstable { .. } => Some(stability), + attrs::StabilityLevel::Stable { .. } => None, } } -fn const_stability_for_def_id(tcx: TyCtxt<'_>, def_id: DefId) -> Option { +fn const_stability_for_def_id(tcx: TyCtxt<'_>, def_id: DefId) -> Option { if !tcx.is_conditionally_const(def_id) { // The item cannot be conditionally-const. No const stability here. // @@ -1065,7 +1065,7 @@ fn const_stability_for_def_id(tcx: TyCtxt<'_>, def_id: DefId) -> Option, def_id: DefId) -> Option) -> Vec { +fn maybe_from_hir_attr( + attr: &attrs::Attribute, + item_id: ItemId, + tcx: TyCtxt<'_>, +) -> Vec { use attrs::AttributeKind as AK; let kind = match attr { - hir::Attribute::Parsed(kind) => kind, + attrs::Attribute::Parsed(kind) => kind, - hir::Attribute::Unparsed(_) => { + attrs::Attribute::Unparsed(_) => { // FIXME: We should handle `#[doc(hidden)]`. return vec![other_attr(tcx, attr)]; } diff --git a/src/librustdoc/passes/propagate_stability.rs b/src/librustdoc/passes/propagate_stability.rs index 6700ca649d7be..d72cee16a9328 100644 --- a/src/librustdoc/passes/propagate_stability.rs +++ b/src/librustdoc/passes/propagate_stability.rs @@ -6,8 +6,8 @@ //! [`core::error`] module is marked as stable since 1.81.0, so we want to show //! [`core::error::Error`] as stable since 1.81.0 as well. +use rustc_hir::attrs::{Stability, StabilityLevel}; use rustc_hir::def_id::CRATE_DEF_ID; -use rustc_hir::{Stability, StabilityLevel}; use crate::clean::{Crate, Item, ItemId, ItemKind}; use crate::core::DocContext; diff --git a/src/tools/clippy/book/src/development/common_tools_writing_lints.md b/src/tools/clippy/book/src/development/common_tools_writing_lints.md index b5958f802e384..eb05d80f6390f 100644 --- a/src/tools/clippy/book/src/development/common_tools_writing_lints.md +++ b/src/tools/clippy/book/src/development/common_tools_writing_lints.md @@ -87,7 +87,7 @@ arguments have to be checked separately. ```rust use clippy_utils::{paths, sym}; use clippy_utils::res::MaybeDef; -use rustc_hir::LangItem; +use rustc_hir::attrs::lang::LangItem; impl LateLintPass<'_> for MyStructLint { fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { diff --git a/src/tools/clippy/clippy_lints/src/assert_is_empty.rs b/src/tools/clippy/clippy_lints/src/assert_is_empty.rs index cfaa3c6fd64e9..3da7fc51ddbcf 100644 --- a/src/tools/clippy/clippy_lints/src/assert_is_empty.rs +++ b/src/tools/clippy/clippy_lints/src/assert_is_empty.rs @@ -6,7 +6,8 @@ use clippy_utils::sugg::Sugg; use clippy_utils::sym; use clippy_utils::ty::implements_trait; use rustc_errors::Applicability; -use rustc_hir::{Expr, ExprKind, LangItem, UnOp}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{Expr, ExprKind, UnOp}; use rustc_lint::{LateContext, LateLintPass, LintContext as _}; use rustc_middle::ty::{self, Ty}; use rustc_session::declare_lint_pass; diff --git a/src/tools/clippy/clippy_lints/src/attrs/deprecated_semver.rs b/src/tools/clippy/clippy_lints/src/attrs/deprecated_semver.rs index e3b1a05bda7dd..e2bd4d3597100 100644 --- a/src/tools/clippy/clippy_lints/src/attrs/deprecated_semver.rs +++ b/src/tools/clippy/clippy_lints/src/attrs/deprecated_semver.rs @@ -2,7 +2,7 @@ use super::DEPRECATED_SEMVER; use clippy_utils::diagnostics::span_lint; use clippy_utils::sym; use rustc_ast::{LitKind, MetaItemLit}; -use rustc_hir::VERSION_PLACEHOLDER; +use rustc_hir::attrs::VERSION_PLACEHOLDER; use rustc_lint::EarlyContext; use rustc_span::Span; use semver::Version; diff --git a/src/tools/clippy/clippy_lints/src/box_default.rs b/src/tools/clippy/clippy_lints/src/box_default.rs index e509d2bf34083..6a9000c277e89 100644 --- a/src/tools/clippy/clippy_lints/src/box_default.rs +++ b/src/tools/clippy/clippy_lints/src/box_default.rs @@ -4,9 +4,10 @@ use clippy_utils::res::{MaybeDef as _, MaybeResPath as _}; use clippy_utils::ty::expr_sig; use clippy_utils::{is_default_equivalent, sym}; use rustc_errors::Applicability; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::def::Res; use rustc_hir::intravisit::{InferKind, Visitor, VisitorExt as _, walk_ty}; -use rustc_hir::{AmbigArg, Block, Expr, ExprKind, HirId, LangItem, LetStmt, Node, QPath, Ty, TyKind}; +use rustc_hir::{AmbigArg, Block, Expr, ExprKind, HirId, LetStmt, Node, QPath, Ty, TyKind}; use rustc_lint::{LateContext, LateLintPass, LintContext as _}; use rustc_session::declare_lint_pass; use rustc_span::Span; diff --git a/src/tools/clippy/clippy_lints/src/cloned_ref_to_slice_refs.rs b/src/tools/clippy/clippy_lints/src/cloned_ref_to_slice_refs.rs index bc1e21c99faa2..2f8cb9c3abbb7 100644 --- a/src/tools/clippy/clippy_lints/src/cloned_ref_to_slice_refs.rs +++ b/src/tools/clippy/clippy_lints/src/cloned_ref_to_slice_refs.rs @@ -9,7 +9,8 @@ use clippy_utils::visitors::is_const_evaluatable; use clippy_utils::{is_in_const_context, is_mutable, sym}; use rustc_ast::Mutability; use rustc_errors::Applicability; -use rustc_hir::{Expr, ExprKind, HirId, LangItem}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{Expr, ExprKind, HirId}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_middle::ty::adjustment::{Adjust, DerefAdjustKind, OverloadedDeref}; diff --git a/src/tools/clippy/clippy_lints/src/collection_is_never_read.rs b/src/tools/clippy/clippy_lints/src/collection_is_never_read.rs index 5c70b0d880914..e862a9b6ad446 100644 --- a/src/tools/clippy/clippy_lints/src/collection_is_never_read.rs +++ b/src/tools/clippy/clippy_lints/src/collection_is_never_read.rs @@ -3,7 +3,8 @@ use clippy_utils::res::{MaybeDef as _, MaybeResPath as _}; use clippy_utils::visitors::{Visitable, for_each_expr}; use clippy_utils::{get_enclosing_block, sym}; use core::ops::ControlFlow; -use rustc_hir::{Body, ExprKind, HirId, LangItem, LetStmt, Node, PatKind}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{Body, ExprKind, HirId, LetStmt, Node, PatKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; diff --git a/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs b/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs index 080569c813911..46e3d36f11b0a 100644 --- a/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs +++ b/src/tools/clippy/clippy_lints/src/drop_forget_ref.rs @@ -2,7 +2,8 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::is_must_use_func_call; use clippy_utils::res::MaybeDef as _; use clippy_utils::ty::{is_copy, opt_must_use_path}; -use rustc_hir::{Arm, Expr, ExprKind, LangItem, Node}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{Arm, Expr, ExprKind, Node}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; use rustc_span::sym; diff --git a/src/tools/clippy/clippy_lints/src/format_args.rs b/src/tools/clippy/clippy_lints/src/format_args.rs index 69fdf84dfe7d9..16700f5c59f0e 100644 --- a/src/tools/clippy/clippy_lints/src/format_args.rs +++ b/src/tools/clippy/clippy_lints/src/format_args.rs @@ -23,7 +23,8 @@ use rustc_data_structures::fx::FxHashMap; use rustc_errors::Applicability; use rustc_errors::SuggestionStyle::{CompletelyHidden, ShowCode}; use rustc_hir::attrs::RustcVersion; -use rustc_hir::{Expr, ExprKind, LangItem, find_attr}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{Expr, ExprKind, find_attr}; use rustc_lint::{LateContext, LateLintPass, LintContext as _}; use rustc_middle::ty::adjustment::{Adjust, Adjustment, DerefAdjustKind}; use rustc_middle::ty::{self, GenericArg, List, TraitRef, Ty, TyCtxt, Unnormalized, Upcast as _}; diff --git a/src/tools/clippy/clippy_lints/src/format_push_string.rs b/src/tools/clippy/clippy_lints/src/format_push_string.rs index 9a092729762dd..c2613e41d6b98 100644 --- a/src/tools/clippy/clippy_lints/src/format_push_string.rs +++ b/src/tools/clippy/clippy_lints/src/format_push_string.rs @@ -4,7 +4,8 @@ use clippy_utils::res::MaybeDef as _; use clippy_utils::source::{snippet_with_applicability, snippet_with_context}; use clippy_utils::{std_or_core, sym}; use rustc_errors::Applicability; -use rustc_hir::{AssignOpKind, Expr, ExprKind, LangItem, MatchSource}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{AssignOpKind, Expr, ExprKind, MatchSource}; use rustc_lint::{LateContext, LateLintPass, LintContext as _}; use rustc_session::impl_lint_pass; use rustc_span::Span; diff --git a/src/tools/clippy/clippy_lints/src/from_str_radix_10.rs b/src/tools/clippy/clippy_lints/src/from_str_radix_10.rs index 5540c50906e2b..cb71eed459cb4 100644 --- a/src/tools/clippy/clippy_lints/src/from_str_radix_10.rs +++ b/src/tools/clippy/clippy_lints/src/from_str_radix_10.rs @@ -3,7 +3,8 @@ use clippy_utils::res::MaybeDef as _; use clippy_utils::sugg::Sugg; use clippy_utils::{is_in_const_context, is_integer_literal, sym}; use rustc_errors::Applicability; -use rustc_hir::{Expr, ExprKind, LangItem, PrimTy, QPath, TyKind, def}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{Expr, ExprKind, PrimTy, QPath, TyKind, def}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::Ty; use rustc_session::declare_lint_pass; diff --git a/src/tools/clippy/clippy_lints/src/incompatible_msrv.rs b/src/tools/clippy/clippy_lints/src/incompatible_msrv.rs index 73467def31757..3fd15c42abf6f 100644 --- a/src/tools/clippy/clippy_lints/src/incompatible_msrv.rs +++ b/src/tools/clippy/clippy_lints/src/incompatible_msrv.rs @@ -3,8 +3,8 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::msrvs::Msrv; use clippy_utils::{is_in_const_context, is_in_test, sym}; use rustc_data_structures::fx::FxHashMap; -use rustc_hir::attrs::RustcVersion; -use rustc_hir::{self as hir, AmbigArg, Expr, ExprKind, HirId, StabilityLevel, StableSince, find_attr}; +use rustc_hir::attrs::{RustcVersion, StabilityLevel, StableSince}; +use rustc_hir::{self as hir, AmbigArg, Expr, ExprKind, HirId, find_attr}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{self, TyCtxt}; use rustc_session::impl_lint_pass; diff --git a/src/tools/clippy/clippy_lints/src/inherent_to_string.rs b/src/tools/clippy/clippy_lints/src/inherent_to_string.rs index e01200329e8e2..56684e65282b8 100644 --- a/src/tools/clippy/clippy_lints/src/inherent_to_string.rs +++ b/src/tools/clippy/clippy_lints/src/inherent_to_string.rs @@ -3,7 +3,8 @@ use clippy_utils::res::MaybeDef as _; use clippy_utils::ty::implements_trait; use clippy_utils::{return_ty, trait_ref_of_method}; use rustc_abi::ExternAbi; -use rustc_hir::{GenericParamKind, ImplItem, ImplItemKind, LangItem}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{GenericParamKind, ImplItem, ImplItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; use rustc_span::sym; diff --git a/src/tools/clippy/clippy_lints/src/large_futures.rs b/src/tools/clippy/clippy_lints/src/large_futures.rs index caa44d5ef1235..8f3bd95990893 100644 --- a/src/tools/clippy/clippy_lints/src/large_futures.rs +++ b/src/tools/clippy/clippy_lints/src/large_futures.rs @@ -4,7 +4,8 @@ use clippy_utils::source::snippet; use clippy_utils::ty::implements_trait; use rustc_abi::Size; use rustc_errors::Applicability; -use rustc_hir::{Expr, ExprKind, LangItem, MatchSource}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{Expr, ExprKind, MatchSource}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; diff --git a/src/tools/clippy/clippy_lints/src/lifetimes.rs b/src/tools/clippy/clippy_lints/src/lifetimes.rs index 8f2f8aaf7859f..02e2038787400 100644 --- a/src/tools/clippy/clippy_lints/src/lifetimes.rs +++ b/src/tools/clippy/clippy_lints/src/lifetimes.rs @@ -7,6 +7,7 @@ use rustc_ast::visit::{try_visit, walk_list}; use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; use rustc_errors::Applicability; use rustc_hir::FnRetTy::Return; +use rustc_hir::attrs::lang; use rustc_hir::intravisit::{ IgnoreNested, NestedFilter, Visitor, VisitorExt as _, walk_fn_decl, walk_generic_args, walk_generic_param, walk_generics, walk_impl_item_ref, walk_param_bound, walk_poly_trait_ref, walk_trait_ref, walk_ty, walk_unambig_ty, @@ -16,7 +17,7 @@ use rustc_hir::{ AmbigArg, BodyId, FnDecl, FnPtrTy, FnSig, GenericArg, GenericArgs, GenericBound, GenericParam, GenericParamKind, Generics, HirId, Impl, ImplItem, ImplItemKind, Item, ItemKind, Lifetime, LifetimeKind, LifetimeParamKind, Node, PolyTraitRef, PredicateOrigin, TraitFn, TraitItem, TraitItemKind, TraitRef, Ty, TyKind, WhereBoundPredicate, - WherePredicate, WherePredicateKind, lang_items, + WherePredicate, WherePredicateKind, }; use rustc_lint::{LateContext, LateLintPass, LintContext as _}; use rustc_middle::hir::nested_filter as middle_nested_filter; @@ -496,7 +497,7 @@ impl<'tcx> Visitor<'tcx> for RefVisitor<'_, 'tcx> { fn visit_poly_trait_ref(&mut self, poly_tref: &'tcx PolyTraitRef<'tcx>) { let trait_ref = &poly_tref.trait_ref; if let Some(id) = trait_ref.trait_def_id() - && lang_items::FN_TRAITS + && lang::FN_TRAITS .iter() .any(|&item| self.cx.tcx.lang_items().get(item) == Some(id)) { diff --git a/src/tools/clippy/clippy_lints/src/loops/char_indices_as_byte_indices.rs b/src/tools/clippy/clippy_lints/src/loops/char_indices_as_byte_indices.rs index 9231f341b72aa..3739ee4786e94 100644 --- a/src/tools/clippy/clippy_lints/src/loops/char_indices_as_byte_indices.rs +++ b/src/tools/clippy/clippy_lints/src/loops/char_indices_as_byte_indices.rs @@ -5,7 +5,8 @@ use clippy_utils::res::{MaybeDef as _, MaybeResPath as _}; use clippy_utils::visitors::for_each_expr; use clippy_utils::{eq_expr_value, higher, sym}; use rustc_errors::{Applicability, MultiSpan}; -use rustc_hir::{Expr, ExprKind, LangItem, Node, Pat, PatKind}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{Expr, ExprKind, Node, Pat, PatKind}; use rustc_lint::LateContext; use rustc_middle::ty::Ty; use rustc_span::{Span, Symbol}; diff --git a/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs b/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs index 37a0c4e13c0e2..441ff68557a0a 100644 --- a/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs +++ b/src/tools/clippy/clippy_lints/src/loops/explicit_iter_loop.rs @@ -9,6 +9,7 @@ use clippy_utils::ty::{ make_normalized_projection_with_regions, normalize_with_regions, }; use rustc_errors::Applicability; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::{Expr, Mutability}; use rustc_lint::LateContext; use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability}; @@ -128,8 +129,7 @@ fn is_ref_iterable<'tcx>( let self_ty = typeck.expr_ty(self_arg); let self_is_copy = is_copy(cx, self_ty); - if self_ty.peel_refs().is_lang_item(cx, rustc_hir::LangItem::OwnedBox) && !msrv.meets(cx, msrvs::BOX_INTO_ITER) - { + if self_ty.peel_refs().is_lang_item(cx, LangItem::OwnedBox) && !msrv.meets(cx, msrvs::BOX_INTO_ITER) { return None; } diff --git a/src/tools/clippy/clippy_lints/src/manual_ignore_case_cmp.rs b/src/tools/clippy/clippy_lints/src/manual_ignore_case_cmp.rs index b214ace2e584f..2a6d3e318b6d0 100644 --- a/src/tools/clippy/clippy_lints/src/manual_ignore_case_cmp.rs +++ b/src/tools/clippy/clippy_lints/src/manual_ignore_case_cmp.rs @@ -6,7 +6,8 @@ use clippy_utils::sym; use rustc_ast::LitKind; use rustc_errors::Applicability; use rustc_hir::ExprKind::{Binary, Lit, MethodCall}; -use rustc_hir::{BinOpKind, Expr, LangItem}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{BinOpKind, Expr}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_middle::ty::{Ty, UintTy}; diff --git a/src/tools/clippy/clippy_lints/src/manual_pop_if.rs b/src/tools/clippy/clippy_lints/src/manual_pop_if.rs index 359bb594e4a12..3b14835a04384 100644 --- a/src/tools/clippy/clippy_lints/src/manual_pop_if.rs +++ b/src/tools/clippy/clippy_lints/src/manual_pop_if.rs @@ -7,7 +7,8 @@ use clippy_utils::visitors::{for_each_expr_without_closures, is_local_used}; use clippy_utils::{eq_expr_value, is_else_clause, is_lang_item_or_ctor, span_contains_non_whitespace, sym}; use rustc_ast::LitKind; use rustc_errors::{Applicability, MultiSpan}; -use rustc_hir::{BlockCheckMode, Expr, ExprKind, LangItem, PatKind, StmtKind, UnsafeSource}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{BlockCheckMode, Expr, ExprKind, PatKind, StmtKind, UnsafeSource}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::TyCtxt; use rustc_session::impl_lint_pass; diff --git a/src/tools/clippy/clippy_lints/src/manual_retain.rs b/src/tools/clippy/clippy_lints/src/manual_retain.rs index 780dfa30846e1..a7536be407ec9 100644 --- a/src/tools/clippy/clippy_lints/src/manual_retain.rs +++ b/src/tools/clippy/clippy_lints/src/manual_retain.rs @@ -7,6 +7,7 @@ use clippy_utils::{SpanlessEq, sym}; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_hir::ExprKind::Assign; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::def_id::DefId; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; @@ -189,7 +190,7 @@ fn check_to_owned( && let Some(chars_expr_def_id) = cx.typeck_results().type_dependent_def_id(chars_expr.hir_id) && cx.tcx.is_diagnostic_item(sym::str_chars, chars_expr_def_id) && let ty = cx.typeck_results().expr_ty(str_expr).peel_refs() - && ty.is_lang_item(cx, hir::LangItem::String) + && ty.is_lang_item(cx, LangItem::String) && SpanlessEq::new(cx).eq_expr(parent_expr_span.ctxt(), left_expr, str_expr) && let hir::ExprKind::MethodCall(_, _, [closure_expr], _) = filter_expr.kind && let hir::ExprKind::Closure(closure) = closure_expr.kind diff --git a/src/tools/clippy/clippy_lints/src/matches/manual_map.rs b/src/tools/clippy/clippy_lints/src/matches/manual_map.rs index 5e8d69a5b4e8b..2331f4e910052 100644 --- a/src/tools/clippy/clippy_lints/src/matches/manual_map.rs +++ b/src/tools/clippy/clippy_lints/src/matches/manual_map.rs @@ -3,7 +3,7 @@ use super::manual_utils::{SomeExpr, check_with}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::res::{MaybeDef as _, MaybeQPath as _}; -use rustc_hir::LangItem::OptionSome; +use rustc_hir::attrs::lang::LangItem::OptionSome; use rustc_hir::{Arm, Block, BlockCheckMode, Expr, ExprKind, Pat, UnsafeSource}; use rustc_lint::LateContext; use rustc_span::SyntaxContext; diff --git a/src/tools/clippy/clippy_lints/src/matches/manual_ok_err.rs b/src/tools/clippy/clippy_lints/src/matches/manual_ok_err.rs index c599099d3ce42..cf56fc67d08d0 100644 --- a/src/tools/clippy/clippy_lints/src/matches/manual_ok_err.rs +++ b/src/tools/clippy/clippy_lints/src/matches/manual_ok_err.rs @@ -6,7 +6,7 @@ use clippy_utils::ty::{option_arg_ty, peel_and_count_ty_refs}; use clippy_utils::{as_some_expr, get_parent_expr, is_none_expr, peel_blocks, span_contains_comment}; use rustc_ast::{BindingMode, Mutability}; use rustc_errors::Applicability; -use rustc_hir::LangItem::ResultErr; +use rustc_hir::attrs::lang::LangItem::ResultErr; use rustc_hir::def::{DefKind, Res}; use rustc_hir::{Arm, Expr, ExprKind, Pat, PatExpr, PatExprKind, PatKind, Path, QPath}; use rustc_lint::LateContext; diff --git a/src/tools/clippy/clippy_lints/src/matches/manual_unwrap_or.rs b/src/tools/clippy/clippy_lints/src/matches/manual_unwrap_or.rs index a5c61fafb514c..007aec0726dbc 100644 --- a/src/tools/clippy/clippy_lints/src/matches/manual_unwrap_or.rs +++ b/src/tools/clippy/clippy_lints/src/matches/manual_unwrap_or.rs @@ -3,8 +3,9 @@ use clippy_utils::res::{MaybeDef as _, MaybeQPath as _, MaybeResPath as _}; use clippy_utils::source::{SpanExt as _, indent_of, reindent_multiline}; use rustc_ast::{BindingMode, ByRef}; use rustc_errors::Applicability; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::def::Res; -use rustc_hir::{Arm, Expr, ExprKind, HirId, LangItem, Pat, PatKind, QPath}; +use rustc_hir::{Arm, Expr, ExprKind, HirId, Pat, PatKind, QPath}; use rustc_lint::LateContext; use rustc_middle::ty::{GenericArgKind, Ty}; use rustc_span::sym; diff --git a/src/tools/clippy/clippy_lints/src/matches/match_str_case_mismatch.rs b/src/tools/clippy/clippy_lints/src/matches/match_str_case_mismatch.rs index 874feb9b4b189..61ddda97b23f4 100644 --- a/src/tools/clippy/clippy_lints/src/matches/match_str_case_mismatch.rs +++ b/src/tools/clippy/clippy_lints/src/matches/match_str_case_mismatch.rs @@ -5,8 +5,9 @@ use clippy_utils::res::MaybeDef as _; use clippy_utils::sym; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::intravisit::{Visitor, walk_expr}; -use rustc_hir::{Arm, Expr, ExprKind, LangItem, PatExpr, PatExprKind, PatKind}; +use rustc_hir::{Arm, Expr, ExprKind, PatExpr, PatExprKind, PatKind}; use rustc_lint::LateContext; use rustc_middle::ty; use rustc_span::Span; diff --git a/src/tools/clippy/clippy_lints/src/matches/redundant_pattern_match.rs b/src/tools/clippy/clippy_lints/src/matches/redundant_pattern_match.rs index 2a236cfa15979..61c83030d073d 100644 --- a/src/tools/clippy/clippy_lints/src/matches/redundant_pattern_match.rs +++ b/src/tools/clippy/clippy_lints/src/matches/redundant_pattern_match.rs @@ -7,7 +7,7 @@ use clippy_utils::visitors::{any_temporaries_need_ordered_drop, for_each_expr_wi use clippy_utils::{get_parent_expr, higher, is_expn_of, sym}; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; -use rustc_hir::LangItem::{self, OptionNone, OptionSome, PollPending, PollReady, ResultErr, ResultOk}; +use rustc_hir::attrs::lang::LangItem::{self, OptionNone, OptionSome, PollPending, PollReady, ResultErr, ResultOk}; use rustc_hir::def::{DefKind, Res}; use rustc_hir::{Arm, BinOpKind, Expr, ExprKind, Node, Pat, PatExpr, PatExprKind, PatKind, QPath, UnOp}; use rustc_lint::LateContext; diff --git a/src/tools/clippy/clippy_lints/src/matches/try_err.rs b/src/tools/clippy/clippy_lints/src/matches/try_err.rs index 81dc46a2fa992..f03fb1c08d74d 100644 --- a/src/tools/clippy/clippy_lints/src/matches/try_err.rs +++ b/src/tools/clippy/clippy_lints/src/matches/try_err.rs @@ -4,8 +4,9 @@ use clippy_utils::res::{MaybeDef as _, MaybeQPath as _}; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::option_arg_ty; use rustc_errors::Applicability; -use rustc_hir::LangItem::ResultErr; -use rustc_hir::{Expr, ExprKind, LangItem, MatchSource}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::attrs::lang::LangItem::ResultErr; +use rustc_hir::{Expr, ExprKind, MatchSource}; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; use rustc_span::{hygiene, sym}; diff --git a/src/tools/clippy/clippy_lints/src/methods/bind_instead_of_map.rs b/src/tools/clippy/clippy_lints/src/methods/bind_instead_of_map.rs index 6390680c067cb..c0eff27fbbda0 100644 --- a/src/tools/clippy/clippy_lints/src/methods/bind_instead_of_map.rs +++ b/src/tools/clippy/clippy_lints/src/methods/bind_instead_of_map.rs @@ -5,8 +5,9 @@ use clippy_utils::source::{snippet, snippet_with_context}; use clippy_utils::visitors::find_all_ret_expressions; use rustc_errors::Applicability; use rustc_hir as hir; +use rustc_hir::QPath; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; -use rustc_hir::{LangItem, QPath}; use rustc_lint::LateContext; use rustc_span::Span; diff --git a/src/tools/clippy/clippy_lints/src/methods/bytes_count_to_len.rs b/src/tools/clippy/clippy_lints/src/methods/bytes_count_to_len.rs index abf551590573b..e5825a8ccc299 100644 --- a/src/tools/clippy/clippy_lints/src/methods/bytes_count_to_len.rs +++ b/src/tools/clippy/clippy_lints/src/methods/bytes_count_to_len.rs @@ -3,6 +3,7 @@ use clippy_utils::res::MaybeDef as _; use clippy_utils::source::snippet_with_applicability; use rustc_errors::Applicability; use rustc_hir as hir; +use rustc_hir::attrs::lang::LangItem; use rustc_lint::LateContext; use super::BYTES_COUNT_TO_LEN; @@ -17,7 +18,7 @@ pub(super) fn check<'tcx>( && let Some(impl_id) = cx.tcx.impl_of_assoc(bytes_id) && cx.tcx.type_of(impl_id).instantiate_identity().skip_norm_wip().is_str() && let ty = cx.typeck_results().expr_ty(bytes_recv).peel_refs() - && (ty.is_str() || ty.is_lang_item(cx, hir::LangItem::String)) + && (ty.is_str() || ty.is_lang_item(cx, LangItem::String)) { let mut applicability = Applicability::MachineApplicable; span_lint_and_sugg( diff --git a/src/tools/clippy/clippy_lints/src/methods/bytes_nth.rs b/src/tools/clippy/clippy_lints/src/methods/bytes_nth.rs index c0db96fd8becf..7627b5bda48ed 100644 --- a/src/tools/clippy/clippy_lints/src/methods/bytes_nth.rs +++ b/src/tools/clippy/clippy_lints/src/methods/bytes_nth.rs @@ -3,7 +3,8 @@ use clippy_utils::res::MaybeDef as _; use clippy_utils::source::snippet_with_applicability; use clippy_utils::sym; use rustc_errors::Applicability; -use rustc_hir::{Expr, LangItem}; +use rustc_hir::Expr; +use rustc_hir::attrs::lang::LangItem; use rustc_lint::LateContext; use crate::methods::method_call; diff --git a/src/tools/clippy/clippy_lints/src/methods/case_sensitive_file_extension_comparisons.rs b/src/tools/clippy/clippy_lints/src/methods/case_sensitive_file_extension_comparisons.rs index 894af02176954..f688f3a01e976 100644 --- a/src/tools/clippy/clippy_lints/src/methods/case_sensitive_file_extension_comparisons.rs +++ b/src/tools/clippy/clippy_lints/src/methods/case_sensitive_file_extension_comparisons.rs @@ -5,7 +5,8 @@ use clippy_utils::source::{SpanExt as _, indent_of, reindent_multiline}; use clippy_utils::sym; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; -use rustc_hir::{Expr, ExprKind, LangItem}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; use rustc_span::{Span, Spanned}; diff --git a/src/tools/clippy/clippy_lints/src/methods/clear_with_drain.rs b/src/tools/clippy/clippy_lints/src/methods/clear_with_drain.rs index 6ef89788fbf82..0ec9f8b4e0bf3 100644 --- a/src/tools/clippy/clippy_lints/src/methods/clear_with_drain.rs +++ b/src/tools/clippy/clippy_lints/src/methods/clear_with_drain.rs @@ -2,7 +2,8 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::res::{MaybeDef as _, MaybeResPath as _}; use clippy_utils::{is_full_collection_range, sym}; use rustc_errors::Applicability; -use rustc_hir::{Expr, LangItem}; +use rustc_hir::Expr; +use rustc_hir::attrs::lang::LangItem; use rustc_lint::LateContext; use rustc_span::Span; diff --git a/src/tools/clippy/clippy_lints/src/methods/clone_on_copy.rs b/src/tools/clippy/clippy_lints/src/methods/clone_on_copy.rs index f63ea13fd1c6d..342d0ac411390 100644 --- a/src/tools/clippy/clippy_lints/src/methods/clone_on_copy.rs +++ b/src/tools/clippy/clippy_lints/src/methods/clone_on_copy.rs @@ -1,16 +1,16 @@ +use super::CLONE_ON_COPY; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::peel_hir_expr_refs; use clippy_utils::source::snippet_with_context; use clippy_utils::ty::is_copy; use rustc_errors::Applicability; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::{BindingMode, ByRef, Expr, ExprKind, MatchSource, Node, PatKind}; use rustc_lint::LateContext; use rustc_middle::ty; use rustc_middle::ty::adjustment::Adjust; use rustc_middle::ty::print::with_forced_trimmed_paths; -use super::CLONE_ON_COPY; - #[derive(Clone, Copy, Debug, PartialEq, Eq)] enum ParentIsSuffixExpr { Yes, @@ -35,7 +35,7 @@ fn check_parent_is_suffix_expr(cx: &LateContext<'_>, expr: &Expr<'_>) -> ParentI if matches!( hir_callee.kind, ExprKind::Path(qpath) - if cx.tcx.qpath_is_lang_item(qpath, rustc_hir::LangItem::TryTraitBranch) + if cx.tcx.qpath_is_lang_item(qpath, LangItem::TryTraitBranch) ) { ParentIsSuffixExpr::Yes } else { diff --git a/src/tools/clippy/clippy_lints/src/methods/expect_fun_call.rs b/src/tools/clippy/clippy_lints/src/methods/expect_fun_call.rs index 609cab45d42d1..0ec06fcce06ac 100644 --- a/src/tools/clippy/clippy_lints/src/methods/expect_fun_call.rs +++ b/src/tools/clippy/clippy_lints/src/methods/expect_fun_call.rs @@ -1,3 +1,4 @@ +use super::EXPECT_FUN_CALL; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::macros::{FormatArgsStorage, format_args_inputs_span, root_macro_call_first_node}; use clippy_utils::res::MaybeDef as _; @@ -6,13 +7,12 @@ use clippy_utils::visitors::for_each_expr; use clippy_utils::{contains_return, is_inside_always_const_context, peel_blocks, sym}; use rustc_errors::Applicability; use rustc_hir as hir; +use rustc_hir::attrs::lang::LangItem; use rustc_lint::LateContext; use rustc_span::Span; use std::borrow::Cow; use std::ops::ControlFlow; -use super::EXPECT_FUN_CALL; - /// Checks for the `EXPECT_FUN_CALL` lint. pub(super) fn check<'tcx>( cx: &LateContext<'tcx>, @@ -86,7 +86,7 @@ fn get_arg_root<'a>(cx: &LateContext<'_>, arg: &'a hir::Expr<'a>) -> &'a hir::Ex if (method_name.ident.name == sym::as_str || method_name.ident.name == sym::as_ref) && { let arg_type = cx.typeck_results().expr_ty(receiver); let base_type = arg_type.peel_refs(); - base_type.is_str() || base_type.is_lang_item(cx, hir::LangItem::String) + base_type.is_str() || base_type.is_lang_item(cx, LangItem::String) } { receiver } else { diff --git a/src/tools/clippy/clippy_lints/src/methods/extend_with_drain.rs b/src/tools/clippy/clippy_lints/src/methods/extend_with_drain.rs index af8128104f859..39ac9fa1aa535 100644 --- a/src/tools/clippy/clippy_lints/src/methods/extend_with_drain.rs +++ b/src/tools/clippy/clippy_lints/src/methods/extend_with_drain.rs @@ -3,7 +3,8 @@ use clippy_utils::res::MaybeDef as _; use clippy_utils::source::snippet_with_applicability; use clippy_utils::sym; use rustc_errors::Applicability; -use rustc_hir::{Expr, ExprKind, LangItem}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; use super::EXTEND_WITH_DRAIN; diff --git a/src/tools/clippy/clippy_lints/src/methods/format_collect.rs b/src/tools/clippy/clippy_lints/src/methods/format_collect.rs index b85e203e4d2e2..de80a9b12f7c5 100644 --- a/src/tools/clippy/clippy_lints/src/methods/format_collect.rs +++ b/src/tools/clippy/clippy_lints/src/methods/format_collect.rs @@ -2,7 +2,8 @@ use super::FORMAT_COLLECT; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::macros::{is_format_macro, root_macro_call_first_node}; use clippy_utils::res::MaybeDef as _; -use rustc_hir::{Expr, ExprKind, LangItem}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; use rustc_span::Span; diff --git a/src/tools/clippy/clippy_lints/src/methods/inefficient_to_string.rs b/src/tools/clippy/clippy_lints/src/methods/inefficient_to_string.rs index 8e9781f668995..b7d2a7402fb58 100644 --- a/src/tools/clippy/clippy_lints/src/methods/inefficient_to_string.rs +++ b/src/tools/clippy/clippy_lints/src/methods/inefficient_to_string.rs @@ -6,6 +6,7 @@ use clippy_utils::sym; use clippy_utils::ty::peel_and_count_ty_refs; use rustc_errors::Applicability; use rustc_hir as hir; +use rustc_hir::attrs::lang::LangItem; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; @@ -52,7 +53,7 @@ fn specializes_tostring(cx: &LateContext<'_>, ty: Ty<'_>) -> bool { return true; } - if ty.is_lang_item(cx, hir::LangItem::String) { + if ty.is_lang_item(cx, LangItem::String) { return true; } diff --git a/src/tools/clippy/clippy_lints/src/methods/iter_nth_zero.rs b/src/tools/clippy/clippy_lints/src/methods/iter_nth_zero.rs index 3417d689c7ff2..9d459d9aee233 100644 --- a/src/tools/clippy/clippy_lints/src/methods/iter_nth_zero.rs +++ b/src/tools/clippy/clippy_lints/src/methods/iter_nth_zero.rs @@ -3,7 +3,8 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::is_lang_item_or_ctor; use clippy_utils::res::{MaybeDef as _, MaybeTypeckRes as _}; use clippy_utils::source::snippet_with_applicability; -use hir::{LangItem, OwnerNode}; +use hir::OwnerNode; +use hir::attrs::lang::LangItem; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; diff --git a/src/tools/clippy/clippy_lints/src/methods/manual_clear.rs b/src/tools/clippy/clippy_lints/src/methods/manual_clear.rs index 025788b83b5b9..dfe3fafd2b590 100644 --- a/src/tools/clippy/clippy_lints/src/methods/manual_clear.rs +++ b/src/tools/clippy/clippy_lints/src/methods/manual_clear.rs @@ -2,7 +2,8 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::res::MaybeDef as _; use clippy_utils::{is_integer_literal, sym}; use rustc_errors::Applicability; -use rustc_hir::{Expr, LangItem}; +use rustc_hir::Expr; +use rustc_hir::attrs::lang::LangItem; use rustc_lint::LateContext; use rustc_span::Span; diff --git a/src/tools/clippy/clippy_lints/src/methods/manual_ok_or.rs b/src/tools/clippy/clippy_lints/src/methods/manual_ok_or.rs index b010f7a8996fa..f53cb40ca6f05 100644 --- a/src/tools/clippy/clippy_lints/src/methods/manual_ok_or.rs +++ b/src/tools/clippy/clippy_lints/src/methods/manual_ok_or.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::res::{MaybeDef as _, MaybeQPath as _, MaybeResPath as _}; use clippy_utils::source::{SpanExt as _, indent_of, reindent_multiline}; use rustc_errors::Applicability; -use rustc_hir::LangItem::{ResultErr, ResultOk}; +use rustc_hir::attrs::lang::LangItem::{ResultErr, ResultOk}; use rustc_hir::{Expr, ExprKind, PatKind}; use rustc_lint::LateContext; use rustc_span::symbol::sym; diff --git a/src/tools/clippy/clippy_lints/src/methods/manual_str_repeat.rs b/src/tools/clippy/clippy_lints/src/methods/manual_str_repeat.rs index d04e224adf7af..2b1b7f6469b63 100644 --- a/src/tools/clippy/clippy_lints/src/methods/manual_str_repeat.rs +++ b/src/tools/clippy/clippy_lints/src/methods/manual_str_repeat.rs @@ -5,7 +5,8 @@ use clippy_utils::sugg::Sugg; use clippy_utils::sym; use rustc_ast::LitKind; use rustc_errors::Applicability; -use rustc_hir::{Expr, ExprKind, LangItem}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; use rustc_middle::ty::{self, Ty}; use std::borrow::Cow; diff --git a/src/tools/clippy/clippy_lints/src/methods/map_clone.rs b/src/tools/clippy/clippy_lints/src/methods/map_clone.rs index f25cbb265c57f..98240ca5c7511 100644 --- a/src/tools/clippy/clippy_lints/src/methods/map_clone.rs +++ b/src/tools/clippy/clippy_lints/src/methods/map_clone.rs @@ -5,8 +5,9 @@ use clippy_utils::res::MaybeDef as _; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::{is_copy, should_call_clone_as_function}; use rustc_errors::Applicability; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::def_id::DefId; -use rustc_hir::{self as hir, LangItem}; +use rustc_hir::{self as hir}; use rustc_lint::LateContext; use rustc_middle::mir::{Mutability, Pinnedness}; use rustc_middle::ty; diff --git a/src/tools/clippy/clippy_lints/src/methods/needless_as_bytes.rs b/src/tools/clippy/clippy_lints/src/methods/needless_as_bytes.rs index 6a20d401419ff..5ddf385130a24 100644 --- a/src/tools/clippy/clippy_lints/src/methods/needless_as_bytes.rs +++ b/src/tools/clippy/clippy_lints/src/methods/needless_as_bytes.rs @@ -2,7 +2,8 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::res::MaybeDef as _; use clippy_utils::sugg::Sugg; use rustc_errors::Applicability; -use rustc_hir::{Expr, LangItem}; +use rustc_hir::Expr; +use rustc_hir::attrs::lang::LangItem; use rustc_lint::LateContext; use rustc_span::{Span, Symbol}; diff --git a/src/tools/clippy/clippy_lints/src/methods/no_effect_replace.rs b/src/tools/clippy/clippy_lints/src/methods/no_effect_replace.rs index 667608cf992ef..27e55718530de 100644 --- a/src/tools/clippy/clippy_lints/src/methods/no_effect_replace.rs +++ b/src/tools/clippy/clippy_lints/src/methods/no_effect_replace.rs @@ -2,7 +2,8 @@ use clippy_utils::SpanlessEq; use clippy_utils::diagnostics::span_lint; use clippy_utils::res::MaybeDef as _; use rustc_ast::LitKind; -use rustc_hir::{ExprKind, LangItem}; +use rustc_hir::ExprKind; +use rustc_hir::attrs::lang::LangItem; use rustc_lint::LateContext; use super::NO_EFFECT_REPLACE; diff --git a/src/tools/clippy/clippy_lints/src/methods/option_map_or_none.rs b/src/tools/clippy/clippy_lints/src/methods/option_map_or_none.rs index 98c8e15756931..991d161d7dc4b 100644 --- a/src/tools/clippy/clippy_lints/src/methods/option_map_or_none.rs +++ b/src/tools/clippy/clippy_lints/src/methods/option_map_or_none.rs @@ -4,7 +4,7 @@ use clippy_utils::res::{MaybeDef as _, MaybeQPath as _}; use clippy_utils::source::snippet; use rustc_errors::Applicability; use rustc_hir as hir; -use rustc_hir::LangItem::OptionSome; +use rustc_hir::attrs::lang::LangItem::OptionSome; use rustc_lint::LateContext; use rustc_span::symbol::sym; diff --git a/src/tools/clippy/clippy_lints/src/methods/or_then_unwrap.rs b/src/tools/clippy/clippy_lints/src/methods/or_then_unwrap.rs index 3be6e8b62ec99..2679049cb59f8 100644 --- a/src/tools/clippy/clippy_lints/src/methods/or_then_unwrap.rs +++ b/src/tools/clippy/clippy_lints/src/methods/or_then_unwrap.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::res::{MaybeDef as _, MaybeQPath as _}; use clippy_utils::source::snippet_with_applicability; use rustc_errors::Applicability; -use rustc_hir::lang_items::LangItem; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; use rustc_span::{Span, sym}; diff --git a/src/tools/clippy/clippy_lints/src/methods/repeat_once.rs b/src/tools/clippy/clippy_lints/src/methods/repeat_once.rs index 6fe19a932d545..5f4b1b24a4542 100644 --- a/src/tools/clippy/clippy_lints/src/methods/repeat_once.rs +++ b/src/tools/clippy/clippy_lints/src/methods/repeat_once.rs @@ -3,7 +3,8 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::res::MaybeDef as _; use clippy_utils::source::snippet; use rustc_errors::Applicability; -use rustc_hir::{Expr, LangItem}; +use rustc_hir::Expr; +use rustc_hir::attrs::lang::LangItem; use rustc_lint::LateContext; use super::REPEAT_ONCE; diff --git a/src/tools/clippy/clippy_lints/src/methods/result_map_or_else_none.rs b/src/tools/clippy/clippy_lints/src/methods/result_map_or_else_none.rs index 7cf30bb4e9c08..be2529d4591b7 100644 --- a/src/tools/clippy/clippy_lints/src/methods/result_map_or_else_none.rs +++ b/src/tools/clippy/clippy_lints/src/methods/result_map_or_else_none.rs @@ -4,7 +4,7 @@ use clippy_utils::source::snippet; use clippy_utils::{is_none_expr, peel_blocks}; use rustc_errors::Applicability; use rustc_hir as hir; -use rustc_hir::LangItem::OptionSome; +use rustc_hir::attrs::lang::LangItem::OptionSome; use rustc_lint::LateContext; use rustc_span::symbol::sym; diff --git a/src/tools/clippy/clippy_lints/src/methods/search_is_some.rs b/src/tools/clippy/clippy_lints/src/methods/search_is_some.rs index 9e9d53cabbb0d..4f3abbe650722 100644 --- a/src/tools/clippy/clippy_lints/src/methods/search_is_some.rs +++ b/src/tools/clippy/clippy_lints/src/methods/search_is_some.rs @@ -7,6 +7,7 @@ use hir::ExprKind; use rustc_errors::Applicability; use rustc_hir as hir; use rustc_hir::PatKind; +use rustc_hir::attrs::lang::LangItem; use rustc_lint::LateContext; use rustc_span::{Span, Symbol}; @@ -101,7 +102,7 @@ pub(super) fn check<'tcx>( else if search_method == sym::find { let is_string_or_str_slice = |e| { let self_ty = cx.typeck_results().expr_ty(e).peel_refs(); - if self_ty.is_lang_item(cx, hir::LangItem::String) { + if self_ty.is_lang_item(cx, LangItem::String) { true } else { self_ty.is_str() diff --git a/src/tools/clippy/clippy_lints/src/methods/sliced_string_as_bytes.rs b/src/tools/clippy/clippy_lints/src/methods/sliced_string_as_bytes.rs index f581384ca5415..7a48180475392 100644 --- a/src/tools/clippy/clippy_lints/src/methods/sliced_string_as_bytes.rs +++ b/src/tools/clippy/clippy_lints/src/methods/sliced_string_as_bytes.rs @@ -3,7 +3,8 @@ use clippy_utils::higher; use clippy_utils::res::MaybeDef as _; use clippy_utils::source::snippet_with_applicability; use rustc_errors::Applicability; -use rustc_hir::{Expr, ExprKind, LangItem}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; use super::SLICED_STRING_AS_BYTES; diff --git a/src/tools/clippy/clippy_lints/src/methods/str_splitn.rs b/src/tools/clippy/clippy_lints/src/methods/str_splitn.rs index 6d319dcd1e678..444f8baec87ff 100644 --- a/src/tools/clippy/clippy_lints/src/methods/str_splitn.rs +++ b/src/tools/clippy/clippy_lints/src/methods/str_splitn.rs @@ -8,9 +8,8 @@ use clippy_utils::visitors::{Descend, for_each_expr}; use clippy_utils::{paths, sym}; use core::ops::ControlFlow; use rustc_errors::Applicability; -use rustc_hir::{ - BindingMode, Expr, ExprKind, HirId, LangItem, LetStmt, MatchSource, Node, Pat, PatKind, Stmt, StmtKind, -}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{BindingMode, Expr, ExprKind, HirId, LetStmt, MatchSource, Node, Pat, PatKind, Stmt, StmtKind}; use rustc_lint::LateContext; use rustc_middle::ty; use rustc_span::{Span, Symbol, SyntaxContext}; diff --git a/src/tools/clippy/clippy_lints/src/methods/string_extend_chars.rs b/src/tools/clippy/clippy_lints/src/methods/string_extend_chars.rs index f531abed813ce..f79dc0d62d80e 100644 --- a/src/tools/clippy/clippy_lints/src/methods/string_extend_chars.rs +++ b/src/tools/clippy/clippy_lints/src/methods/string_extend_chars.rs @@ -1,16 +1,16 @@ +use super::STRING_EXTEND_CHARS; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::res::MaybeDef as _; use clippy_utils::source::snippet_with_applicability; use clippy_utils::{method_chain_args, sym}; use rustc_errors::Applicability; use rustc_hir as hir; +use rustc_hir::attrs::lang::LangItem; use rustc_lint::LateContext; -use super::STRING_EXTEND_CHARS; - pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr<'_>, arg: &hir::Expr<'_>) { let obj_ty = cx.typeck_results().expr_ty(recv).peel_refs(); - if !obj_ty.is_lang_item(cx, hir::LangItem::String) { + if !obj_ty.is_lang_item(cx, LangItem::String) { return; } if let Some(arglists) = method_chain_args(arg, &[sym::chars]) { @@ -22,7 +22,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr } else { "" } - } else if self_ty.is_lang_item(cx, hir::LangItem::String) { + } else if self_ty.is_lang_item(cx, LangItem::String) { "&" } else { return; diff --git a/src/tools/clippy/clippy_lints/src/methods/unnecessary_join.rs b/src/tools/clippy/clippy_lints/src/methods/unnecessary_join.rs index 193406942f3f8..1de37b39a2289 100644 --- a/src/tools/clippy/clippy_lints/src/methods/unnecessary_join.rs +++ b/src/tools/clippy/clippy_lints/src/methods/unnecessary_join.rs @@ -2,7 +2,8 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::res::MaybeDef as _; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; -use rustc_hir::{Expr, ExprKind, LangItem}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{Expr, ExprKind}; use rustc_lint::LateContext; use rustc_middle::ty; use rustc_span::Span; diff --git a/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs b/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs index 2952d81a3b00c..edb80ae0e37af 100644 --- a/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs +++ b/src/tools/clippy/clippy_lints/src/methods/unnecessary_to_owned.rs @@ -8,9 +8,10 @@ use clippy_utils::ty::{get_iterator_item_ty, implements_trait, is_copy, peel_and use clippy_utils::visitors::find_all_ret_expressions; use clippy_utils::{fn_def_id, get_parent_expr, is_expr_temporary_value, return_ty, sym}; use rustc_errors::Applicability; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; -use rustc_hir::{BorrowKind, Expr, ExprKind, ItemKind, LangItem, Node}; +use rustc_hir::{BorrowKind, Expr, ExprKind, ItemKind, Node}; use rustc_infer::infer::TyCtxtInferExt as _; use rustc_lint::LateContext; use rustc_middle::mir::Mutability; diff --git a/src/tools/clippy/clippy_lints/src/methods/useless_asref.rs b/src/tools/clippy/clippy_lints/src/methods/useless_asref.rs index 2eac3ffba3246..3c662e9f2b196 100644 --- a/src/tools/clippy/clippy_lints/src/methods/useless_asref.rs +++ b/src/tools/clippy/clippy_lints/src/methods/useless_asref.rs @@ -4,8 +4,9 @@ use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::{implements_trait, peel_and_count_ty_refs, should_call_clone_as_function}; use clippy_utils::{get_parent_expr, peel_blocks, strip_pat_refs}; use rustc_errors::Applicability; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::{self as hir, LangItem, Node}; +use rustc_hir::{self as hir, Node}; use rustc_lint::LateContext; use rustc_middle::ty::adjustment::{Adjust, DerefAdjustKind}; use rustc_middle::ty::{Ty, TyCtxt, TypeSuperVisitable as _, TypeVisitable as _, TypeVisitor}; diff --git a/src/tools/clippy/clippy_lints/src/missing_fields_in_debug.rs b/src/tools/clippy/clippy_lints/src/missing_fields_in_debug.rs index 6497e3283b392..6f982cc01197f 100644 --- a/src/tools/clippy/clippy_lints/src/missing_fields_in_debug.rs +++ b/src/tools/clippy/clippy_lints/src/missing_fields_in_debug.rs @@ -6,8 +6,9 @@ use clippy_utils::sym; use clippy_utils::visitors::{Visitable, for_each_expr}; use rustc_ast::LitKind; use rustc_data_structures::fx::FxHashSet; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::{Block, Expr, ExprKind, Impl, Item, ItemKind, LangItem, Node, QPath, TyKind, VariantData}; +use rustc_hir::{Block, Expr, ExprKind, Impl, Item, ItemKind, Node, QPath, TyKind, VariantData}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::{Ty, TypeckResults}; use rustc_session::declare_lint_pass; diff --git a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs index b0e11baa745a5..b04d78a26ebf1 100644 --- a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs +++ b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs @@ -6,10 +6,11 @@ use clippy_utils::visitors::{Descend, for_each_expr_without_closures}; use clippy_utils::{is_self, peel_hir_ty_options, strip_pat_refs, sym}; use rustc_abi::ExternAbi; use rustc_errors::{Applicability, Diag}; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::intravisit::FnKind; use rustc_hir::{ - Attribute, BindingMode, Body, ExprKind, FnDecl, GenericArg, HirId, HirIdSet, Impl, ItemKind, LangItem, Mutability, - Node, PatKind, QPath, TyKind, + Attribute, BindingMode, Body, ExprKind, FnDecl, GenericArg, HirId, HirIdSet, Impl, ItemKind, Mutability, Node, + PatKind, QPath, TyKind, }; use rustc_hir_typeck::expr_use_visitor as euv; use rustc_lint::{LateContext, LateLintPass}; diff --git a/src/tools/clippy/clippy_lints/src/needless_question_mark.rs b/src/tools/clippy/clippy_lints/src/needless_question_mark.rs index 933700f5f9e18..3387263fc9c82 100644 --- a/src/tools/clippy/clippy_lints/src/needless_question_mark.rs +++ b/src/tools/clippy/clippy_lints/src/needless_question_mark.rs @@ -1,8 +1,9 @@ use clippy_utils::diagnostics::span_lint_hir_and_then; use clippy_utils::res::MaybeQPath as _; use rustc_errors::Applicability; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::def::{DefKind, Res}; -use rustc_hir::{Block, Body, Expr, ExprKind, LangItem, MatchSource}; +use rustc_hir::{Block, Body, Expr, ExprKind, MatchSource}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; diff --git a/src/tools/clippy/clippy_lints/src/non_canonical_impls.rs b/src/tools/clippy/clippy_lints/src/non_canonical_impls.rs index 60408adc31b62..f7554adc38135 100644 --- a/src/tools/clippy/clippy_lints/src/non_canonical_impls.rs +++ b/src/tools/clippy/clippy_lints/src/non_canonical_impls.rs @@ -4,8 +4,9 @@ use clippy_utils::res::{MaybeDef as _, MaybeQPath as _}; use clippy_utils::ty::implements_trait; use clippy_utils::{is_from_proc_macro, is_lint_allowed, last_path_segment, std_or_core}; use rustc_errors::Applicability; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::def_id::DefId; -use rustc_hir::{Block, Body, Expr, ExprKind, ImplItem, ImplItemKind, Item, ItemKind, LangItem, Stmt, StmtKind, UnOp}; +use rustc_hir::{Block, Body, Expr, ExprKind, ImplItem, ImplItemKind, Item, ItemKind, Stmt, StmtKind, UnOp}; use rustc_lint::{LateContext, LateLintPass, LintContext as _}; use rustc_middle::ty::{TyCtxt, TypeckResults}; use rustc_session::impl_lint_pass; diff --git a/src/tools/clippy/clippy_lints/src/nonnull_unchecked_on_box_ptr.rs b/src/tools/clippy/clippy_lints/src/nonnull_unchecked_on_box_ptr.rs index 4ce51dffd6558..3bdd1aebfb668 100644 --- a/src/tools/clippy/clippy_lints/src/nonnull_unchecked_on_box_ptr.rs +++ b/src/tools/clippy/clippy_lints/src/nonnull_unchecked_on_box_ptr.rs @@ -6,7 +6,8 @@ use clippy_utils::source::snippet_with_context; use clippy_utils::sym; use clippy_utils::visitors::is_expr_unsafe; use rustc_errors::Applicability; -use rustc_hir::{Block, BlockCheckMode, Expr, ExprKind, LangItem, Node, UnsafeSource}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{Block, BlockCheckMode, Expr, ExprKind, Node, UnsafeSource}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; diff --git a/src/tools/clippy/clippy_lints/src/option_if_let_else.rs b/src/tools/clippy/clippy_lints/src/option_if_let_else.rs index 2be50f811e88f..27384f847797d 100644 --- a/src/tools/clippy/clippy_lints/src/option_if_let_else.rs +++ b/src/tools/clippy/clippy_lints/src/option_if_let_else.rs @@ -10,7 +10,7 @@ use clippy_utils::{ }; use rustc_data_structures::fx::FxHashSet; use rustc_errors::Applicability; -use rustc_hir::LangItem::ResultErr; +use rustc_hir::attrs::lang::LangItem::ResultErr; use rustc_hir::def::Res; use rustc_hir::intravisit::{Visitor, walk_expr, walk_path}; use rustc_hir::{ diff --git a/src/tools/clippy/clippy_lints/src/pub_underscore_fields.rs b/src/tools/clippy/clippy_lints/src/pub_underscore_fields.rs index f5a52187540d1..46adaa8d4a743 100644 --- a/src/tools/clippy/clippy_lints/src/pub_underscore_fields.rs +++ b/src/tools/clippy/clippy_lints/src/pub_underscore_fields.rs @@ -4,7 +4,8 @@ use clippy_utils::attrs::is_doc_hidden; use clippy_utils::diagnostics::span_lint_hir_and_then; use clippy_utils::res::{MaybeDef as _, MaybeResPath as _}; use clippy_utils::sym::PhantomPinned; -use rustc_hir::{FieldDef, Item, ItemKind, LangItem}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{FieldDef, Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; diff --git a/src/tools/clippy/clippy_lints/src/question_mark.rs b/src/tools/clippy/clippy_lints/src/question_mark.rs index c4a6b25e89cd5..b8be0738dd139 100644 --- a/src/tools/clippy/clippy_lints/src/question_mark.rs +++ b/src/tools/clippy/clippy_lints/src/question_mark.rs @@ -15,7 +15,7 @@ use clippy_utils::{ span_contains_cfg, span_contains_comment, sym, }; use rustc_errors::Applicability; -use rustc_hir::LangItem::{self, OptionNone, OptionSome, ResultErr, ResultOk}; +use rustc_hir::attrs::lang::LangItem::{self, OptionNone, OptionSome, ResultErr, ResultOk}; use rustc_hir::def::Res; use rustc_hir::{ Arm, BindingMode, Block, Body, ByRef, Expr, ExprKind, FnRetTy, HirId, LetStmt, MatchSource, Mutability, Node, Pat, diff --git a/src/tools/clippy/clippy_lints/src/ranges.rs b/src/tools/clippy/clippy_lints/src/ranges.rs index bd5d3c8980fdf..373d408d8ea03 100644 --- a/src/tools/clippy/clippy_lints/src/ranges.rs +++ b/src/tools/clippy/clippy_lints/src/ranges.rs @@ -12,7 +12,8 @@ use clippy_utils::{ use rustc_ast::Mutability; use rustc_ast::ast::RangeLimits; use rustc_errors::Applicability; -use rustc_hir::{BinOpKind, Expr, ExprKind, HirId, LangItem, Node}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{BinOpKind, Expr, ExprKind, HirId, Node}; use rustc_lint::{LateContext, LateLintPass, Lint}; use rustc_middle::ty::{self, ClauseKind, GenericArgKind, PredicatePolarity, Ty}; use rustc_session::impl_lint_pass; diff --git a/src/tools/clippy/clippy_lints/src/redundant_clone.rs b/src/tools/clippy/clippy_lints/src/redundant_clone.rs index eeef64de2cef6..28705d6b070cb 100644 --- a/src/tools/clippy/clippy_lints/src/redundant_clone.rs +++ b/src/tools/clippy/clippy_lints/src/redundant_clone.rs @@ -5,8 +5,9 @@ use clippy_utils::source::SpanExt as _; use clippy_utils::ty::{has_drop, is_copy, peel_and_count_ty_refs}; use clippy_utils::{fn_has_unsatisfiable_clauses, sym}; use rustc_errors::Applicability; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::intravisit::FnKind; -use rustc_hir::{Body, FnDecl, LangItem, def_id}; +use rustc_hir::{Body, FnDecl, def_id}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::mir; use rustc_middle::ty::{self, Ty}; diff --git a/src/tools/clippy/clippy_lints/src/redundant_slicing.rs b/src/tools/clippy/clippy_lints/src/redundant_slicing.rs index f0a0e4220444f..d03dbb2adc6e2 100644 --- a/src/tools/clippy/clippy_lints/src/redundant_slicing.rs +++ b/src/tools/clippy/clippy_lints/src/redundant_slicing.rs @@ -5,7 +5,8 @@ use clippy_utils::source::snippet_with_context; use clippy_utils::ty::peel_and_count_ty_refs; use rustc_ast::util::parser::ExprPrecedence; use rustc_errors::Applicability; -use rustc_hir::{BorrowKind, Expr, ExprKind, LangItem, Mutability}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability}; use rustc_lint::{LateContext, LateLintPass, Lint}; use rustc_middle::ty::adjustment::{Adjust, AutoBorrow, AutoBorrowMutability}; use rustc_middle::ty::{self, GenericArg, Ty, Unnormalized}; diff --git a/src/tools/clippy/clippy_lints/src/replace_box.rs b/src/tools/clippy/clippy_lints/src/replace_box.rs index 95f2f8da2c647..3ab1a718fd508 100644 --- a/src/tools/clippy/clippy_lints/src/replace_box.rs +++ b/src/tools/clippy/clippy_lints/src/replace_box.rs @@ -6,7 +6,8 @@ use clippy_utils::{is_default_equivalent_call, local_is_initialized}; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::smallvec::SmallVec; use rustc_errors::Applicability; -use rustc_hir::{Body, BodyId, Expr, ExprKind, HirId, LangItem, QPath}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{Body, BodyId, Expr, ExprKind, HirId, QPath}; use rustc_hir_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::hir::place::ProjectionKind; diff --git a/src/tools/clippy/clippy_lints/src/returns/needless_return.rs b/src/tools/clippy/clippy_lints/src/returns/needless_return.rs index ad81b5efcfe13..3658333884f45 100644 --- a/src/tools/clippy/clippy_lints/src/returns/needless_return.rs +++ b/src/tools/clippy/clippy_lints/src/returns/needless_return.rs @@ -6,8 +6,9 @@ use clippy_utils::{ }; use rustc_ast::MetaItemInner; use rustc_errors::Applicability; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::intravisit::FnKind; -use rustc_hir::{Body, Expr, ExprKind, HirId, LangItem, MatchSource, StmtKind}; +use rustc_hir::{Body, Expr, ExprKind, HirId, MatchSource, StmtKind}; use rustc_lint::{LateContext, Level, LintContext as _}; use rustc_middle::ty::{self, Ty}; use rustc_span::{BytePos, Pos as _, Span}; diff --git a/src/tools/clippy/clippy_lints/src/returns/needless_return_with_question_mark.rs b/src/tools/clippy/clippy_lints/src/returns/needless_return_with_question_mark.rs index 40e66220a0c94..60857c00ecde7 100644 --- a/src/tools/clippy/clippy_lints/src/returns/needless_return_with_question_mark.rs +++ b/src/tools/clippy/clippy_lints/src/returns/needless_return_with_question_mark.rs @@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::res::{MaybeDef as _, MaybeQPath as _}; use clippy_utils::{is_from_proc_macro, is_inside_let_else}; use rustc_errors::Applicability; -use rustc_hir::LangItem::ResultErr; +use rustc_hir::attrs::lang::LangItem::ResultErr; use rustc_hir::{Expr, ExprKind, HirId, MatchSource, Node, Stmt, StmtKind}; use rustc_lint::{LateContext, LintContext as _}; use rustc_middle::ty::adjustment::Adjust; diff --git a/src/tools/clippy/clippy_lints/src/same_length_and_capacity.rs b/src/tools/clippy/clippy_lints/src/same_length_and_capacity.rs index fcd23619f9ed2..683fd8e1a9e17 100644 --- a/src/tools/clippy/clippy_lints/src/same_length_and_capacity.rs +++ b/src/tools/clippy/clippy_lints/src/same_length_and_capacity.rs @@ -1,7 +1,8 @@ use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::res::MaybeDef as _; use clippy_utils::{eq_expr_value, sym}; -use rustc_hir::{Expr, ExprKind, LangItem, QPath}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{Expr, ExprKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; use rustc_span::symbol::sym as rustc_sym; diff --git a/src/tools/clippy/clippy_lints/src/std_instead_of_core.rs b/src/tools/clippy/clippy_lints/src/std_instead_of_core.rs index 3f4ba4724e942..c2dced156ed72 100644 --- a/src/tools/clippy/clippy_lints/src/std_instead_of_core.rs +++ b/src/tools/clippy/clippy_lints/src/std_instead_of_core.rs @@ -3,9 +3,10 @@ use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg}; use clippy_utils::is_from_proc_macro; use clippy_utils::msrvs::Msrv; use rustc_errors::Applicability; +use rustc_hir::attrs::{StabilityLevel, StableSince}; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; -use rustc_hir::{Block, Body, HirId, Path, PathSegment, StabilityLevel, StableSince}; +use rustc_hir::{Block, Body, HirId, Path, PathSegment}; use rustc_lint::{LateContext, LateLintPass, Lint, LintContext as _}; use rustc_session::impl_lint_pass; use rustc_span::symbol::kw; diff --git a/src/tools/clippy/clippy_lints/src/strings.rs b/src/tools/clippy/clippy_lints/src/strings.rs index 6cbbcc681f944..1714415593caa 100644 --- a/src/tools/clippy/clippy_lints/src/strings.rs +++ b/src/tools/clippy/clippy_lints/src/strings.rs @@ -3,9 +3,10 @@ use clippy_utils::res::{MaybeDef as _, MaybeQPath as _}; use clippy_utils::source::{snippet, snippet_with_applicability, snippet_with_context}; use clippy_utils::{SpanlessEq, get_expr_use_or_unification_node, get_parent_expr, is_lint_allowed, method_calls, sym}; use rustc_errors::Applicability; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; -use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, LangItem, Node}; +use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, Node}; use rustc_lint::{LateContext, LateLintPass, LintContext as _}; use rustc_middle::ty; use rustc_session::declare_lint_pass; diff --git a/src/tools/clippy/clippy_lints/src/strlen_on_c_strings.rs b/src/tools/clippy/clippy_lints/src/strlen_on_c_strings.rs index c784c1744743f..44f055cb0261d 100644 --- a/src/tools/clippy/clippy_lints/src/strlen_on_c_strings.rs +++ b/src/tools/clippy/clippy_lints/src/strlen_on_c_strings.rs @@ -6,7 +6,8 @@ use clippy_utils::source::snippet_with_context; use clippy_utils::visitors::is_expr_unsafe; use clippy_utils::{match_libc_symbol, sym}; use rustc_errors::Applicability; -use rustc_hir::{Block, BlockCheckMode, Expr, ExprKind, LangItem, Node, UnsafeSource}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{Block, BlockCheckMode, Expr, ExprKind, Node, UnsafeSource}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; diff --git a/src/tools/clippy/clippy_lints/src/trait_bounds.rs b/src/tools/clippy/clippy_lints/src/trait_bounds.rs index 73d9849b6d8b7..53d1a60f4d372 100644 --- a/src/tools/clippy/clippy_lints/src/trait_bounds.rs +++ b/src/tools/clippy/clippy_lints/src/trait_bounds.rs @@ -8,10 +8,11 @@ use itertools::Itertools as _; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, IndexEntry}; use rustc_data_structures::unhash::UnhashMap; use rustc_errors::Applicability; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::def::Res; use rustc_hir::{ - AmbigArg, BoundPolarity, GenericBound, Generics, Item, ItemKind, LangItem, Node, Path, PathSegment, - PredicateOrigin, QPath, TraitBoundModifiers, TraitItem, TraitRef, Ty, TyKind, WherePredicateKind, + AmbigArg, BoundPolarity, GenericBound, Generics, Item, ItemKind, Node, Path, PathSegment, PredicateOrigin, QPath, + TraitBoundModifiers, TraitItem, TraitRef, Ty, TyKind, WherePredicateKind, }; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::impl_lint_pass; diff --git a/src/tools/clippy/clippy_lints/src/types/owned_cow.rs b/src/tools/clippy/clippy_lints/src/types/owned_cow.rs index 85a49253320eb..fad578a9a3eb4 100644 --- a/src/tools/clippy/clippy_lints/src/types/owned_cow.rs +++ b/src/tools/clippy/clippy_lints/src/types/owned_cow.rs @@ -4,6 +4,7 @@ use clippy_utils::source::snippet_opt; use clippy_utils::sym; use rustc_errors::Applicability; use rustc_hir as hir; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::def_id::DefId; use rustc_lint::LateContext; use rustc_span::Span; @@ -32,7 +33,7 @@ pub(super) fn check(cx: &LateContext<'_>, qpath: &hir::QPath<'_>, def_id: DefId) } fn replacement(cx: &LateContext<'_>, cty: &hir::Ty<'_>) -> Option<(Span, String)> { - if cty.basic_res().is_lang_item(cx, hir::LangItem::String) { + if cty.basic_res().is_lang_item(cx, LangItem::String) { return Some((cty.span, "str".into())); } if cty.basic_res().is_diag_item(cx, sym::Vec) { diff --git a/src/tools/clippy/clippy_lints/src/types/vec_box.rs b/src/tools/clippy/clippy_lints/src/types/vec_box.rs index 539fa8505a109..63103bbddd590 100644 --- a/src/tools/clippy/clippy_lints/src/types/vec_box.rs +++ b/src/tools/clippy/clippy_lints/src/types/vec_box.rs @@ -2,8 +2,9 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::last_path_segment; use clippy_utils::source::snippet; use rustc_errors::Applicability; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::def_id::DefId; -use rustc_hir::{self as hir, GenericArg, LangItem, QPath, TyKind}; +use rustc_hir::{self as hir, GenericArg, QPath, TyKind}; use rustc_hir_analysis::lower_ty; use rustc_lint::LateContext; use rustc_middle::ty::TypeVisitableExt as _; diff --git a/src/tools/clippy/clippy_lints/src/unnecessary_owned_empty_strings.rs b/src/tools/clippy/clippy_lints/src/unnecessary_owned_empty_strings.rs index de24e7827593c..7c7578ffc70bf 100644 --- a/src/tools/clippy/clippy_lints/src/unnecessary_owned_empty_strings.rs +++ b/src/tools/clippy/clippy_lints/src/unnecessary_owned_empty_strings.rs @@ -3,7 +3,8 @@ use clippy_utils::res::MaybeDef as _; use clippy_utils::sym; use rustc_ast::ast::LitKind; use rustc_errors::Applicability; -use rustc_hir::{BorrowKind, Expr, ExprKind, LangItem, Mutability}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_session::declare_lint_pass; diff --git a/src/tools/clippy/clippy_lints/src/unnecessary_wraps.rs b/src/tools/clippy/clippy_lints/src/unnecessary_wraps.rs index 39b17e58b8e2a..8c9eab028ade7 100644 --- a/src/tools/clippy/clippy_lints/src/unnecessary_wraps.rs +++ b/src/tools/clippy/clippy_lints/src/unnecessary_wraps.rs @@ -7,7 +7,7 @@ use clippy_utils::source::snippet; use clippy_utils::visitors::find_all_ret_expressions; use clippy_utils::{contains_return, return_ty}; use rustc_errors::Applicability; -use rustc_hir::LangItem::{OptionSome, ResultOk}; +use rustc_hir::attrs::lang::LangItem::{OptionSome, ResultOk}; use rustc_hir::intravisit::FnKind; use rustc_hir::{Body, ExprKind, FnDecl, Impl, ItemKind, Node}; use rustc_lint::{LateContext, LateLintPass}; diff --git a/src/tools/clippy/clippy_lints/src/unused_io_amount.rs b/src/tools/clippy/clippy_lints/src/unused_io_amount.rs index 3a9aa8e5788e2..ef0a5bc9df525 100644 --- a/src/tools/clippy/clippy_lints/src/unused_io_amount.rs +++ b/src/tools/clippy/clippy_lints/src/unused_io_amount.rs @@ -4,6 +4,7 @@ use clippy_utils::res::MaybeDef as _; use clippy_utils::{paths, peel_blocks, sym}; use hir::{ExprKind, HirId, PatKind}; use rustc_hir as hir; +use rustc_hir::attrs::lang::LangItem; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::declare_lint_pass; use rustc_span::Span; @@ -139,7 +140,7 @@ fn non_consuming_err_arm<'a>(cx: &LateContext<'a>, arm: &hir::Arm<'a>) -> bool { return cx .qpath_res(path, inner_pat.hir_id) .ctor_parent(cx) - .is_lang_item(cx, hir::LangItem::ResultErr); + .is_lang_item(cx, LangItem::ResultErr); } false @@ -206,7 +207,7 @@ fn is_ok_wild_or_dotdot_pattern<'a>(cx: &LateContext<'a>, pat: &hir::Pat<'a>) -> if let PatKind::TupleStruct(ref path, inner_pat, _) = pat.kind // we check against Result::Ok to avoid linting on Err(_) or something else. - && cx.qpath_res(path, pat.hir_id).ctor_parent(cx).is_lang_item(cx, hir::LangItem::ResultOk) + && cx.qpath_res(path, pat.hir_id).ctor_parent(cx).is_lang_item(cx, LangItem::ResultOk) { if matches!(inner_pat, []) { return true; @@ -259,7 +260,7 @@ fn unpack_call_chain<'a>(mut expr: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> { fn unpack_try<'a>(cx: &LateContext<'_>, mut expr: &'a hir::Expr<'a>) -> &'a hir::Expr<'a> { while let ExprKind::Call(func, [arg_0]) = expr.kind && let ExprKind::Path(qpath) = func.kind - && cx.tcx.qpath_is_lang_item(qpath, hir::LangItem::TryTraitBranch) + && cx.tcx.qpath_is_lang_item(qpath, LangItem::TryTraitBranch) { expr = arg_0; } @@ -279,7 +280,7 @@ fn unpack_await<'a>(cx: &LateContext<'_>, expr: &'a hir::Expr<'a>) -> &'a hir::E if let ExprKind::Match(expr, _, hir::MatchSource::AwaitDesugar) = expr.kind && let ExprKind::Call(func, [arg_0]) = expr.kind && let ExprKind::Path(qpath) = func.kind - && cx.tcx.qpath_is_lang_item(qpath, hir::LangItem::IntoFutureIntoFuture) + && cx.tcx.qpath_is_lang_item(qpath, LangItem::IntoFutureIntoFuture) { return arg_0; } diff --git a/src/tools/clippy/clippy_lints/src/useless_conversion.rs b/src/tools/clippy/clippy_lints/src/useless_conversion.rs index 9226d3bcbf329..d4a05a848869b 100644 --- a/src/tools/clippy/clippy_lints/src/useless_conversion.rs +++ b/src/tools/clippy/clippy_lints/src/useless_conversion.rs @@ -5,8 +5,9 @@ use clippy_utils::sugg::{DiagExt as _, Sugg}; use clippy_utils::ty::{is_copy, same_type_modulo_regions}; use clippy_utils::{get_parent_expr, is_ty_alias, sym}; use rustc_errors::Applicability; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::def_id::DefId; -use rustc_hir::{BindingMode, Expr, ExprKind, HirId, LangItem, MatchSource, Mutability, Node, PatKind}; +use rustc_hir::{BindingMode, Expr, ExprKind, HirId, MatchSource, Mutability, Node, PatKind}; use rustc_infer::infer::TyCtxtInferExt as _; use rustc_infer::traits::Obligation; use rustc_lint::{LateContext, LateLintPass}; diff --git a/src/tools/clippy/clippy_lints/src/with_capacity_zero.rs b/src/tools/clippy/clippy_lints/src/with_capacity_zero.rs index 62ab50bcde394..d093d898b4aab 100644 --- a/src/tools/clippy/clippy_lints/src/with_capacity_zero.rs +++ b/src/tools/clippy/clippy_lints/src/with_capacity_zero.rs @@ -2,7 +2,8 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::res::MaybeDef as _; use clippy_utils::{fn_def_id, is_integer_literal, last_path_segment, span_contains_comment, sym}; use rustc_errors::Applicability; -use rustc_hir::{Expr, ExprKind, LangItem}; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::Ty; use rustc_session::declare_lint_pass; diff --git a/src/tools/clippy/clippy_utils/src/higher.rs b/src/tools/clippy/clippy_utils/src/higher.rs index e4f508661dbfb..c7e4ffdf3aadf 100644 --- a/src/tools/clippy/clippy_utils/src/higher.rs +++ b/src/tools/clippy/clippy_utils/src/higher.rs @@ -7,6 +7,7 @@ use crate::res::MaybeDef as _; use crate::{is_expn_of, sym}; use rustc_ast::ast; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::{ self as hir, Arm, Block, Expr, ExprKind, HirId, LetStmt, LocalSource, LoopSource, MatchSource, Node, Pat, QPath, StructTailExpr, @@ -221,40 +222,40 @@ impl<'a> Range<'a> { let (ty, start, end) = match expr.kind { ExprKind::Call(path, [arg1, arg2]) if let ExprKind::Path(qpath) = path.kind - && cx.tcx.qpath_is_lang_item(qpath, hir::LangItem::RangeInclusiveNew) => + && cx.tcx.qpath_is_lang_item(qpath, LangItem::RangeInclusiveNew) => { (RangeTy::OpsInclusive, Some(arg1), Some(arg2)) }, ExprKind::Struct(&qpath, fields, StructTailExpr::None) => match (cx.tcx.qpath_lang_item(qpath)?, fields) { - (hir::LangItem::RangeFull, []) => (RangeTy::OpsFull, None, None), - (hir::LangItem::RangeFrom, [start]) if start.ident.name == sym::start => { + (LangItem::RangeFull, []) => (RangeTy::OpsFull, None, None), + (LangItem::RangeFrom, [start]) if start.ident.name == sym::start => { (RangeTy::OpsFrom, Some(start.expr), None) }, - (hir::LangItem::RangeFromCopy, [start]) if start.ident.name == sym::start => { + (LangItem::RangeFromCopy, [start]) if start.ident.name == sym::start => { (RangeTy::RangeFrom, Some(start.expr), None) }, - (hir::LangItem::Range, [start, end] | [end, start]) + (LangItem::Range, [start, end] | [end, start]) if start.ident.name == sym::start && end.ident.name == sym::end => { (RangeTy::OpsRange, Some(start.expr), Some(end.expr)) }, - (hir::LangItem::RangeCopy, [start, end] | [end, start]) + (LangItem::RangeCopy, [start, end] | [end, start]) if start.ident.name == sym::start && end.ident.name == sym::end => { (RangeTy::RangeRange, Some(start.expr), Some(end.expr)) }, - (hir::LangItem::RangeInclusiveCopy, [start, last] | [last, start]) + (LangItem::RangeInclusiveCopy, [start, last] | [last, start]) if start.ident.name == sym::start && last.ident.name == sym::last => { (RangeTy::RangeInclusive, Some(start.expr), Some(last.expr)) }, - (hir::LangItem::RangeToInclusive, [end]) if end.ident.name == sym::end => { + (LangItem::RangeToInclusive, [end]) if end.ident.name == sym::end => { (RangeTy::OpsToInclusive, None, Some(end.expr)) }, - (hir::LangItem::RangeToInclusiveCopy, [last]) if last.ident.name == sym::last => { + (LangItem::RangeToInclusiveCopy, [last]) if last.ident.name == sym::last => { (RangeTy::RangeToInclusive, None, Some(last.expr)) }, - (hir::LangItem::RangeTo, [end]) if end.ident.name == sym::end => (RangeTy::OpsTo, None, Some(end.expr)), + (LangItem::RangeTo, [end]) if end.ident.name == sym::end => (RangeTy::OpsTo, None, Some(end.expr)), _ => return None, }, _ => return None, diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index afaf4160e2c88..9b9f564d1a149 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -85,8 +85,9 @@ use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexmap; use rustc_data_structures::packed::Pu128; use rustc_data_structures::unhash::UnindexMap; -use rustc_hir::LangItem::{OptionNone, OptionSome, ResultErr, ResultOk}; use rustc_hir::attrs::CfgEntry; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::attrs::lang::LangItem::{OptionNone, OptionSome, ResultErr, ResultOk}; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{DefId, LocalDefId, LocalModId}; use rustc_hir::definitions::{DefPath, DefPathData}; @@ -95,9 +96,9 @@ use rustc_hir::{ self as hir, AnonConst, Arm, BindingMode, Block, BlockCheckMode, Body, ByRef, CRATE_HIR_ID, Closure, ConstArg, ConstArgKind, CoroutineDesugaring, CoroutineKind, CoroutineSource, Destination, Expr, ExprField, ExprKind, FieldDef, FnDecl, FnRetTy, GenericArg, GenericArgs, HirId, HirIdMap, HirIdSet, Impl, ImplItem, ImplItemKind, Item, - ItemKind, LangItem, LetStmt, MatchSource, Mutability, Node, OwnerId, OwnerNode, Param, Pat, PatExpr, PatExprKind, - PatKind, Path, PathSegment, QPath, Stmt, StmtKind, TraitFn, TraitItem, TraitItemKind, TraitRef, TyKind, UnOp, - Variant, def, find_attr, + ItemKind, LetStmt, MatchSource, Mutability, Node, OwnerId, OwnerNode, Param, Pat, PatExpr, PatExprKind, PatKind, + Path, PathSegment, QPath, Stmt, StmtKind, TraitFn, TraitItem, TraitItemKind, TraitRef, TyKind, UnOp, Variant, def, + find_attr, }; use rustc_lexer::{FrontmatterAllowed, TokenKind, tokenize}; use rustc_lint::{LateContext, Level, Lint, LintContext as _}; diff --git a/src/tools/clippy/clippy_utils/src/msrvs.rs b/src/tools/clippy/clippy_utils/src/msrvs.rs index 48819d53da771..16b7e8512e3a0 100644 --- a/src/tools/clippy/clippy_utils/src/msrvs.rs +++ b/src/tools/clippy/clippy_utils/src/msrvs.rs @@ -3,9 +3,9 @@ use rustc_ast::Attribute; use rustc_ast::attr::AttributeExt; use rustc_attr_parsing::parse_version; use rustc_data_structures::smallvec::SmallVec; -use rustc_hir::attrs::RustcVersion; +use rustc_hir::HirId; +use rustc_hir::attrs::{RustcVersion, StabilityLevel, StableSince}; use rustc_hir::def_id::DefId; -use rustc_hir::{HirId, StabilityLevel, StableSince}; use rustc_lint::LateContext; use rustc_middle::ty::TyCtxt; use rustc_session::Session; diff --git a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs index 4acd0cb31412f..8b33031a89ac9 100644 --- a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs +++ b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs @@ -4,11 +4,11 @@ // differ from the time of `rustc` even if the name stays the same. use crate::msrvs::{self, Msrv}; -use hir::LangItem; use rustc_const_eval::check_consts::ConstCx; -use rustc_hir::attrs::RustcVersion; +use rustc_hir::attrs::lang::LangItem; +use rustc_hir::attrs::{RustcVersion, StabilityLevel, StableSince}; use rustc_hir::def_id::DefId; -use rustc_hir::{self as hir, HirId, StableSince}; +use rustc_hir::{self as hir, HirId}; use rustc_infer::infer::TyCtxtInferExt as _; use rustc_infer::traits::Obligation; use rustc_lint::LateContext; @@ -441,7 +441,7 @@ pub fn is_stable_const_fn_at(tcx: TyCtxt<'_>, node: HirId, def_id: DefId, msrv: .and_then(|trait_def_id| tcx.lookup_const_stability(trait_def_id)) }) .is_none_or(|const_stab| { - if let rustc_hir::StabilityLevel::Stable { since, .. } = const_stab.level { + if let StabilityLevel::Stable { since, .. } = const_stab.level { // Checking MSRV is manually necessary because `rustc` has no such concept. This entire // function could be removed if `rustc` provided a MSRV-aware version of `is_stable_const_fn`. // as a part of an unimplemented MSRV check https://github.com/rust-lang/rust/issues/65262. diff --git a/src/tools/clippy/clippy_utils/src/res.rs b/src/tools/clippy/clippy_utils/src/res.rs index fdafebe00f477..aa2d019c98628 100644 --- a/src/tools/clippy/clippy_utils/src/res.rs +++ b/src/tools/clippy/clippy_utils/src/res.rs @@ -1,7 +1,8 @@ +use rustc_hir::attrs::lang::LangItem; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; use rustc_hir::{ - self as hir, Expr, ExprKind, HirId, LangItem, Pat, PatExpr, PatExprKind, PatKind, Path, PathSegment, QPath, TyKind, + self as hir, Expr, ExprKind, HirId, Pat, PatExpr, PatExprKind, PatKind, Path, PathSegment, QPath, TyKind, }; use rustc_lint::LateContext; use rustc_middle::ty::layout::HasTyCtxt; diff --git a/src/tools/clippy/clippy_utils/src/ty/mod.rs b/src/tools/clippy/clippy_utils/src/ty/mod.rs index ba41fe5c41ec1..8c4fc07e33c15 100644 --- a/src/tools/clippy/clippy_utils/src/ty/mod.rs +++ b/src/tools/clippy/clippy_utils/src/ty/mod.rs @@ -9,9 +9,10 @@ use rustc_ast::ast::Mutability; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_errors::pluralize; use rustc_hir as hir; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res}; use rustc_hir::def_id::DefId; -use rustc_hir::{Expr, ExprKind, FnDecl, LangItem}; +use rustc_hir::{Expr, ExprKind, FnDecl}; use rustc_hir_analysis::lower_ty; use rustc_infer::infer::TyCtxtInferExt as _; use rustc_lint::LateContext; diff --git a/tests/ui-fulldeps/polymorphic-drop-glue.rs b/tests/ui-fulldeps/polymorphic-drop-glue.rs index 0617d78b89679..4012ae4c507f3 100644 --- a/tests/ui-fulldeps/polymorphic-drop-glue.rs +++ b/tests/ui-fulldeps/polymorphic-drop-glue.rs @@ -16,7 +16,7 @@ extern crate rustc_span; use std::process::ExitCode; use rustc_driver::Compilation; -use rustc_hir::LangItem; +use rustc_hir::attrs::lang::LangItem; use rustc_hir::def::DefKind; use rustc_interface::interface::Compiler; use rustc_middle::ty::{self, TyCtxt};