Skip to content

Commit 3948be6

Browse files
clippy: directly use rustc_abi instead of reexports
1 parent 64e06c0 commit 3948be6

20 files changed

+43
-41
lines changed

src/tools/clippy/clippy_lints/src/casts/cast_possible_truncation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ use clippy_utils::expr_or_init;
44
use clippy_utils::source::snippet;
55
use clippy_utils::sugg::Sugg;
66
use clippy_utils::ty::{get_discriminant_value, is_isize_or_usize};
7+
use rustc_abi::IntegerType;
78
use rustc_errors::{Applicability, Diag};
89
use rustc_hir::def::{DefKind, Res};
910
use rustc_hir::{BinOpKind, Expr, ExprKind};
1011
use rustc_lint::LateContext;
1112
use rustc_middle::ty::{self, FloatTy, Ty};
1213
use rustc_span::Span;
13-
use rustc_target::abi::IntegerType;
1414

1515
use super::{CAST_ENUM_TRUNCATION, CAST_POSSIBLE_TRUNCATION, utils};
1616

src/tools/clippy/clippy_lints/src/escape.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_session::impl_lint_pass;
1010
use rustc_span::Span;
1111
use rustc_span::def_id::LocalDefId;
1212
use rustc_span::symbol::kw;
13-
use rustc_target::spec::abi::Abi;
13+
use rustc_abi::ExternAbi;
1414

1515
pub struct BoxedLocal {
1616
too_large_for_stack: u64,
@@ -73,7 +73,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
7373
fn_def_id: LocalDefId,
7474
) {
7575
if let Some(header) = fn_kind.header() {
76-
if header.abi != Abi::Rust {
76+
if header.abi != ExternAbi::Rust {
7777
return;
7878
}
7979
}

src/tools/clippy/clippy_lints/src/eta_reduction.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_middle::ty::{
1515
};
1616
use rustc_session::declare_lint_pass;
1717
use rustc_span::symbol::sym;
18-
use rustc_target::spec::abi::Abi;
18+
use rustc_abi::ExternAbi;
1919
use rustc_trait_selection::error_reporting::InferCtxtErrorExt as _;
2020

2121
declare_clippy_lint! {
@@ -172,7 +172,7 @@ fn check_closure<'tcx>(cx: &LateContext<'tcx>, outer_receiver: Option<&Expr<'tcx
172172
&& let output = typeck.expr_ty(body.value)
173173
&& let ty::Tuple(tys) = *subs.type_at(1).kind()
174174
{
175-
cx.tcx.mk_fn_sig(tys, output, false, Safety::Safe, Abi::Rust)
175+
cx.tcx.mk_fn_sig(tys, output, false, Safety::Safe, ExternAbi::Rust)
176176
} else {
177177
return;
178178
}

src/tools/clippy/clippy_lints/src/excessive_bools.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_lint::{LateContext, LateLintPass};
77
use rustc_session::impl_lint_pass;
88
use rustc_span::Span;
99
use rustc_span::def_id::LocalDefId;
10-
use rustc_target::spec::abi::Abi;
10+
use rustc_abi::ExternAbi;
1111

1212
declare_clippy_lint! {
1313
/// ### What it does
@@ -145,7 +145,7 @@ impl<'tcx> LateLintPass<'tcx> for ExcessiveBools {
145145
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, trait_item: &'tcx TraitItem<'tcx>) {
146146
// functions with a body are already checked by `check_fn`
147147
if let TraitItemKind::Fn(fn_sig, TraitFn::Required(_)) = &trait_item.kind
148-
&& fn_sig.header.abi == Abi::Rust
148+
&& fn_sig.header.abi == ExternAbi::Rust
149149
&& fn_sig.decl.inputs.len() as u64 > self.max_fn_params_bools
150150
{
151151
check_fn_decl(cx, fn_sig.decl, fn_sig.span, self.max_fn_params_bools);
@@ -162,7 +162,7 @@ impl<'tcx> LateLintPass<'tcx> for ExcessiveBools {
162162
def_id: LocalDefId,
163163
) {
164164
if let Some(fn_header) = fn_kind.header()
165-
&& fn_header.abi == Abi::Rust
165+
&& fn_header.abi == ExternAbi::Rust
166166
&& fn_decl.inputs.len() as u64 > self.max_fn_params_bools
167167
&& get_parent_as_impl(cx.tcx, cx.tcx.local_def_id_to_hir_id(def_id))
168168
.is_none_or(|impl_item| impl_item.of_trait.is_none())

src/tools/clippy/clippy_lints/src/functions/too_many_arguments.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_hir::{self as hir, intravisit};
22
use rustc_lint::LateContext;
33
use rustc_span::Span;
4-
use rustc_target::spec::abi::Abi;
4+
use rustc_abi::ExternAbi;
55

66
use clippy_utils::diagnostics::span_lint;
77
use clippy_utils::is_trait_impl_item;
@@ -23,11 +23,11 @@ pub(super) fn check_fn(
2323
intravisit::FnKind::Method(
2424
_,
2525
&hir::FnSig {
26-
header: hir::FnHeader { abi: Abi::Rust, .. },
26+
header: hir::FnHeader { abi: ExternAbi::Rust, .. },
2727
..
2828
},
2929
)
30-
| intravisit::FnKind::ItemFn(_, _, hir::FnHeader { abi: Abi::Rust, .. }) => check_arg_number(
30+
| intravisit::FnKind::ItemFn(_, _, hir::FnHeader { abi: ExternAbi::Rust, .. }) => check_arg_number(
3131
cx,
3232
decl,
3333
span.with_hi(decl.output.span().hi()),
@@ -41,7 +41,7 @@ pub(super) fn check_fn(
4141
pub(super) fn check_trait_item(cx: &LateContext<'_>, item: &hir::TraitItem<'_>, too_many_arguments_threshold: u64) {
4242
if let hir::TraitItemKind::Fn(ref sig, _) = item.kind {
4343
// don't lint extern functions decls, it's not their fault
44-
if sig.header.abi == Abi::Rust {
44+
if sig.header.abi == ExternAbi::Rust {
4545
check_arg_number(
4646
cx,
4747
sig.decl,

src/tools/clippy/clippy_lints/src/inherent_to_string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_hir::{GenericParamKind, ImplItem, ImplItemKind, LangItem};
55
use rustc_lint::{LateContext, LateLintPass};
66
use rustc_session::declare_lint_pass;
77
use rustc_span::sym;
8-
use rustc_target::spec::abi::Abi;
8+
use rustc_abi::ExternAbi;
99

1010
declare_clippy_lint! {
1111
/// ### What it does
@@ -96,7 +96,7 @@ impl<'tcx> LateLintPass<'tcx> for InherentToString {
9696
// #11201
9797
&& let header = signature.header
9898
&& header.is_safe()
99-
&& header.abi == Abi::Rust
99+
&& header.abi == ExternAbi::Rust
100100
&& impl_item.ident.name == sym::to_string
101101
&& let decl = signature.decl
102102
&& decl.implicit_self.has_implicit_self()

src/tools/clippy/clippy_lints/src/large_futures.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use clippy_config::Conf;
22
use clippy_utils::diagnostics::span_lint_and_sugg;
33
use clippy_utils::source::snippet;
44
use clippy_utils::ty::implements_trait;
5+
use rustc_abi::Size;
56
use rustc_errors::Applicability;
67
use rustc_hir::{Expr, ExprKind, LangItem, MatchSource, QPath};
78
use rustc_lint::{LateContext, LateLintPass};
89
use rustc_session::impl_lint_pass;
9-
use rustc_target::abi::Size;
1010

1111
declare_clippy_lint! {
1212
/// ### What it does

src/tools/clippy/clippy_lints/src/methods/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ use clippy_utils::msrvs::{self, Msrv};
149149
use clippy_utils::ty::{contains_ty_adt_constructor_opaque, implements_trait, is_copy, is_type_diagnostic_item};
150150
use clippy_utils::{contains_return, is_bool, is_trait_method, iter_input_pats, peel_blocks, return_ty};
151151
pub use path_ends_with_ext::DEFAULT_ALLOWED_DOTFILES;
152+
use rustc_abi::ExternAbi;
152153
use rustc_data_structures::fx::FxHashSet;
153154
use rustc_hir as hir;
154155
use rustc_hir::{Expr, ExprKind, Node, Stmt, StmtKind, TraitItem, TraitItemKind};
@@ -5447,7 +5448,7 @@ const FN_HEADER: hir::FnHeader = hir::FnHeader {
54475448
safety: hir::HeaderSafety::Normal(hir::Safety::Safe),
54485449
constness: hir::Constness::NotConst,
54495450
asyncness: hir::IsAsync::NotAsync,
5450-
abi: rustc_target::spec::abi::Abi::Rust,
5451+
abi: ExternAbi::Rust,
54515452
};
54525453

54535454
struct ShouldImplTraitCase {

src/tools/clippy/clippy_lints/src/missing_const_for_fn.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
use clippy_config::Conf;
23
use clippy_utils::diagnostics::span_lint_and_then;
34
use clippy_utils::msrvs::{self, Msrv};
@@ -12,7 +13,7 @@ use rustc_middle::ty;
1213
use rustc_session::impl_lint_pass;
1314
use rustc_span::Span;
1415
use rustc_span::def_id::LocalDefId;
15-
use rustc_target::spec::abi::Abi;
16+
use rustc_abi::ExternAbi;
1617

1718
declare_clippy_lint! {
1819
/// ### What it does
@@ -183,11 +184,11 @@ fn already_const(header: hir::FnHeader) -> bool {
183184
header.constness == Constness::Const
184185
}
185186

186-
fn could_be_const_with_abi(msrv: &Msrv, abi: Abi) -> bool {
187+
fn could_be_const_with_abi(msrv: &Msrv, abi: ExternAbi) -> bool {
187188
match abi {
188-
Abi::Rust => true,
189+
ExternAbi::Rust => true,
189190
// `const extern "C"` was stabilized after 1.62.0
190-
Abi::C { unwind: false } => msrv.meets(msrvs::CONST_EXTERN_C_FN),
191+
ExternAbi::C { unwind: false } => msrv.meets(msrvs::CONST_EXTERN_C_FN),
191192
// Rest ABIs are still unstable and need the `const_extern_fn` feature enabled.
192193
_ => msrv.meets(msrvs::CONST_EXTERN_FN),
193194
}

src/tools/clippy/clippy_lints/src/needless_pass_by_ref_mut.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_session::impl_lint_pass;
2020
use rustc_span::Span;
2121
use rustc_span::def_id::LocalDefId;
2222
use rustc_span::symbol::kw;
23-
use rustc_target::spec::abi::Abi;
23+
use rustc_abi::ExternAbi;
2424

2525
declare_clippy_lint! {
2626
/// ### What it does
@@ -149,7 +149,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> {
149149
return;
150150
}
151151
let attrs = cx.tcx.hir().attrs(hir_id);
152-
if header.abi != Abi::Rust || requires_exact_signature(attrs) {
152+
if header.abi != ExternAbi::Rust || requires_exact_signature(attrs) {
153153
return;
154154
}
155155
header.is_async()

src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc_session::declare_lint_pass;
1919
use rustc_span::def_id::LocalDefId;
2020
use rustc_span::symbol::kw;
2121
use rustc_span::{Span, sym};
22-
use rustc_target::spec::abi::Abi;
22+
use rustc_abi::ExternAbi;
2323
use rustc_trait_selection::traits;
2424
use rustc_trait_selection::traits::misc::type_allowed_to_implement_copy;
2525

@@ -89,7 +89,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
8989
match kind {
9090
FnKind::ItemFn(.., header) => {
9191
let attrs = cx.tcx.hir().attrs(hir_id);
92-
if header.abi != Abi::Rust || requires_exact_signature(attrs) {
92+
if header.abi != ExternAbi::Rust || requires_exact_signature(attrs) {
9393
return;
9494
}
9595
},

src/tools/clippy/clippy_lints/src/no_mangle_with_rust_abi.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_hir::{Item, ItemKind};
55
use rustc_lint::{LateContext, LateLintPass};
66
use rustc_session::declare_lint_pass;
77
use rustc_span::{BytePos, Pos};
8-
use rustc_target::spec::abi::Abi;
8+
use rustc_abi::ExternAbi;
99

1010
declare_clippy_lint! {
1111
/// ### What it does
@@ -46,7 +46,7 @@ impl<'tcx> LateLintPass<'tcx> for NoMangleWithRustAbi {
4646
for attr in attrs {
4747
if let Some(ident) = attr.ident()
4848
&& ident.name == rustc_span::sym::no_mangle
49-
&& fn_sig.header.abi == Abi::Rust
49+
&& fn_sig.header.abi == ExternAbi::Rust
5050
&& let Some((fn_attrs, _)) = fn_snippet.rsplit_once("fn")
5151
&& !fn_attrs.contains("extern")
5252
{

src/tools/clippy/clippy_lints/src/non_copy_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use clippy_utils::diagnostics::span_lint_and_then;
55
use clippy_utils::is_in_const_context;
66
use clippy_utils::macros::macro_backtrace;
77
use clippy_utils::ty::{InteriorMut, implements_trait};
8+
use rustc_abi::VariantIdx;
89
use rustc_hir::def::{DefKind, Res};
910
use rustc_hir::def_id::DefId;
1011
use rustc_hir::{
@@ -16,7 +17,6 @@ use rustc_middle::ty::adjustment::Adjust;
1617
use rustc_middle::ty::{self, Ty, TyCtxt};
1718
use rustc_session::impl_lint_pass;
1819
use rustc_span::{DUMMY_SP, Span, sym};
19-
use rustc_target::abi::VariantIdx;
2020

2121
// FIXME: this is a correctness problem but there's no suitable
2222
// warn-by-default category.

src/tools/clippy/clippy_lints/src/pass_by_ref_or_value.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc_middle::ty::{self, RegionKind, TyCtxt};
1919
use rustc_session::impl_lint_pass;
2020
use rustc_span::def_id::LocalDefId;
2121
use rustc_span::{Span, sym};
22-
use rustc_target::spec::abi::Abi;
22+
use rustc_abi::ExternAbi;
2323

2424
declare_clippy_lint! {
2525
/// ### What it does
@@ -277,7 +277,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByRefOrValue {
277277
let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
278278
match kind {
279279
FnKind::ItemFn(.., header) => {
280-
if header.abi != Abi::Rust {
280+
if header.abi != ExternAbi::Rust {
281281
return;
282282
}
283283
let attrs = cx.tcx.hir().attrs(hir_id);

src/tools/clippy/clippy_lints/src/ptr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc_middle::ty::{self, Binder, ClauseKind, ExistentialPredicate, List, Pre
1919
use rustc_session::declare_lint_pass;
2020
use rustc_span::symbol::Symbol;
2121
use rustc_span::{Span, sym};
22-
use rustc_target::spec::abi::Abi;
22+
use rustc_abi::ExternAbi;
2323
use rustc_trait_selection::infer::InferCtxtExt as _;
2424
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
2525
use std::{fmt, iter};
@@ -160,7 +160,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
160160

161161
check_mut_from_ref(cx, sig, None);
162162

163-
if !matches!(sig.header.abi, Abi::Rust) {
163+
if !matches!(sig.header.abi, ExternAbi::Rust) {
164164
// Ignore `extern` functions with non-Rust calling conventions
165165
return;
166166
}
@@ -220,7 +220,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
220220

221221
check_mut_from_ref(cx, sig, Some(body));
222222

223-
if !matches!(sig.header.abi, Abi::Rust) {
223+
if !matches!(sig.header.abi, ExternAbi::Rust) {
224224
// Ignore `extern` functions with non-Rust calling conventions
225225
return;
226226
}

src/tools/clippy/clippy_lints/src/types/type_complexity.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use clippy_utils::diagnostics::span_lint;
2+
use rustc_abi::ExternAbi;
23
use rustc_hir::intravisit::{InferKind, Visitor, VisitorExt, walk_ty};
34
use rustc_hir::{self as hir, AmbigArg, GenericParamKind, TyKind};
45
use rustc_lint::LateContext;
56
use rustc_span::Span;
6-
use rustc_target::spec::abi::Abi;
77

88
use super::TYPE_COMPLEXITY;
99

@@ -50,7 +50,7 @@ impl<'tcx> Visitor<'tcx> for TypeComplexityVisitor {
5050
TyKind::Path(..) | TyKind::Slice(..) | TyKind::Tup(..) | TyKind::Array(..) => (10 * self.nest, 1),
5151

5252
// function types bring a lot of overhead
53-
TyKind::BareFn(bare) if bare.abi == Abi::Rust => (50 * self.nest, 1),
53+
TyKind::BareFn(bare) if bare.abi == ExternAbi::Rust => (50 * self.nest, 1),
5454

5555
TyKind::TraitObject(param_bounds, _) => {
5656
let has_lifetime_parameters = param_bounds.iter().any(|bound| {

src/tools/clippy/clippy_utils/src/check_proc_macro.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//! code was written, and check if the span contains that text. Note this will only work correctly
1313
//! if the span is not from a `macro_rules` based macro.
1414
15+
use rustc_abi::ExternAbi;
1516
use rustc_ast::AttrStyle;
1617
use rustc_ast::ast::{AttrKind, Attribute, IntTy, LitIntType, LitKind, StrStyle, TraitObjectSyntax, UintTy};
1718
use rustc_ast::token::CommentKind;
@@ -26,7 +27,6 @@ use rustc_middle::ty::TyCtxt;
2627
use rustc_session::Session;
2728
use rustc_span::symbol::{Ident, kw};
2829
use rustc_span::{Span, Symbol};
29-
use rustc_target::spec::abi::Abi;
3030

3131
/// The search pattern to look for. Used by `span_matches_pat`
3232
#[derive(Clone)]
@@ -233,7 +233,7 @@ fn fn_header_search_pat(header: FnHeader) -> Pat {
233233
Pat::Str("const")
234234
} else if header.is_unsafe() {
235235
Pat::Str("unsafe")
236-
} else if header.abi != Abi::Rust {
236+
} else if header.abi != ExternAbi::Rust {
237237
Pat::Str("extern")
238238
} else {
239239
Pat::MultiStr(&["fn", "extern"])
@@ -375,7 +375,7 @@ fn ty_search_pat(ty: &Ty<'_>) -> (Pat, Pat) {
375375
TyKind::BareFn(bare_fn) => (
376376
if bare_fn.safety.is_unsafe() {
377377
Pat::Str("unsafe")
378-
} else if bare_fn.abi != Abi::Rust {
378+
} else if bare_fn.abi != ExternAbi::Rust {
379379
Pat::Str("extern")
380380
} else {
381381
Pat::MultiStr(&["fn", "extern"])

src/tools/clippy/clippy_utils/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::sync::Arc;
99
use crate::source::{SpanRangeExt, walk_span_to_context};
1010
use crate::{clip, is_direct_expn_of, sext, unsext};
1111

12+
use rustc_abi::Size;
1213
use rustc_apfloat::Float;
1314
use rustc_apfloat::ieee::{Half, Quad};
1415
use rustc_ast::ast::{self, LitFloatType, LitKind};
@@ -25,7 +26,6 @@ use rustc_middle::{bug, mir, span_bug};
2526
use rustc_span::def_id::DefId;
2627
use rustc_span::symbol::Ident;
2728
use rustc_span::{SyntaxContext, sym};
28-
use rustc_target::abi::Size;
2929
use std::cell::Cell;
3030
use std::cmp::Ordering;
3131
use std::hash::{Hash, Hasher};

src/tools/clippy/clippy_utils/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
// FIXME: switch to something more ergonomic here, once available.
3131
// (Currently there is no way to opt into sysroot crates without `extern crate`.)
32+
extern crate rustc_abi;
3233
extern crate rustc_ast;
3334
extern crate rustc_ast_pretty;
3435
extern crate rustc_attr_parsing;
@@ -48,7 +49,6 @@ extern crate rustc_middle;
4849
extern crate rustc_mir_dataflow;
4950
extern crate rustc_session;
5051
extern crate rustc_span;
51-
extern crate rustc_target;
5252
extern crate rustc_trait_selection;
5353
extern crate smallvec;
5454

@@ -123,7 +123,7 @@ use rustc_span::hygiene::{ExpnKind, MacroKind};
123123
use rustc_span::source_map::SourceMap;
124124
use rustc_span::symbol::{Ident, Symbol, kw};
125125
use rustc_span::{InnerSpan, Span, sym};
126-
use rustc_target::abi::Integer;
126+
use rustc_abi::Integer;
127127
use visitors::{Visitable, for_each_unconsumed_temporary};
128128

129129
use crate::consts::{ConstEvalCtxt, Constant, mir_to_const};

0 commit comments

Comments
 (0)