Skip to content

Rollup of 4 pull requests #131428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
dceb9a6
Fix methods alignment on mobile
GuillaumeGomez Oct 8, 2024
9e041fa
Add GUI regression test for methods left margin on mobile
GuillaumeGomez Oct 8, 2024
5db54be
Stabilize Pin::as_deref_mut
coolreader18 Aug 22, 2024
8da92b5
compiler: Factor rustc_target::abi::* out of middle::ty::layout
workingjubilee Oct 8, 2024
11c48be
compiler: Factor rustc_target::abi::* out of ty_utils
workingjubilee Oct 8, 2024
9d95c8b
compiler: Factor rustc_target::abi out of const_eval
workingjubilee Oct 8, 2024
ff17ce2
compiler: Factor rustc_target::abi out of hir_typeck
workingjubilee Oct 9, 2024
839cf1c
compiler: Factor rustc_target::abi out of cg_ssa
workingjubilee Oct 9, 2024
1379ef5
compiler: Factor rustc_target::abi out of cg_llvm
workingjubilee Oct 9, 2024
b3beb4e
cg_clif: Factor out rustc_target::abi
workingjubilee Oct 9, 2024
d92aee5
cg_gcc: Factor out rustc_target::abi
workingjubilee Oct 9, 2024
43e198a
compiler: Seal off the rustc_target::abi enum glob imports
workingjubilee Oct 9, 2024
af5a704
Fix quotation marks around debug line in `src/ci/run.sh`
cuviper Oct 9, 2024
b4d001e
Rollup merge of #129424 - coolreader18:stabilize-pin_as_deref_mut, r=…
workingjubilee Oct 9, 2024
fb79df5
Rollup merge of #131417 - GuillaumeGomez:mobile-methods-left-margin, …
workingjubilee Oct 9, 2024
0e7d1d0
Rollup merge of #131424 - workingjubilee:stem-the-tyde-of-glob-import…
workingjubilee Oct 9, 2024
887b73c
Rollup merge of #131426 - cuviper:ci-debug-quotes, r=jieyouxu
workingjubilee Oct 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
compiler: Factor rustc_target::abi::* out of middle::ty::layout
  • Loading branch information
workingjubilee committed Oct 9, 2024
commit 8da92b5ce24a218347b331ddfbe7d08db6aa73f3
1 change: 1 addition & 0 deletions compiler/rustc_middle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ field-offset = "0.3.5"
gsgdt = "0.1.2"
polonius-engine = "0.13.0"
rustc-rayon-core = { version = "0.5.0", optional = true }
rustc_abi = { path = "../rustc_abi" }
rustc_apfloat = "0.2.0"
rustc_arena = { path = "../rustc_arena" }
rustc_ast = { path = "../rustc_ast" }
Expand Down
24 changes: 17 additions & 7 deletions compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ use std::num::NonZero;
use std::ops::Bound;
use std::{cmp, fmt};

use rustc_abi::Primitive::{self, Float, Int, Pointer};
use rustc_abi::{
Abi, AddressSpace, Align, FieldsShape, HasDataLayout, Integer, LayoutCalculator, LayoutS,
PointeeInfo, PointerKind, ReprOptions, Scalar, Size, TagEncoding, TargetDataLayout, Variants,
};
use rustc_error_messages::DiagMessage;
use rustc_errors::{
Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level,
};
use rustc_hir as hir;
use rustc_hir::LangItem;
use rustc_hir::def_id::DefId;
use rustc_index::IndexVec;
Expand All @@ -15,10 +19,11 @@ use rustc_session::config::OptLevel;
use rustc_span::symbol::{Symbol, sym};
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span};
use rustc_target::abi::call::FnAbi;
use rustc_target::abi::*;
use rustc_target::abi::{FieldIdx, TyAbiInterface, VariantIdx, call};
use rustc_target::spec::abi::Abi as SpecAbi;
use rustc_target::spec::{HasTargetSpec, HasWasmCAbiOpt, PanicStrategy, Target, WasmCAbi};
use tracing::debug;
use {rustc_abi as abi, rustc_hir as hir};

use crate::error::UnsupportedFnAbi;
use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
Expand All @@ -27,9 +32,10 @@ use crate::ty::normalize_erasing_regions::NormalizationError;
use crate::ty::{self, CoroutineArgsExt, Ty, TyCtxt, TypeVisitableExt};

#[extension(pub trait IntegerExt)]
impl Integer {
impl abi::Integer {
#[inline]
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>, signed: bool) -> Ty<'tcx> {
use abi::Integer::{I8, I16, I32, I64, I128};
match (*self, signed) {
(I8, false) => tcx.types.u8,
(I16, false) => tcx.types.u16,
Expand All @@ -44,7 +50,8 @@ impl Integer {
}
}

fn from_int_ty<C: HasDataLayout>(cx: &C, ity: ty::IntTy) -> Integer {
fn from_int_ty<C: HasDataLayout>(cx: &C, ity: ty::IntTy) -> abi::Integer {
use abi::Integer::{I8, I16, I32, I64, I128};
match ity {
ty::IntTy::I8 => I8,
ty::IntTy::I16 => I16,
Expand All @@ -54,7 +61,8 @@ impl Integer {
ty::IntTy::Isize => cx.data_layout().ptr_sized_integer(),
}
}
fn from_uint_ty<C: HasDataLayout>(cx: &C, ity: ty::UintTy) -> Integer {
fn from_uint_ty<C: HasDataLayout>(cx: &C, ity: ty::UintTy) -> abi::Integer {
use abi::Integer::{I8, I16, I32, I64, I128};
match ity {
ty::UintTy::U8 => I8,
ty::UintTy::U16 => I16,
Expand Down Expand Up @@ -102,7 +110,7 @@ impl Integer {
tcx.data_layout().c_enum_min_size
} else {
// repr(Rust) enums try to be as small as possible
I8
Integer::I8
};

// If there are no negative values, we can use the unsigned fit.
Expand All @@ -115,9 +123,10 @@ impl Integer {
}

#[extension(pub trait FloatExt)]
impl Float {
impl abi::Float {
#[inline]
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
use abi::Float::*;
match *self {
F16 => tcx.types.f16,
F32 => tcx.types.f32,
Expand All @@ -127,6 +136,7 @@ impl Float {
}

fn from_float_ty(fty: ty::FloatTy) -> Self {
use abi::Float::*;
match fty {
ty::FloatTy::F16 => F16,
ty::FloatTy::F32 => F32,
Expand Down