Rollup merge of #132574 - workingjubilee:abi-in-compiler, r=compiler-errors

compiler: Directly use rustc_abi almost everywhere

Use rustc_abi instead of rustc_target where applicable. This is mostly described by the following substitutions:
```rust
match path_substring {
    rustc_target::spec::abi::Abi => rustc_abi::ExternAbi,
    rustc_target::abi::call => rustc_target::callconv,
    rustc_target::abi => rustc_abi,
}
```

A number of spot-fixes make that not quite the whole story.

The main exception is in 33edc68 where I get a lot more persnickety about how things are imported, especially in `rustc_middle::ty::layout`, not just from where. This includes putting an end to a reexport of `rustc_middle::ty::ReprOptions`, for the same reason that the rest of this change is happening: reexports mostly confound things.

This notably omits rustc_passes and the ast crates, as I'm still examining a question I have about how they do stability checking of `extern "Abi"` strings and if I can simplify their logic. The rustc_abi and rustc_target crates also go untouched because they will be entangled in that cleanup.

r? compiler-errors
This commit is contained in:
Jubilee 2024-11-03 15:25:00 -08:00 committed by GitHub
commit 72df7780dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
141 changed files with 363 additions and 385 deletions

View file

@ -12,7 +12,7 @@ use std::marker::PhantomData;
use std::ops::{Bound, Deref};
use std::{fmt, iter, mem};
use rustc_abi::{FieldIdx, Layout, LayoutData, TargetDataLayout, VariantIdx};
use rustc_abi::{ExternAbi, FieldIdx, Layout, LayoutData, TargetDataLayout, VariantIdx};
use rustc_ast::{self as ast, attr};
use rustc_data_structures::defer;
use rustc_data_structures::fingerprint::Fingerprint;
@ -49,7 +49,6 @@ use rustc_session::{Limit, MetadataKind, Session};
use rustc_span::def_id::{CRATE_DEF_ID, DefPathHash, StableCrateId};
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{DUMMY_SP, Span};
use rustc_target::spec::abi;
use rustc_type_ir::TyKind::*;
use rustc_type_ir::fold::TypeFoldable;
use rustc_type_ir::lang_items::TraitSolverLangItem;
@ -136,7 +135,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
type AllocId = crate::mir::interpret::AllocId;
type Pat = Pattern<'tcx>;
type Safety = hir::Safety;
type Abi = abi::Abi;
type Abi = ExternAbi;
type Const = ty::Const<'tcx>;
type PlaceholderConst = ty::PlaceholderConst;
@ -695,13 +694,13 @@ impl<'tcx> rustc_type_ir::inherent::DefId<TyCtxt<'tcx>> for DefId {
}
}
impl<'tcx> rustc_type_ir::inherent::Abi<TyCtxt<'tcx>> for abi::Abi {
impl<'tcx> rustc_type_ir::inherent::Abi<TyCtxt<'tcx>> for ExternAbi {
fn rust() -> Self {
abi::Abi::Rust
ExternAbi::Rust
}
fn is_rust(self) -> bool {
matches!(self, abi::Abi::Rust)
matches!(self, ExternAbi::Rust)
}
}
@ -2557,7 +2556,7 @@ impl<'tcx> TyCtxt<'tcx> {
ty::Tuple(params) => *params,
_ => bug!(),
};
self.mk_fn_sig(params, s.output(), s.c_variadic, safety, abi::Abi::Rust)
self.mk_fn_sig(params, s.output(), s.c_variadic, safety, ExternAbi::Rust)
})
}
@ -2819,7 +2818,7 @@ impl<'tcx> TyCtxt<'tcx> {
output: I::Item,
c_variadic: bool,
safety: hir::Safety,
abi: abi::Abi,
abi: ExternAbi,
) -> T::Output
where
I: IntoIterator<Item = T>,