Skip to content

Commit 9e3a093

Browse files
compiler: reuse stowed Target::abi_map
We preserve `AbiMap::from_target` for now as other PRs in flight use it. We will remove it from public API when it isn't a gratuitous conflict.
1 parent 0dda4fa commit 9e3a093

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use rustc_middle::ty::{
2525
TypeVisitable, TypeVisitableExt, fold_regions,
2626
};
2727
use rustc_session::lint::builtin::UNINHABITED_STATIC;
28-
use rustc_target::spec::{AbiMap, AbiMapping};
28+
use rustc_target::spec::AbiMapping;
2929
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
3030
use rustc_trait_selection::error_reporting::traits::on_unimplemented::OnUnimplementedDirective;
3131
use rustc_trait_selection::traits;
@@ -55,7 +55,7 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: ExternAbi
5555
// FIXME: this should be checked earlier, e.g. in `rustc_ast_lowering`, to fix
5656
// things like #86232.
5757

58-
match AbiMap::from_target(&tcx.sess.target).canonize_abi(abi, false) {
58+
match tcx.sess.target.abi_map().canonize_abi(abi, false) {
5959
AbiMapping::Direct(..) => (),
6060
AbiMapping::Invalid => {
6161
let mut err = struct_span_code_err!(
@@ -79,7 +79,7 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: ExternAbi
7979
pub fn check_abi_fn_ptr(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: ExternAbi) {
8080
// This is always an FCW, even for `AbiMapping::Invalid`, since we started linting later than
8181
// in `check_abi` above.
82-
match AbiMap::from_target(&tcx.sess.target).canonize_abi(abi, false) {
82+
match tcx.sess.target.abi_map().canonize_abi(abi, false) {
8383
AbiMapping::Direct(..) => (),
8484
// This is not a redundant match arm: these ABIs started linting after introducing
8585
// UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS already existed and we want to

compiler/rustc_ty_utils/src/abi.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_session::config::OptLevel;
1414
use rustc_span::DUMMY_SP;
1515
use rustc_span::def_id::DefId;
1616
use rustc_target::callconv::{
17-
AbiMap, ArgAbi, ArgAttribute, ArgAttributes, ArgExtension, FnAbi, PassMode,
17+
ArgAbi, ArgAttribute, ArgAttributes, ArgExtension, FnAbi, PassMode,
1818
};
1919
use tracing::debug;
2020

@@ -481,8 +481,7 @@ fn fn_abi_new_uncached<'tcx>(
481481
};
482482
let sig = tcx.normalize_erasing_regions(cx.typing_env, sig);
483483

484-
let abi_map = AbiMap::from_target(&tcx.sess.target);
485-
let conv = abi_map.canonize_abi(sig.abi, sig.c_variadic).unwrap();
484+
let conv = tcx.sess.target.abi_map().canonize_abi(sig.abi, sig.c_variadic).unwrap();
486485

487486
let mut inputs = sig.inputs();
488487
let extra_args = if sig.abi == ExternAbi::RustCall {

0 commit comments

Comments
 (0)