clippy: directly use rustc_abi instead of reexports
This commit is contained in:
parent
64e06c0f55
commit
3948be651a
20 changed files with 43 additions and 41 deletions
|
@ -4,13 +4,13 @@ use clippy_utils::expr_or_init;
|
||||||
use clippy_utils::source::snippet;
|
use clippy_utils::source::snippet;
|
||||||
use clippy_utils::sugg::Sugg;
|
use clippy_utils::sugg::Sugg;
|
||||||
use clippy_utils::ty::{get_discriminant_value, is_isize_or_usize};
|
use clippy_utils::ty::{get_discriminant_value, is_isize_or_usize};
|
||||||
|
use rustc_abi::IntegerType;
|
||||||
use rustc_errors::{Applicability, Diag};
|
use rustc_errors::{Applicability, Diag};
|
||||||
use rustc_hir::def::{DefKind, Res};
|
use rustc_hir::def::{DefKind, Res};
|
||||||
use rustc_hir::{BinOpKind, Expr, ExprKind};
|
use rustc_hir::{BinOpKind, Expr, ExprKind};
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_middle::ty::{self, FloatTy, Ty};
|
use rustc_middle::ty::{self, FloatTy, Ty};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_target::abi::IntegerType;
|
|
||||||
|
|
||||||
use super::{CAST_ENUM_TRUNCATION, CAST_POSSIBLE_TRUNCATION, utils};
|
use super::{CAST_ENUM_TRUNCATION, CAST_POSSIBLE_TRUNCATION, utils};
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use rustc_session::impl_lint_pass;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use rustc_span::symbol::kw;
|
use rustc_span::symbol::kw;
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_abi::ExternAbi;
|
||||||
|
|
||||||
pub struct BoxedLocal {
|
pub struct BoxedLocal {
|
||||||
too_large_for_stack: u64,
|
too_large_for_stack: u64,
|
||||||
|
@ -73,7 +73,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
|
||||||
fn_def_id: LocalDefId,
|
fn_def_id: LocalDefId,
|
||||||
) {
|
) {
|
||||||
if let Some(header) = fn_kind.header() {
|
if let Some(header) = fn_kind.header() {
|
||||||
if header.abi != Abi::Rust {
|
if header.abi != ExternAbi::Rust {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ use rustc_middle::ty::{
|
||||||
};
|
};
|
||||||
use rustc_session::declare_lint_pass;
|
use rustc_session::declare_lint_pass;
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_abi::ExternAbi;
|
||||||
use rustc_trait_selection::error_reporting::InferCtxtErrorExt as _;
|
use rustc_trait_selection::error_reporting::InferCtxtErrorExt as _;
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
|
@ -172,7 +172,7 @@ fn check_closure<'tcx>(cx: &LateContext<'tcx>, outer_receiver: Option<&Expr<'tcx
|
||||||
&& let output = typeck.expr_ty(body.value)
|
&& let output = typeck.expr_ty(body.value)
|
||||||
&& let ty::Tuple(tys) = *subs.type_at(1).kind()
|
&& let ty::Tuple(tys) = *subs.type_at(1).kind()
|
||||||
{
|
{
|
||||||
cx.tcx.mk_fn_sig(tys, output, false, Safety::Safe, Abi::Rust)
|
cx.tcx.mk_fn_sig(tys, output, false, Safety::Safe, ExternAbi::Rust)
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_session::impl_lint_pass;
|
use rustc_session::impl_lint_pass;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_abi::ExternAbi;
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
|
@ -145,7 +145,7 @@ impl<'tcx> LateLintPass<'tcx> for ExcessiveBools {
|
||||||
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, trait_item: &'tcx TraitItem<'tcx>) {
|
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, trait_item: &'tcx TraitItem<'tcx>) {
|
||||||
// functions with a body are already checked by `check_fn`
|
// functions with a body are already checked by `check_fn`
|
||||||
if let TraitItemKind::Fn(fn_sig, TraitFn::Required(_)) = &trait_item.kind
|
if let TraitItemKind::Fn(fn_sig, TraitFn::Required(_)) = &trait_item.kind
|
||||||
&& fn_sig.header.abi == Abi::Rust
|
&& fn_sig.header.abi == ExternAbi::Rust
|
||||||
&& fn_sig.decl.inputs.len() as u64 > self.max_fn_params_bools
|
&& fn_sig.decl.inputs.len() as u64 > self.max_fn_params_bools
|
||||||
{
|
{
|
||||||
check_fn_decl(cx, fn_sig.decl, fn_sig.span, self.max_fn_params_bools);
|
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 {
|
||||||
def_id: LocalDefId,
|
def_id: LocalDefId,
|
||||||
) {
|
) {
|
||||||
if let Some(fn_header) = fn_kind.header()
|
if let Some(fn_header) = fn_kind.header()
|
||||||
&& fn_header.abi == Abi::Rust
|
&& fn_header.abi == ExternAbi::Rust
|
||||||
&& fn_decl.inputs.len() as u64 > self.max_fn_params_bools
|
&& fn_decl.inputs.len() as u64 > self.max_fn_params_bools
|
||||||
&& get_parent_as_impl(cx.tcx, cx.tcx.local_def_id_to_hir_id(def_id))
|
&& get_parent_as_impl(cx.tcx, cx.tcx.local_def_id_to_hir_id(def_id))
|
||||||
.is_none_or(|impl_item| impl_item.of_trait.is_none())
|
.is_none_or(|impl_item| impl_item.of_trait.is_none())
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use rustc_hir::{self as hir, intravisit};
|
use rustc_hir::{self as hir, intravisit};
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_abi::ExternAbi;
|
||||||
|
|
||||||
use clippy_utils::diagnostics::span_lint;
|
use clippy_utils::diagnostics::span_lint;
|
||||||
use clippy_utils::is_trait_impl_item;
|
use clippy_utils::is_trait_impl_item;
|
||||||
|
@ -23,11 +23,11 @@ pub(super) fn check_fn(
|
||||||
intravisit::FnKind::Method(
|
intravisit::FnKind::Method(
|
||||||
_,
|
_,
|
||||||
&hir::FnSig {
|
&hir::FnSig {
|
||||||
header: hir::FnHeader { abi: Abi::Rust, .. },
|
header: hir::FnHeader { abi: ExternAbi::Rust, .. },
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
| intravisit::FnKind::ItemFn(_, _, hir::FnHeader { abi: Abi::Rust, .. }) => check_arg_number(
|
| intravisit::FnKind::ItemFn(_, _, hir::FnHeader { abi: ExternAbi::Rust, .. }) => check_arg_number(
|
||||||
cx,
|
cx,
|
||||||
decl,
|
decl,
|
||||||
span.with_hi(decl.output.span().hi()),
|
span.with_hi(decl.output.span().hi()),
|
||||||
|
@ -41,7 +41,7 @@ pub(super) fn check_fn(
|
||||||
pub(super) fn check_trait_item(cx: &LateContext<'_>, item: &hir::TraitItem<'_>, too_many_arguments_threshold: u64) {
|
pub(super) fn check_trait_item(cx: &LateContext<'_>, item: &hir::TraitItem<'_>, too_many_arguments_threshold: u64) {
|
||||||
if let hir::TraitItemKind::Fn(ref sig, _) = item.kind {
|
if let hir::TraitItemKind::Fn(ref sig, _) = item.kind {
|
||||||
// don't lint extern functions decls, it's not their fault
|
// don't lint extern functions decls, it's not their fault
|
||||||
if sig.header.abi == Abi::Rust {
|
if sig.header.abi == ExternAbi::Rust {
|
||||||
check_arg_number(
|
check_arg_number(
|
||||||
cx,
|
cx,
|
||||||
sig.decl,
|
sig.decl,
|
||||||
|
|
|
@ -5,7 +5,7 @@ use rustc_hir::{GenericParamKind, ImplItem, ImplItemKind, LangItem};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_session::declare_lint_pass;
|
use rustc_session::declare_lint_pass;
|
||||||
use rustc_span::sym;
|
use rustc_span::sym;
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_abi::ExternAbi;
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
|
@ -96,7 +96,7 @@ impl<'tcx> LateLintPass<'tcx> for InherentToString {
|
||||||
// #11201
|
// #11201
|
||||||
&& let header = signature.header
|
&& let header = signature.header
|
||||||
&& header.is_safe()
|
&& header.is_safe()
|
||||||
&& header.abi == Abi::Rust
|
&& header.abi == ExternAbi::Rust
|
||||||
&& impl_item.ident.name == sym::to_string
|
&& impl_item.ident.name == sym::to_string
|
||||||
&& let decl = signature.decl
|
&& let decl = signature.decl
|
||||||
&& decl.implicit_self.has_implicit_self()
|
&& decl.implicit_self.has_implicit_self()
|
||||||
|
|
|
@ -2,11 +2,11 @@ use clippy_config::Conf;
|
||||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||||
use clippy_utils::source::snippet;
|
use clippy_utils::source::snippet;
|
||||||
use clippy_utils::ty::implements_trait;
|
use clippy_utils::ty::implements_trait;
|
||||||
|
use rustc_abi::Size;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{Expr, ExprKind, LangItem, MatchSource, QPath};
|
use rustc_hir::{Expr, ExprKind, LangItem, MatchSource, QPath};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_session::impl_lint_pass;
|
use rustc_session::impl_lint_pass;
|
||||||
use rustc_target::abi::Size;
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
|
|
|
@ -149,6 +149,7 @@ use clippy_utils::msrvs::{self, Msrv};
|
||||||
use clippy_utils::ty::{contains_ty_adt_constructor_opaque, implements_trait, is_copy, is_type_diagnostic_item};
|
use clippy_utils::ty::{contains_ty_adt_constructor_opaque, implements_trait, is_copy, is_type_diagnostic_item};
|
||||||
use clippy_utils::{contains_return, is_bool, is_trait_method, iter_input_pats, peel_blocks, return_ty};
|
use clippy_utils::{contains_return, is_bool, is_trait_method, iter_input_pats, peel_blocks, return_ty};
|
||||||
pub use path_ends_with_ext::DEFAULT_ALLOWED_DOTFILES;
|
pub use path_ends_with_ext::DEFAULT_ALLOWED_DOTFILES;
|
||||||
|
use rustc_abi::ExternAbi;
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::{Expr, ExprKind, Node, Stmt, StmtKind, TraitItem, TraitItemKind};
|
use rustc_hir::{Expr, ExprKind, Node, Stmt, StmtKind, TraitItem, TraitItemKind};
|
||||||
|
@ -5447,7 +5448,7 @@ const FN_HEADER: hir::FnHeader = hir::FnHeader {
|
||||||
safety: hir::HeaderSafety::Normal(hir::Safety::Safe),
|
safety: hir::HeaderSafety::Normal(hir::Safety::Safe),
|
||||||
constness: hir::Constness::NotConst,
|
constness: hir::Constness::NotConst,
|
||||||
asyncness: hir::IsAsync::NotAsync,
|
asyncness: hir::IsAsync::NotAsync,
|
||||||
abi: rustc_target::spec::abi::Abi::Rust,
|
abi: ExternAbi::Rust,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ShouldImplTraitCase {
|
struct ShouldImplTraitCase {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
use clippy_config::Conf;
|
use clippy_config::Conf;
|
||||||
use clippy_utils::diagnostics::span_lint_and_then;
|
use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
use clippy_utils::msrvs::{self, Msrv};
|
use clippy_utils::msrvs::{self, Msrv};
|
||||||
|
@ -12,7 +13,7 @@ use rustc_middle::ty;
|
||||||
use rustc_session::impl_lint_pass;
|
use rustc_session::impl_lint_pass;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_abi::ExternAbi;
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
|
@ -183,11 +184,11 @@ fn already_const(header: hir::FnHeader) -> bool {
|
||||||
header.constness == Constness::Const
|
header.constness == Constness::Const
|
||||||
}
|
}
|
||||||
|
|
||||||
fn could_be_const_with_abi(msrv: &Msrv, abi: Abi) -> bool {
|
fn could_be_const_with_abi(msrv: &Msrv, abi: ExternAbi) -> bool {
|
||||||
match abi {
|
match abi {
|
||||||
Abi::Rust => true,
|
ExternAbi::Rust => true,
|
||||||
// `const extern "C"` was stabilized after 1.62.0
|
// `const extern "C"` was stabilized after 1.62.0
|
||||||
Abi::C { unwind: false } => msrv.meets(msrvs::CONST_EXTERN_C_FN),
|
ExternAbi::C { unwind: false } => msrv.meets(msrvs::CONST_EXTERN_C_FN),
|
||||||
// Rest ABIs are still unstable and need the `const_extern_fn` feature enabled.
|
// Rest ABIs are still unstable and need the `const_extern_fn` feature enabled.
|
||||||
_ => msrv.meets(msrvs::CONST_EXTERN_FN),
|
_ => msrv.meets(msrvs::CONST_EXTERN_FN),
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ use rustc_session::impl_lint_pass;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use rustc_span::symbol::kw;
|
use rustc_span::symbol::kw;
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_abi::ExternAbi;
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
|
@ -149,7 +149,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let attrs = cx.tcx.hir().attrs(hir_id);
|
let attrs = cx.tcx.hir().attrs(hir_id);
|
||||||
if header.abi != Abi::Rust || requires_exact_signature(attrs) {
|
if header.abi != ExternAbi::Rust || requires_exact_signature(attrs) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
header.is_async()
|
header.is_async()
|
||||||
|
|
|
@ -19,7 +19,7 @@ use rustc_session::declare_lint_pass;
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use rustc_span::symbol::kw;
|
use rustc_span::symbol::kw;
|
||||||
use rustc_span::{Span, sym};
|
use rustc_span::{Span, sym};
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_abi::ExternAbi;
|
||||||
use rustc_trait_selection::traits;
|
use rustc_trait_selection::traits;
|
||||||
use rustc_trait_selection::traits::misc::type_allowed_to_implement_copy;
|
use rustc_trait_selection::traits::misc::type_allowed_to_implement_copy;
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
|
||||||
match kind {
|
match kind {
|
||||||
FnKind::ItemFn(.., header) => {
|
FnKind::ItemFn(.., header) => {
|
||||||
let attrs = cx.tcx.hir().attrs(hir_id);
|
let attrs = cx.tcx.hir().attrs(hir_id);
|
||||||
if header.abi != Abi::Rust || requires_exact_signature(attrs) {
|
if header.abi != ExternAbi::Rust || requires_exact_signature(attrs) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,7 +5,7 @@ use rustc_hir::{Item, ItemKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_session::declare_lint_pass;
|
use rustc_session::declare_lint_pass;
|
||||||
use rustc_span::{BytePos, Pos};
|
use rustc_span::{BytePos, Pos};
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_abi::ExternAbi;
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
|
@ -46,7 +46,7 @@ impl<'tcx> LateLintPass<'tcx> for NoMangleWithRustAbi {
|
||||||
for attr in attrs {
|
for attr in attrs {
|
||||||
if let Some(ident) = attr.ident()
|
if let Some(ident) = attr.ident()
|
||||||
&& ident.name == rustc_span::sym::no_mangle
|
&& ident.name == rustc_span::sym::no_mangle
|
||||||
&& fn_sig.header.abi == Abi::Rust
|
&& fn_sig.header.abi == ExternAbi::Rust
|
||||||
&& let Some((fn_attrs, _)) = fn_snippet.rsplit_once("fn")
|
&& let Some((fn_attrs, _)) = fn_snippet.rsplit_once("fn")
|
||||||
&& !fn_attrs.contains("extern")
|
&& !fn_attrs.contains("extern")
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,7 @@ use clippy_utils::diagnostics::span_lint_and_then;
|
||||||
use clippy_utils::is_in_const_context;
|
use clippy_utils::is_in_const_context;
|
||||||
use clippy_utils::macros::macro_backtrace;
|
use clippy_utils::macros::macro_backtrace;
|
||||||
use clippy_utils::ty::{InteriorMut, implements_trait};
|
use clippy_utils::ty::{InteriorMut, implements_trait};
|
||||||
|
use rustc_abi::VariantIdx;
|
||||||
use rustc_hir::def::{DefKind, Res};
|
use rustc_hir::def::{DefKind, Res};
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_hir::{
|
use rustc_hir::{
|
||||||
|
@ -16,7 +17,6 @@ use rustc_middle::ty::adjustment::Adjust;
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||||
use rustc_session::impl_lint_pass;
|
use rustc_session::impl_lint_pass;
|
||||||
use rustc_span::{DUMMY_SP, Span, sym};
|
use rustc_span::{DUMMY_SP, Span, sym};
|
||||||
use rustc_target::abi::VariantIdx;
|
|
||||||
|
|
||||||
// FIXME: this is a correctness problem but there's no suitable
|
// FIXME: this is a correctness problem but there's no suitable
|
||||||
// warn-by-default category.
|
// warn-by-default category.
|
||||||
|
|
|
@ -19,7 +19,7 @@ use rustc_middle::ty::{self, RegionKind, TyCtxt};
|
||||||
use rustc_session::impl_lint_pass;
|
use rustc_session::impl_lint_pass;
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use rustc_span::{Span, sym};
|
use rustc_span::{Span, sym};
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_abi::ExternAbi;
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
|
@ -277,7 +277,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByRefOrValue {
|
||||||
let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
|
let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
|
||||||
match kind {
|
match kind {
|
||||||
FnKind::ItemFn(.., header) => {
|
FnKind::ItemFn(.., header) => {
|
||||||
if header.abi != Abi::Rust {
|
if header.abi != ExternAbi::Rust {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let attrs = cx.tcx.hir().attrs(hir_id);
|
let attrs = cx.tcx.hir().attrs(hir_id);
|
||||||
|
|
|
@ -19,7 +19,7 @@ use rustc_middle::ty::{self, Binder, ClauseKind, ExistentialPredicate, List, Pre
|
||||||
use rustc_session::declare_lint_pass;
|
use rustc_session::declare_lint_pass;
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
use rustc_span::{Span, sym};
|
use rustc_span::{Span, sym};
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_abi::ExternAbi;
|
||||||
use rustc_trait_selection::infer::InferCtxtExt as _;
|
use rustc_trait_selection::infer::InferCtxtExt as _;
|
||||||
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
|
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
|
||||||
use std::{fmt, iter};
|
use std::{fmt, iter};
|
||||||
|
@ -160,7 +160,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
|
||||||
|
|
||||||
check_mut_from_ref(cx, sig, None);
|
check_mut_from_ref(cx, sig, None);
|
||||||
|
|
||||||
if !matches!(sig.header.abi, Abi::Rust) {
|
if !matches!(sig.header.abi, ExternAbi::Rust) {
|
||||||
// Ignore `extern` functions with non-Rust calling conventions
|
// Ignore `extern` functions with non-Rust calling conventions
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
|
||||||
|
|
||||||
check_mut_from_ref(cx, sig, Some(body));
|
check_mut_from_ref(cx, sig, Some(body));
|
||||||
|
|
||||||
if !matches!(sig.header.abi, Abi::Rust) {
|
if !matches!(sig.header.abi, ExternAbi::Rust) {
|
||||||
// Ignore `extern` functions with non-Rust calling conventions
|
// Ignore `extern` functions with non-Rust calling conventions
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use clippy_utils::diagnostics::span_lint;
|
use clippy_utils::diagnostics::span_lint;
|
||||||
|
use rustc_abi::ExternAbi;
|
||||||
use rustc_hir::intravisit::{InferKind, Visitor, VisitorExt, walk_ty};
|
use rustc_hir::intravisit::{InferKind, Visitor, VisitorExt, walk_ty};
|
||||||
use rustc_hir::{self as hir, AmbigArg, GenericParamKind, TyKind};
|
use rustc_hir::{self as hir, AmbigArg, GenericParamKind, TyKind};
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
use rustc_target::spec::abi::Abi;
|
|
||||||
|
|
||||||
use super::TYPE_COMPLEXITY;
|
use super::TYPE_COMPLEXITY;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ impl<'tcx> Visitor<'tcx> for TypeComplexityVisitor {
|
||||||
TyKind::Path(..) | TyKind::Slice(..) | TyKind::Tup(..) | TyKind::Array(..) => (10 * self.nest, 1),
|
TyKind::Path(..) | TyKind::Slice(..) | TyKind::Tup(..) | TyKind::Array(..) => (10 * self.nest, 1),
|
||||||
|
|
||||||
// function types bring a lot of overhead
|
// function types bring a lot of overhead
|
||||||
TyKind::BareFn(bare) if bare.abi == Abi::Rust => (50 * self.nest, 1),
|
TyKind::BareFn(bare) if bare.abi == ExternAbi::Rust => (50 * self.nest, 1),
|
||||||
|
|
||||||
TyKind::TraitObject(param_bounds, _) => {
|
TyKind::TraitObject(param_bounds, _) => {
|
||||||
let has_lifetime_parameters = param_bounds.iter().any(|bound| {
|
let has_lifetime_parameters = param_bounds.iter().any(|bound| {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
//! code was written, and check if the span contains that text. Note this will only work correctly
|
//! code was written, and check if the span contains that text. Note this will only work correctly
|
||||||
//! if the span is not from a `macro_rules` based macro.
|
//! if the span is not from a `macro_rules` based macro.
|
||||||
|
|
||||||
|
use rustc_abi::ExternAbi;
|
||||||
use rustc_ast::AttrStyle;
|
use rustc_ast::AttrStyle;
|
||||||
use rustc_ast::ast::{AttrKind, Attribute, IntTy, LitIntType, LitKind, StrStyle, TraitObjectSyntax, UintTy};
|
use rustc_ast::ast::{AttrKind, Attribute, IntTy, LitIntType, LitKind, StrStyle, TraitObjectSyntax, UintTy};
|
||||||
use rustc_ast::token::CommentKind;
|
use rustc_ast::token::CommentKind;
|
||||||
|
@ -26,7 +27,6 @@ use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
use rustc_span::symbol::{Ident, kw};
|
use rustc_span::symbol::{Ident, kw};
|
||||||
use rustc_span::{Span, Symbol};
|
use rustc_span::{Span, Symbol};
|
||||||
use rustc_target::spec::abi::Abi;
|
|
||||||
|
|
||||||
/// The search pattern to look for. Used by `span_matches_pat`
|
/// The search pattern to look for. Used by `span_matches_pat`
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -233,7 +233,7 @@ fn fn_header_search_pat(header: FnHeader) -> Pat {
|
||||||
Pat::Str("const")
|
Pat::Str("const")
|
||||||
} else if header.is_unsafe() {
|
} else if header.is_unsafe() {
|
||||||
Pat::Str("unsafe")
|
Pat::Str("unsafe")
|
||||||
} else if header.abi != Abi::Rust {
|
} else if header.abi != ExternAbi::Rust {
|
||||||
Pat::Str("extern")
|
Pat::Str("extern")
|
||||||
} else {
|
} else {
|
||||||
Pat::MultiStr(&["fn", "extern"])
|
Pat::MultiStr(&["fn", "extern"])
|
||||||
|
@ -375,7 +375,7 @@ fn ty_search_pat(ty: &Ty<'_>) -> (Pat, Pat) {
|
||||||
TyKind::BareFn(bare_fn) => (
|
TyKind::BareFn(bare_fn) => (
|
||||||
if bare_fn.safety.is_unsafe() {
|
if bare_fn.safety.is_unsafe() {
|
||||||
Pat::Str("unsafe")
|
Pat::Str("unsafe")
|
||||||
} else if bare_fn.abi != Abi::Rust {
|
} else if bare_fn.abi != ExternAbi::Rust {
|
||||||
Pat::Str("extern")
|
Pat::Str("extern")
|
||||||
} else {
|
} else {
|
||||||
Pat::MultiStr(&["fn", "extern"])
|
Pat::MultiStr(&["fn", "extern"])
|
||||||
|
|
|
@ -9,6 +9,7 @@ use std::sync::Arc;
|
||||||
use crate::source::{SpanRangeExt, walk_span_to_context};
|
use crate::source::{SpanRangeExt, walk_span_to_context};
|
||||||
use crate::{clip, is_direct_expn_of, sext, unsext};
|
use crate::{clip, is_direct_expn_of, sext, unsext};
|
||||||
|
|
||||||
|
use rustc_abi::Size;
|
||||||
use rustc_apfloat::Float;
|
use rustc_apfloat::Float;
|
||||||
use rustc_apfloat::ieee::{Half, Quad};
|
use rustc_apfloat::ieee::{Half, Quad};
|
||||||
use rustc_ast::ast::{self, LitFloatType, LitKind};
|
use rustc_ast::ast::{self, LitFloatType, LitKind};
|
||||||
|
@ -25,7 +26,6 @@ use rustc_middle::{bug, mir, span_bug};
|
||||||
use rustc_span::def_id::DefId;
|
use rustc_span::def_id::DefId;
|
||||||
use rustc_span::symbol::Ident;
|
use rustc_span::symbol::Ident;
|
||||||
use rustc_span::{SyntaxContext, sym};
|
use rustc_span::{SyntaxContext, sym};
|
||||||
use rustc_target::abi::Size;
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
// FIXME: switch to something more ergonomic here, once available.
|
// FIXME: switch to something more ergonomic here, once available.
|
||||||
// (Currently there is no way to opt into sysroot crates without `extern crate`.)
|
// (Currently there is no way to opt into sysroot crates without `extern crate`.)
|
||||||
|
extern crate rustc_abi;
|
||||||
extern crate rustc_ast;
|
extern crate rustc_ast;
|
||||||
extern crate rustc_ast_pretty;
|
extern crate rustc_ast_pretty;
|
||||||
extern crate rustc_attr_parsing;
|
extern crate rustc_attr_parsing;
|
||||||
|
@ -48,7 +49,6 @@ extern crate rustc_middle;
|
||||||
extern crate rustc_mir_dataflow;
|
extern crate rustc_mir_dataflow;
|
||||||
extern crate rustc_session;
|
extern crate rustc_session;
|
||||||
extern crate rustc_span;
|
extern crate rustc_span;
|
||||||
extern crate rustc_target;
|
|
||||||
extern crate rustc_trait_selection;
|
extern crate rustc_trait_selection;
|
||||||
extern crate smallvec;
|
extern crate smallvec;
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ use rustc_span::hygiene::{ExpnKind, MacroKind};
|
||||||
use rustc_span::source_map::SourceMap;
|
use rustc_span::source_map::SourceMap;
|
||||||
use rustc_span::symbol::{Ident, Symbol, kw};
|
use rustc_span::symbol::{Ident, Symbol, kw};
|
||||||
use rustc_span::{InnerSpan, Span, sym};
|
use rustc_span::{InnerSpan, Span, sym};
|
||||||
use rustc_target::abi::Integer;
|
use rustc_abi::Integer;
|
||||||
use visitors::{Visitable, for_each_unconsumed_temporary};
|
use visitors::{Visitable, for_each_unconsumed_temporary};
|
||||||
|
|
||||||
use crate::consts::{ConstEvalCtxt, Constant, mir_to_const};
|
use crate::consts::{ConstEvalCtxt, Constant, mir_to_const};
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
use core::ops::ControlFlow;
|
use core::ops::ControlFlow;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
use rustc_abi::VariantIdx;
|
||||||
use rustc_ast::ast::Mutability;
|
use rustc_ast::ast::Mutability;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
|
@ -23,7 +24,6 @@ use rustc_middle::ty::{
|
||||||
};
|
};
|
||||||
use rustc_span::symbol::Ident;
|
use rustc_span::symbol::Ident;
|
||||||
use rustc_span::{DUMMY_SP, Span, Symbol, sym};
|
use rustc_span::{DUMMY_SP, Span, Symbol, sym};
|
||||||
use rustc_target::abi::VariantIdx;
|
|
||||||
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
|
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
|
||||||
use rustc_trait_selection::traits::query::normalize::QueryNormalizeExt;
|
use rustc_trait_selection::traits::query::normalize::QueryNormalizeExt;
|
||||||
use rustc_trait_selection::traits::{Obligation, ObligationCause};
|
use rustc_trait_selection::traits::{Obligation, ObligationCause};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue