Rollup merge of #132550 - workingjubilee:rustc-abi-selects-borrowck-for-mono-sans, r=compiler-errors

compiler: Continue introducing rustc_abi to the compiler

Some crates have not heard of rustc_abi before, so arrange introductions.

Encourage some crates to go further and leave rustc_target behind: it was no good for them.
This commit is contained in:
Matthias Krüger 2024-11-03 12:08:56 +01:00 committed by GitHub
commit 1ba782ab3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 35 additions and 30 deletions

View File

@ -3346,6 +3346,7 @@ dependencies = [
"either",
"itertools",
"polonius-engine",
"rustc_abi",
"rustc_data_structures",
"rustc_errors",
"rustc_fluent_macro",
@ -3359,7 +3360,6 @@ dependencies = [
"rustc_mir_dataflow",
"rustc_session",
"rustc_span",
"rustc_target",
"rustc_trait_selection",
"rustc_traits",
"smallvec",
@ -3706,6 +3706,7 @@ name = "rustc_hir"
version = "0.0.0"
dependencies = [
"odht",
"rustc_abi",
"rustc_arena",
"rustc_ast",
"rustc_data_structures",
@ -4131,6 +4132,7 @@ dependencies = [
name = "rustc_monomorphize"
version = "0.0.0"
dependencies = [
"rustc_abi",
"rustc_data_structures",
"rustc_errors",
"rustc_fluent_macro",
@ -4335,6 +4337,7 @@ name = "rustc_sanitizers"
version = "0.0.0"
dependencies = [
"bitflags 2.6.0",
"rustc_abi",
"rustc_data_structures",
"rustc_hir",
"rustc_middle",
@ -4467,6 +4470,7 @@ name = "rustc_trait_selection"
version = "0.0.0"
dependencies = [
"itertools",
"rustc_abi",
"rustc_ast",
"rustc_ast_ir",
"rustc_attr",
@ -4483,7 +4487,6 @@ dependencies = [
"rustc_serialize",
"rustc_session",
"rustc_span",
"rustc_target",
"rustc_transmute",
"rustc_type_ir",
"smallvec",

View File

@ -8,6 +8,7 @@ edition = "2021"
either = "1.5.0"
itertools = "0.12"
polonius-engine = "0.13.0"
rustc_abi = { path = "../rustc_abi" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
@ -21,7 +22,6 @@ rustc_middle = { path = "../rustc_middle" }
rustc_mir_dataflow = { path = "../rustc_mir_dataflow" }
rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
rustc_target = { path = "../rustc_target" }
rustc_trait_selection = { path = "../rustc_trait_selection" }
rustc_traits = { path = "../rustc_traits" }
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }

View File

@ -1,5 +1,6 @@
//! Borrow checker diagnostics.
use rustc_abi::{FieldIdx, VariantIdx};
use rustc_errors::{Applicability, Diag, MultiSpan};
use rustc_hir::def::{CtorKind, Namespace};
use rustc_hir::{self as hir, CoroutineKind, LangItem};
@ -21,7 +22,6 @@
use rustc_span::source_map::Spanned;
use rustc_span::symbol::sym;
use rustc_span::{DUMMY_SP, Span, Symbol};
use rustc_target::abi::{FieldIdx, VariantIdx};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{

View File

@ -4,6 +4,7 @@
use core::ops::ControlFlow;
use hir::{ExprKind, Param};
use rustc_abi::FieldIdx;
use rustc_errors::{Applicability, Diag};
use rustc_hir::intravisit::Visitor;
use rustc_hir::{self as hir, BindingMode, ByRef, Node};
@ -16,7 +17,6 @@
use rustc_middle::ty::{self, InstanceKind, Ty, TyCtxt, Upcast};
use rustc_span::symbol::{Symbol, kw};
use rustc_span::{BytePos, DesugaringKind, Span, sym};
use rustc_target::abi::FieldIdx;
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits;

View File

@ -1103,7 +1103,7 @@ fn suggest_deref_closure_return(&self, diag: &mut Diag<'_>) {
peeled_ty,
liberated_sig.c_variadic,
hir::Safety::Safe,
rustc_target::spec::abi::Abi::Rust,
rustc_abi::ExternAbi::Rust,
)),
);
let closure_ty = Ty::new_closure(

View File

@ -21,6 +21,7 @@
use std::ops::Deref;
use consumers::{BodyWithBorrowckFacts, ConsumerOptions};
use rustc_abi::FieldIdx;
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_data_structures::graph::dominators::Dominators;
use rustc_errors::Diag;
@ -45,7 +46,6 @@
};
use rustc_session::lint::builtin::UNUSED_MUT;
use rustc_span::{Span, Symbol};
use rustc_target::abi::FieldIdx;
use smallvec::SmallVec;
use tracing::{debug, instrument};

View File

@ -1,7 +1,7 @@
use rustc_abi::FieldIdx;
use rustc_data_structures::graph::dominators::Dominators;
use rustc_middle::mir::{BasicBlock, Body, BorrowKind, Location, Place, PlaceRef, ProjectionElem};
use rustc_middle::ty::TyCtxt;
use rustc_target::abi::FieldIdx;
use tracing::debug;
use crate::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation};

View File

@ -4,6 +4,7 @@
use std::{fmt, iter, mem};
use either::Either;
use rustc_abi::{FIRST_VARIANT, FieldIdx};
use rustc_data_structures::frozen::Frozen;
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_errors::ErrorGuaranteed;
@ -40,7 +41,6 @@
use rustc_span::source_map::Spanned;
use rustc_span::symbol::sym;
use rustc_span::{DUMMY_SP, Span};
use rustc_target::abi::{FIRST_VARIANT, FieldIdx};
use rustc_trait_selection::traits::query::type_op::custom::{
CustomTypeOp, scrape_region_constraints,
};

View File

@ -6,6 +6,7 @@ edition = "2021"
[dependencies]
# tidy-alphabetical-start
odht = { version = "0.3.1", features = ["nightly"] }
rustc_abi = { path = "../rustc_abi" }
rustc_arena = { path = "../rustc_arena" }
rustc_ast = { path = "../rustc_ast" }
rustc_data_structures = { path = "../rustc_data_structures" }

View File

@ -1,5 +1,6 @@
use std::fmt;
use rustc_abi::ExternAbi;
use rustc_ast::util::parser::ExprPrecedence;
use rustc_ast::{
self as ast, Attribute, FloatTy, InlineAsmOptions, InlineAsmTemplatePiece, IntTy, Label,
@ -19,7 +20,6 @@
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{BytePos, DUMMY_SP, ErrorGuaranteed, Span};
use rustc_target::asm::InlineAsmRegOrRegClass;
use rustc_target::spec::abi::Abi;
use smallvec::SmallVec;
use tracing::debug;
@ -2735,7 +2735,7 @@ pub fn from_name(name: Symbol) -> Option<Self> {
#[derive(Debug, Clone, Copy, HashStable_Generic)]
pub struct BareFnTy<'hir> {
pub safety: Safety,
pub abi: Abi,
pub abi: ExternAbi,
pub generic_params: &'hir [GenericParam<'hir>],
pub decl: &'hir FnDecl<'hir>,
pub param_names: &'hir [Ident],
@ -3313,7 +3313,7 @@ pub fn is_struct_or_union(&self) -> bool {
expect_mod, &'hir Mod<'hir>, ItemKind::Mod(m), m;
expect_foreign_mod, (Abi, &'hir [ForeignItemRef]),
expect_foreign_mod, (ExternAbi, &'hir [ForeignItemRef]),
ItemKind::ForeignMod { abi, items }, (*abi, items);
expect_global_asm, &'hir InlineAsm<'hir>, ItemKind::GlobalAsm(asm), asm;
@ -3386,7 +3386,7 @@ pub struct FnHeader {
pub safety: Safety,
pub constness: Constness,
pub asyncness: IsAsync,
pub abi: Abi,
pub abi: ExternAbi,
}
impl FnHeader {
@ -3428,7 +3428,7 @@ pub enum ItemKind<'hir> {
/// A module.
Mod(&'hir Mod<'hir>),
/// An external module, e.g. `extern { .. }`.
ForeignMod { abi: Abi, items: &'hir [ForeignItemRef] },
ForeignMod { abi: ExternAbi, items: &'hir [ForeignItemRef] },
/// Module-level inline assembly (from `global_asm!`).
GlobalAsm(&'hir InlineAsm<'hir>),
/// A type alias, e.g., `type Foo = Bar<u8>`.

View File

@ -5,6 +5,7 @@ edition = "2021"
[dependencies]
# tidy-alphabetical-start
rustc_abi = { path = "../rustc_abi" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_fluent_macro = { path = "../rustc_fluent_macro" }

View File

@ -210,6 +210,7 @@
use std::path::PathBuf;
use move_check::MoveCheckState;
use rustc_abi::Size;
use rustc_data_structures::sync::{LRef, MTLock, par_for_each_in};
use rustc_data_structures::unord::{UnordMap, UnordSet};
use rustc_hir as hir;
@ -236,7 +237,6 @@
use rustc_span::source_map::{Spanned, dummy_spanned, respan};
use rustc_span::symbol::{Ident, sym};
use rustc_span::{DUMMY_SP, Span};
use rustc_target::abi::Size;
use tracing::{debug, instrument, trace};
use crate::errors::{self, EncounteredErrorWhileInstantiating, NoOptimizedMir, RecursionLimit};

View File

@ -7,6 +7,7 @@ edition = "2021"
bitflags = "2.5.0"
tracing = "0.1"
twox-hash = "1.6.3"
rustc_abi = { path = "../rustc_abi" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_hir = { path = "../rustc_hir" }
rustc_middle = { path = "../rustc_middle" }

View File

@ -7,6 +7,7 @@
use std::fmt::Write as _;
use rustc_abi::{ExternAbi, Integer};
use rustc_data_structures::base_n::{ALPHANUMERIC_ONLY, CASE_INSENSITIVE, ToBaseN};
use rustc_data_structures::fx::FxHashMap;
use rustc_hir as hir;
@ -18,8 +19,6 @@
};
use rustc_span::def_id::DefId;
use rustc_span::sym;
use rustc_target::abi::Integer;
use rustc_target::spec::abi::Abi;
use tracing::instrument;
use crate::cfi::typeid::TypeIdOptions;
@ -185,7 +184,7 @@ fn encode_fnsig<'tcx>(
let mut encode_ty_options = EncodeTyOptions::from_bits(options.bits())
.unwrap_or_else(|| bug!("encode_fnsig: invalid option(s) `{:?}`", options.bits()));
match fn_sig.abi {
Abi::C { .. } => {
ExternAbi::C { .. } => {
encode_ty_options.insert(EncodeTyOptions::GENERALIZE_REPR_C);
}
_ => {

View File

@ -7,7 +7,7 @@
use rustc_data_structures::fx::FxHashMap;
use rustc_middle::bug;
use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
use rustc_target::abi::call::{Conv, FnAbi, PassMode};
use rustc_target::callconv::{Conv, FnAbi, PassMode};
use tracing::instrument;
mod encode;

View File

@ -6,7 +6,7 @@
use bitflags::bitflags;
use rustc_middle::ty::{Instance, Ty, TyCtxt};
use rustc_target::abi::call::FnAbi;
use rustc_target::callconv::FnAbi;
bitflags! {
/// Options for typeid_for_fnabi.

View File

@ -7,7 +7,7 @@
use std::hash::Hasher;
use rustc_middle::ty::{Instance, InstanceKind, ReifyReason, Ty, TyCtxt};
use rustc_target::abi::call::FnAbi;
use rustc_target::callconv::FnAbi;
use twox_hash::XxHash64;
pub use crate::cfi::typeid::{TypeIdOptions, itanium_cxx_abi};

View File

@ -6,6 +6,7 @@ edition = "2021"
[dependencies]
# tidy-alphabetical-start
itertools = "0.12"
rustc_abi = { path = "../rustc_abi" }
rustc_ast = { path = "../rustc_ast" }
rustc_ast_ir = { path = "../rustc_ast_ir" }
rustc_attr = { path = "../rustc_attr" }
@ -22,7 +23,6 @@ rustc_query_system = { path = "../rustc_query_system" }
rustc_serialize = { path = "../rustc_serialize" }
rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
rustc_target = { path = "../rustc_target" }
rustc_transmute = { path = "../rustc_transmute", features = ["rustc"] }
rustc_type_ir = { path = "../rustc_type_ir" }
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }

View File

@ -50,6 +50,7 @@
use std::path::PathBuf;
use std::{cmp, fmt, iter};
use rustc_abi::ExternAbi;
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_errors::{Applicability, Diag, DiagStyledString, IntoDiagArg, StringPart, pluralize};
use rustc_hir::def::DefKind;
@ -67,7 +68,6 @@
TypeVisitableExt,
};
use rustc_span::{BytePos, DesugaringKind, Pos, Span, sym};
use rustc_target::spec::abi;
use tracing::{debug, instrument};
use crate::error_reporting::TypeErrCtxt;
@ -686,10 +686,10 @@ fn cmp_fn_sig(
// unsafe extern "C" for<'a> fn(&'a T) -> &'a T
// ^^^^^^^^^^
if sig1.abi != abi::Abi::Rust {
if sig1.abi != ExternAbi::Rust {
values.0.push(format!("extern {} ", sig1.abi), sig1.abi != sig2.abi);
}
if sig2.abi != abi::Abi::Rust {
if sig2.abi != ExternAbi::Rust {
values.1.push(format!("extern {} ", sig2.abi), sig1.abi != sig2.abi);
}

View File

@ -6,6 +6,7 @@
use std::path::PathBuf;
use itertools::{EitherOrBoth, Itertools};
use rustc_abi::ExternAbi;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_errors::codes::*;
@ -38,7 +39,6 @@
use rustc_span::def_id::LocalDefId;
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{BytePos, DUMMY_SP, DesugaringKind, ExpnKind, MacroKind, Span};
use rustc_target::spec::abi;
use tracing::{debug, instrument};
use super::{
@ -1916,7 +1916,7 @@ pub(crate) fn build_fn_sig_ty<'tcx>(
infcx.next_ty_var(DUMMY_SP),
false,
hir::Safety::Safe,
abi::Abi::Rust,
ExternAbi::Rust,
)
}
_ => infcx.tcx.mk_fn_sig(
@ -1924,7 +1924,7 @@ pub(crate) fn build_fn_sig_ty<'tcx>(
infcx.next_ty_var(DUMMY_SP),
false,
hir::Safety::Safe,
abi::Abi::Rust,
ExternAbi::Rust,
),
};
@ -3996,7 +3996,7 @@ fn suggest_option_method_if_applicable<G: EmissionGuarantee>(
&& let [self_ty, found_ty] = trait_ref.args.as_slice()
&& let Some(fn_ty) = self_ty.as_type().filter(|ty| ty.is_fn())
&& let fn_sig @ ty::FnSig {
abi: abi::Abi::Rust,
abi: ExternAbi::Rust,
c_variadic: false,
safety: hir::Safety::Safe,
..

View File

@ -7,6 +7,7 @@
use std::iter;
use std::ops::ControlFlow;
use rustc_abi::BackendRepr;
use rustc_errors::FatalError;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
@ -18,7 +19,6 @@
};
use rustc_span::Span;
use rustc_span::symbol::Symbol;
use rustc_target::abi::BackendRepr;
use smallvec::SmallVec;
use tracing::{debug, instrument};