Skip to content

Commit 18af91b

Browse files
compiler: Remove unsupported_fn_ptr_calling_conventions lint
1 parent 6559a51 commit 18af91b

File tree

5 files changed

+7
-31
lines changed

5 files changed

+7
-31
lines changed

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::cell::LazyCell;
22
use std::ops::ControlFlow;
33

4-
use rustc_abi::FieldIdx;
4+
use rustc_abi::{ExternAbi, FieldIdx};
55
use rustc_attr_data_structures::AttributeKind;
66
use rustc_attr_data_structures::ReprAttr::ReprPacked;
77
use rustc_data_structures::unord::{UnordMap, UnordSet};
@@ -13,7 +13,6 @@ use rustc_infer::infer::{RegionVariableOrigin, TyCtxtInferExt};
1313
use rustc_infer::traits::{Obligation, ObligationCauseCode};
1414
use rustc_lint_defs::builtin::{
1515
REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS, UNSUPPORTED_CALLING_CONVENTIONS,
16-
UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS,
1716
};
1817
use rustc_middle::hir::nested_filter;
1918
use rustc_middle::middle::resolve_bound_vars::ResolvedArg;
@@ -71,30 +70,6 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: ExternAbi
7170
}
7271
}
7372

74-
pub fn check_abi_fn_ptr(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: ExternAbi) {
75-
// This is always an FCW, even for `AbiMapping::Invalid`, since we started linting later than
76-
// in `check_abi` above.
77-
match AbiMap::from_target(&tcx.sess.target).canonize_abi(abi, false) {
78-
AbiMapping::Direct(..) => (),
79-
// This is not a redundant match arm: these ABIs started linting after introducing
80-
// UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS already existed and we want to
81-
// avoid expanding the scope of that lint so it can move to a hard error sooner.
82-
AbiMapping::Deprecated(..) => {
83-
tcx.node_span_lint(UNSUPPORTED_CALLING_CONVENTIONS, hir_id, span, |lint| {
84-
lint.primary_message("use of calling convention not supported on this target");
85-
add_abi_diag_help(abi, lint);
86-
});
87-
}
88-
AbiMapping::Invalid => {
89-
tcx.node_span_lint(UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS, hir_id, span, |lint| {
90-
lint.primary_message(format!(
91-
"the calling convention {abi} is not supported on this target"
92-
));
93-
});
94-
}
95-
}
96-
}
97-
9873
pub fn check_custom_abi(tcx: TyCtxt<'_>, def_id: LocalDefId, fn_sig: FnSig<'_>, fn_sig_span: Span) {
9974
if fn_sig.abi == ExternAbi::Custom {
10075
// Function definitions that use `extern "custom"` must be naked functions.
@@ -862,6 +837,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
862837
let hir::ItemKind::ForeignMod { abi, items } = it.kind else {
863838
return;
864839
};
840+
865841
check_abi(tcx, it.hir_id(), it.span, abi);
866842

867843
for item in items {

compiler/rustc_hir_analysis/src/check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ pub mod wfcheck;
7272

7373
use std::num::NonZero;
7474

75-
pub use check::{check_abi, check_abi_fn_ptr, check_custom_abi};
76-
use rustc_abi::{ExternAbi, VariantIdx};
75+
pub use check::{check_abi, check_custom_abi};
76+
use rustc_abi::VariantIdx;
7777
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
7878
use rustc_errors::{Diag, ErrorGuaranteed, pluralize, struct_span_code_err};
7979
use rustc_hir::LangItem;

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ use rustc_trait_selection::traits::wf::object_region_bounds;
5151
use rustc_trait_selection::traits::{self, FulfillmentError};
5252
use tracing::{debug, instrument};
5353

54-
use crate::check::check_abi_fn_ptr;
54+
use crate::check::check_abi;
5555
use crate::errors::{AmbiguousLifetimeBound, BadReturnTypeNotation};
5656
use crate::hir_ty_lowering::errors::{GenericsArgsErrExtend, prohibit_assoc_item_constraint};
5757
use crate::hir_ty_lowering::generics::{check_generic_arg_count, lower_generic_args};
@@ -2660,7 +2660,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
26602660
if let hir::Node::Ty(hir::Ty { kind: hir::TyKind::BareFn(bare_fn_ty), span, .. }) =
26612661
tcx.hir_node(hir_id)
26622662
{
2663-
check_abi_fn_ptr(tcx, hir_id, *span, bare_fn_ty.abi);
2663+
check_abi(tcx, hir_id, *span, bare_fn_ty.abi);
26642664
}
26652665

26662666
// reject function types that violate cmse ABI requirements

compiler/rustc_lint/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ fn register_builtins(store: &mut LintStore) {
608608
"converted into hard error, see issue #127323 \
609609
<https://github.com/rust-lang/rust/issues/127323> for more information",
610610
);
611+
store.register_removed("unsupported_fn_ptr_calling_conventions", "converted into hard error");
611612
store.register_removed(
612613
"undefined_naked_function_abi",
613614
"converted into hard error, see PR #139001 \

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ declare_lint_pass! {
122122
UNSAFE_OP_IN_UNSAFE_FN,
123123
UNSTABLE_NAME_COLLISIONS,
124124
UNSTABLE_SYNTAX_PRE_EXPANSION,
125-
UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS,
126125
UNUSED_ASSIGNMENTS,
127126
UNUSED_ASSOCIATED_TYPE_BOUNDS,
128127
UNUSED_ATTRIBUTES,

0 commit comments

Comments
 (0)