Skip to content

Commit ee5e21f

Browse files
compiler: Remove check_abi and check_abi_fn_ptr
They are redundant with the rustc_ast_lowering code.
1 parent 2bf340c commit ee5e21f

File tree

4 files changed

+2
-38
lines changed

4 files changed

+2
-38
lines changed

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ use rustc_hir::def::{CtorKind, DefKind};
1010
use rustc_hir::{LangItem, Node, intravisit};
1111
use rustc_infer::infer::{RegionVariableOrigin, TyCtxtInferExt};
1212
use rustc_infer::traits::{Obligation, ObligationCauseCode};
13-
use rustc_lint_defs::builtin::{
14-
REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS, UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS,
15-
};
13+
use rustc_lint_defs::builtin::REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS;
1614
use rustc_middle::hir::nested_filter;
1715
use rustc_middle::middle::resolve_bound_vars::ResolvedArg;
1816
use rustc_middle::middle::stability::EvalResult;
@@ -35,28 +33,6 @@ use {rustc_attr_data_structures as attrs, rustc_hir as hir};
3533
use super::compare_impl_item::check_type_bounds;
3634
use super::*;
3735

38-
pub fn check_abi(tcx: TyCtxt<'_>, span: Span, abi: ExternAbi) {
39-
if !tcx.sess.target.is_abi_supported(abi) {
40-
struct_span_code_err!(
41-
tcx.dcx(),
42-
span,
43-
E0570,
44-
"`{abi}` is not a supported ABI for the current target",
45-
)
46-
.emit();
47-
}
48-
}
49-
50-
pub fn check_abi_fn_ptr(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: ExternAbi) {
51-
if !tcx.sess.target.is_abi_supported(abi) {
52-
tcx.node_span_lint(UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS, hir_id, span, |lint| {
53-
lint.primary_message(format!(
54-
"the calling convention {abi} is not supported on this target"
55-
));
56-
});
57-
}
58-
}
59-
6036
fn check_struct(tcx: TyCtxt<'_>, def_id: LocalDefId) {
6137
let def = tcx.adt_def(def_id);
6238
let span = tcx.def_span(def_id);
@@ -779,7 +755,6 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
779755
let hir::ItemKind::ForeignMod { abi, items } = it.kind else {
780756
return;
781757
};
782-
check_abi(tcx, it.span, abi);
783758

784759
for item in items {
785760
let def_id = item.id.owner_id.def_id;

compiler/rustc_hir_analysis/src/check/mod.rs

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

7373
use std::num::NonZero;
7474

75-
pub use check::{check_abi, check_abi_fn_ptr};
76-
use rustc_abi::{ExternAbi, VariantIdx};
75+
use rustc_abi::VariantIdx;
7776
use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
7877
use rustc_errors::{Diag, ErrorGuaranteed, pluralize, struct_span_code_err};
7978
use rustc_hir::def_id::{DefId, LocalDefId};

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ use rustc_trait_selection::traits::wf::object_region_bounds;
5050
use rustc_trait_selection::traits::{self, ObligationCtxt};
5151
use tracing::{debug, instrument};
5252

53-
use crate::check::check_abi_fn_ptr;
5453
use crate::errors::{AmbiguousLifetimeBound, BadReturnTypeNotation};
5554
use crate::hir_ty_lowering::errors::{GenericsArgsErrExtend, prohibit_assoc_item_constraint};
5655
use crate::hir_ty_lowering::generics::{check_generic_arg_count, lower_generic_args};
@@ -2736,12 +2735,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
27362735
let fn_ty = tcx.mk_fn_sig(input_tys, output_ty, decl.c_variadic, safety, abi);
27372736
let bare_fn_ty = ty::Binder::bind_with_vars(fn_ty, bound_vars);
27382737

2739-
if let hir::Node::Ty(hir::Ty { kind: hir::TyKind::BareFn(bare_fn_ty), span, .. }) =
2740-
tcx.hir_node(hir_id)
2741-
{
2742-
check_abi_fn_ptr(tcx, hir_id, *span, bare_fn_ty.abi);
2743-
}
2744-
27452738
// reject function types that violate cmse ABI requirements
27462739
cmse::validate_cmse_abi(self.tcx(), self.dcx(), hir_id, abi, bare_fn_ty);
27472740

compiler/rustc_hir_typeck/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ use rustc_errors::{Applicability, ErrorGuaranteed, pluralize, struct_span_code_e
4848
use rustc_hir as hir;
4949
use rustc_hir::def::{DefKind, Res};
5050
use rustc_hir::{HirId, HirIdMap, Node};
51-
use rustc_hir_analysis::check::check_abi;
5251
use rustc_hir_analysis::hir_ty_lowering::HirTyLowerer;
5352
use rustc_infer::traits::{ObligationCauseCode, ObligationInspector, WellFormedLoc};
5453
use rustc_middle::query::Providers;
@@ -149,8 +148,6 @@ fn typeck_with_inspect<'tcx>(
149148
tcx.fn_sig(def_id).instantiate_identity()
150149
};
151150

152-
check_abi(tcx, span, fn_sig.abi());
153-
154151
// Compute the function signature from point of view of inside the fn.
155152
let mut fn_sig = tcx.liberate_late_bound_regions(def_id.to_def_id(), fn_sig);
156153

0 commit comments

Comments
 (0)