Skip to content

Commit 9cb70ff

Browse files
committed
Auto merge of rust-lang#131440 - jieyouxu:rollup-9jk0hs0, r=jieyouxu
Rollup of 6 pull requests Successful merges: - rust-lang#131417 (Fix methods alignment on mobile) - rust-lang#131420 (Dont ICE when encountering post-mono layout cycle error) - rust-lang#131424 (compiler: Stop reexporting enum-globs from `rustc_target::abi`) - rust-lang#131426 (Fix quotation marks around debug line in `src/ci/run.sh`) - rust-lang#131429 (Rename directive `needs-profiler-support` to `needs-profiler-runtime`) - rust-lang#131435 (Ignore broken-pipe-no-ice on apple (specifically macOS) for now) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4203c68 + 26732ab commit 9cb70ff

File tree

54 files changed

+282
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+282
-93
lines changed

Cargo.lock

+6
Original file line numberDiff line numberDiff line change
@@ -3416,6 +3416,7 @@ dependencies = [
34163416
"measureme",
34173417
"object 0.36.4",
34183418
"rustc-demangle",
3419+
"rustc_abi",
34193420
"rustc_ast",
34203421
"rustc_attr",
34213422
"rustc_codegen_ssa",
@@ -3456,6 +3457,7 @@ dependencies = [
34563457
"object 0.36.4",
34573458
"pathdiff",
34583459
"regex",
3460+
"rustc_abi",
34593461
"rustc_arena",
34603462
"rustc_ast",
34613463
"rustc_attr",
@@ -3493,6 +3495,7 @@ name = "rustc_const_eval"
34933495
version = "0.0.0"
34943496
dependencies = [
34953497
"either",
3498+
"rustc_abi",
34963499
"rustc_apfloat",
34973500
"rustc_ast",
34983501
"rustc_attr",
@@ -3772,6 +3775,7 @@ name = "rustc_hir_typeck"
37723775
version = "0.0.0"
37733776
dependencies = [
37743777
"itertools",
3778+
"rustc_abi",
37753779
"rustc_ast",
37763780
"rustc_ast_ir",
37773781
"rustc_attr",
@@ -4027,6 +4031,7 @@ dependencies = [
40274031
"gsgdt",
40284032
"polonius-engine",
40294033
"rustc-rayon-core",
4034+
"rustc_abi",
40304035
"rustc_apfloat",
40314036
"rustc_arena",
40324037
"rustc_ast",
@@ -4522,6 +4527,7 @@ name = "rustc_ty_utils"
45224527
version = "0.0.0"
45234528
dependencies = [
45244529
"itertools",
4530+
"rustc_abi",
45254531
"rustc_ast_ir",
45264532
"rustc_data_structures",
45274533
"rustc_errors",

compiler/rustc_codegen_cranelift/src/discriminant.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
//! Adapted from <https://github.com/rust-lang/rust/blob/31c0645b9d2539f47eecb096142474b29dc542f7/compiler/rustc_codegen_ssa/src/mir/place.rs>
44
//! (<https://github.com/rust-lang/rust/pull/104535>)
55
6-
use rustc_target::abi::{Int, TagEncoding, Variants};
6+
use rustc_abi::Primitive::Int;
7+
use rustc_abi::{TagEncoding, Variants};
78

89
use crate::prelude::*;
910

compiler/rustc_codegen_cranelift/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
extern crate jobserver;
1616
#[macro_use]
1717
extern crate rustc_middle;
18+
extern crate rustc_abi;
1819
extern crate rustc_ast;
1920
extern crate rustc_codegen_ssa;
2021
extern crate rustc_data_structures;

compiler/rustc_codegen_gcc/src/builder.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use gccjit::{
77
BinaryOp, Block, ComparisonOp, Context, Function, LValue, Location, RValue, ToRValue, Type,
88
UnaryOp,
99
};
10+
use rustc_abi as abi;
11+
use rustc_abi::{Align, HasDataLayout, Size, TargetDataLayout, WrappingRange};
1012
use rustc_apfloat::{Float, Round, Status, ieee};
1113
use rustc_codegen_ssa::MemFlags;
1214
use rustc_codegen_ssa::common::{
@@ -28,7 +30,6 @@ use rustc_middle::ty::{Instance, ParamEnv, Ty, TyCtxt};
2830
use rustc_span::Span;
2931
use rustc_span::def_id::DefId;
3032
use rustc_target::abi::call::FnAbi;
31-
use rustc_target::abi::{self, Align, HasDataLayout, Size, TargetDataLayout, WrappingRange};
3233
use rustc_target::spec::{HasTargetSpec, HasWasmCAbiOpt, Target, WasmCAbi};
3334

3435
use crate::common::{SignType, TypeReflection, type_is_pointer};
@@ -998,12 +999,12 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
998999
) {
9991000
let vr = scalar.valid_range(bx);
10001001
match scalar.primitive() {
1001-
abi::Int(..) => {
1002+
abi::Primitive::Int(..) => {
10021003
if !scalar.is_always_valid(bx) {
10031004
bx.range_metadata(load, vr);
10041005
}
10051006
}
1006-
abi::Pointer(_) if vr.start < vr.end && !vr.contains(0) => {
1007+
abi::Primitive::Pointer(_) if vr.start < vr.end && !vr.contains(0) => {
10071008
bx.nonnull_metadata(load);
10081009
}
10091010
_ => {}

compiler/rustc_codegen_gcc/src/common.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
use gccjit::{LValue, RValue, ToRValue, Type};
2+
use rustc_abi as abi;
3+
use rustc_abi::HasDataLayout;
4+
use rustc_abi::Primitive::Pointer;
25
use rustc_codegen_ssa::traits::{
36
BaseTypeCodegenMethods, ConstCodegenMethods, MiscCodegenMethods, StaticCodegenMethods,
47
};
58
use rustc_middle::mir::Mutability;
69
use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};
710
use rustc_middle::ty::layout::LayoutOf;
8-
use rustc_target::abi::{self, HasDataLayout, Pointer};
911

1012
use crate::consts::const_alloc_to_gcc;
1113
use crate::context::CodegenCx;

compiler/rustc_codegen_gcc/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ extern crate tempfile;
3232
extern crate tracing;
3333

3434
// The rustc crates we need
35+
extern crate rustc_abi;
3536
extern crate rustc_apfloat;
3637
extern crate rustc_ast;
3738
extern crate rustc_attr;

compiler/rustc_codegen_gcc/src/type_of.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
use std::fmt::Write;
22

33
use gccjit::{Struct, Type};
4+
use rustc_abi as abi;
5+
use rustc_abi::Primitive::*;
6+
use rustc_abi::{Abi, FieldsShape, Integer, PointeeInfo, Size, Variants};
47
use rustc_codegen_ssa::traits::{
58
BaseTypeCodegenMethods, DerivedTypeCodegenMethods, LayoutTypeCodegenMethods,
69
};
710
use rustc_middle::bug;
811
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
912
use rustc_middle::ty::print::with_no_trimmed_paths;
1013
use rustc_middle::ty::{self, CoroutineArgsExt, Ty, TypeVisitableExt};
14+
use rustc_target::abi::TyAbiInterface;
1115
use rustc_target::abi::call::{CastTarget, FnAbi, Reg};
12-
use rustc_target::abi::{
13-
self, Abi, FieldsShape, Float, Int, Integer, PointeeInfo, Pointer, Size, TyAbiInterface,
14-
Variants,
15-
};
1616

1717
use crate::abi::{FnAbiGcc, FnAbiGccExt, GccType};
1818
use crate::context::CodegenCx;

compiler/rustc_codegen_llvm/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ libc = "0.2"
1414
measureme = "11"
1515
object = { version = "0.36.3", default-features = false, features = ["std", "read"] }
1616
rustc-demangle = "0.1.21"
17+
rustc_abi = { path = "../rustc_abi" }
1718
rustc_ast = { path = "../rustc_ast" }
1819
rustc_attr = { path = "../rustc_attr" }
1920
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }

compiler/rustc_codegen_llvm/src/abi.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use std::cmp;
22

33
use libc::c_uint;
4+
use rustc_abi as abi;
5+
use rustc_abi::Primitive::Int;
6+
use rustc_abi::{HasDataLayout, Size};
47
use rustc_codegen_ssa::MemFlags;
58
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
69
use rustc_codegen_ssa::mir::place::{PlaceRef, PlaceValue};
@@ -11,7 +14,6 @@ pub(crate) use rustc_middle::ty::layout::{WIDE_PTR_ADDR, WIDE_PTR_EXTRA};
1114
use rustc_middle::{bug, ty};
1215
use rustc_session::config;
1316
pub(crate) use rustc_target::abi::call::*;
14-
use rustc_target::abi::{self, HasDataLayout, Int, Size};
1517
use rustc_target::spec::SanitizerSet;
1618
pub(crate) use rustc_target::spec::abi::Abi;
1719
use smallvec::SmallVec;

compiler/rustc_codegen_llvm/src/builder.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use std::ops::Deref;
33
use std::{iter, ptr};
44

55
use libc::{c_char, c_uint};
6+
use rustc_abi as abi;
7+
use rustc_abi::{Align, Size, WrappingRange};
68
use rustc_codegen_ssa::MemFlags;
79
use rustc_codegen_ssa::common::{IntPredicate, RealPredicate, SynchronizationScope, TypeKind};
810
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
@@ -20,7 +22,6 @@ use rustc_sanitizers::{cfi, kcfi};
2022
use rustc_session::config::OptLevel;
2123
use rustc_span::Span;
2224
use rustc_target::abi::call::FnAbi;
23-
use rustc_target::abi::{self, Align, Size, WrappingRange};
2425
use rustc_target::spec::{HasTargetSpec, SanitizerSet, Target};
2526
use smallvec::SmallVec;
2627
use tracing::{debug, instrument};
@@ -505,12 +506,12 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
505506
}
506507

507508
match scalar.primitive() {
508-
abi::Int(..) => {
509+
abi::Primitive::Int(..) => {
509510
if !scalar.is_always_valid(bx) {
510511
bx.range_metadata(load, scalar.valid_range(bx));
511512
}
512513
}
513-
abi::Pointer(_) => {
514+
abi::Primitive::Pointer(_) => {
514515
if !scalar.valid_range(bx).contains(0) {
515516
bx.nonnull_metadata(load);
516517
}
@@ -521,7 +522,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
521522
}
522523
}
523524
}
524-
abi::Float(_) => {}
525+
abi::Primitive::Float(_) => {}
525526
}
526527
}
527528

compiler/rustc_codegen_llvm/src/common.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
//! Code that is useful in various codegen modules.
22
33
use libc::{c_char, c_uint};
4+
use rustc_abi as abi;
5+
use rustc_abi::Primitive::Pointer;
6+
use rustc_abi::{AddressSpace, HasDataLayout};
47
use rustc_ast::Mutability;
58
use rustc_codegen_ssa::traits::*;
69
use rustc_data_structures::stable_hasher::{Hash128, HashStable, StableHasher};
@@ -9,7 +12,6 @@ use rustc_middle::bug;
912
use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};
1013
use rustc_middle::ty::TyCtxt;
1114
use rustc_session::cstore::DllImport;
12-
use rustc_target::abi::{self, AddressSpace, HasDataLayout, Pointer};
1315
use tracing::debug;
1416

1517
use crate::consts::const_alloc_to_llvm;

compiler/rustc_codegen_llvm/src/context.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1187,10 +1187,11 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'_, 'tcx> {
11871187
span: Span,
11881188
fn_abi_request: FnAbiRequest<'tcx>,
11891189
) -> ! {
1190-
if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err {
1191-
self.tcx.dcx().emit_fatal(Spanned { span, node: err })
1192-
} else {
1193-
match fn_abi_request {
1190+
match err {
1191+
FnAbiError::Layout(LayoutError::SizeOverflow(_) | LayoutError::Cycle(_)) => {
1192+
self.tcx.dcx().emit_fatal(Spanned { span, node: err });
1193+
}
1194+
_ => match fn_abi_request {
11941195
FnAbiRequest::OfFnPtr { sig, extra_args } => {
11951196
span_bug!(span, "`fn_abi_of_fn_ptr({sig}, {extra_args:?})` failed: {err:?}",);
11961197
}
@@ -1200,7 +1201,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for CodegenCx<'_, 'tcx> {
12001201
"`fn_abi_of_instance({instance}, {extra_args:?})` failed: {err:?}",
12011202
);
12021203
}
1203-
}
1204+
},
12041205
}
12051206
}
12061207
}

compiler/rustc_codegen_llvm/src/type_of.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use std::fmt::Write;
22

3+
use rustc_abi::Primitive::{Float, Int, Pointer};
4+
use rustc_abi::{Abi, Align, FieldsShape, Scalar, Size, Variants};
35
use rustc_codegen_ssa::traits::*;
46
use rustc_middle::bug;
57
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
68
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
79
use rustc_middle::ty::{self, CoroutineArgsExt, Ty, TypeVisitableExt};
8-
use rustc_target::abi::{Abi, Align, FieldsShape, Float, Int, Pointer, Scalar, Size, Variants};
910
use tracing::debug;
1011

1112
use crate::common::*;

compiler/rustc_codegen_ssa/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ itertools = "0.12"
1414
jobserver = "0.1.28"
1515
pathdiff = "0.2.0"
1616
regex = "1.4"
17+
rustc_abi = { path = "../rustc_abi" }
1718
rustc_arena = { path = "../rustc_arena" }
1819
rustc_ast = { path = "../rustc_ast" }
1920
rustc_attr = { path = "../rustc_attr" }

compiler/rustc_codegen_ssa/src/mir/operand.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ use std::fmt;
33

44
use arrayvec::ArrayVec;
55
use either::Either;
6+
use rustc_abi as abi;
7+
use rustc_abi::{Abi, Align, Size};
68
use rustc_middle::bug;
79
use rustc_middle::mir::interpret::{Pointer, Scalar, alloc_range};
810
use rustc_middle::mir::{self, ConstValue};
911
use rustc_middle::ty::Ty;
1012
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
11-
use rustc_target::abi::{self, Abi, Align, Size};
1213
use tracing::debug;
1314

1415
use super::place::{PlaceRef, PlaceValue};
@@ -207,7 +208,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
207208
match alloc.0.read_scalar(
208209
bx,
209210
alloc_range(start, size),
210-
/*read_provenance*/ matches!(s.primitive(), abi::Pointer(_)),
211+
/*read_provenance*/ matches!(s.primitive(), abi::Primitive::Pointer(_)),
211212
) {
212213
Ok(val) => bx.scalar_to_backend(val, s, ty),
213214
Err(_) => bx.const_poison(ty),

compiler/rustc_codegen_ssa/src/mir/place.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
use rustc_abi::Primitive::{Int, Pointer};
2+
use rustc_abi::{Align, FieldsShape, Size, TagEncoding, Variants};
13
use rustc_middle::mir::tcx::PlaceTy;
24
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
35
use rustc_middle::ty::{self, Ty};
46
use rustc_middle::{bug, mir};
5-
use rustc_target::abi::{
6-
Align, FieldsShape, Int, Pointer, Size, TagEncoding, VariantIdx, Variants,
7-
};
7+
use rustc_target::abi::VariantIdx;
88
use tracing::{debug, instrument};
99

1010
use super::operand::OperandValue;

compiler/rustc_const_eval/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ edition = "2021"
66
[dependencies]
77
# tidy-alphabetical-start
88
either = "1"
9+
rustc_abi = { path = "../rustc_abi" }
910
rustc_apfloat = "0.2.0"
1011
rustc_ast = { path = "../rustc_ast" }
1112
rustc_attr = { path = "../rustc_attr" }

compiler/rustc_const_eval/src/interpret/operand.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
use std::assert_matches::assert_matches;
55

66
use either::{Either, Left, Right};
7+
use rustc_abi as abi;
8+
use rustc_abi::{Abi, HasDataLayout, Size};
79
use rustc_hir::def::Namespace;
810
use rustc_middle::mir::interpret::ScalarSizeMismatch;
911
use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt, LayoutOf, TyAndLayout};
1012
use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter};
1113
use rustc_middle::ty::{ConstInt, ScalarInt, Ty, TyCtxt};
1214
use rustc_middle::{bug, mir, span_bug, ty};
13-
use rustc_target::abi::{self, Abi, HasDataLayout, Size};
1415
use tracing::trace;
1516

1617
use super::{
@@ -117,7 +118,7 @@ impl<Prov: Provenance> Immediate<Prov> {
117118
match (self, abi) {
118119
(Immediate::Scalar(scalar), Abi::Scalar(s)) => {
119120
assert_eq!(scalar.size(), s.size(cx), "{msg}: scalar value has wrong size");
120-
if !matches!(s.primitive(), abi::Pointer(..)) {
121+
if !matches!(s.primitive(), abi::Primitive::Pointer(..)) {
121122
// This is not a pointer, it should not carry provenance.
122123
assert!(
123124
matches!(scalar, Scalar::Int(..)),
@@ -131,7 +132,7 @@ impl<Prov: Provenance> Immediate<Prov> {
131132
a.size(cx),
132133
"{msg}: first component of scalar pair has wrong size"
133134
);
134-
if !matches!(a.primitive(), abi::Pointer(..)) {
135+
if !matches!(a.primitive(), abi::Primitive::Pointer(..)) {
135136
assert!(
136137
matches!(a_val, Scalar::Int(..)),
137138
"{msg}: first component of scalar pair should be an integer, but has provenance"
@@ -142,7 +143,7 @@ impl<Prov: Provenance> Immediate<Prov> {
142143
b.size(cx),
143144
"{msg}: second component of scalar pair has wrong size"
144145
);
145-
if !matches!(b.primitive(), abi::Pointer(..)) {
146+
if !matches!(b.primitive(), abi::Primitive::Pointer(..)) {
146147
assert!(
147148
matches!(b_val, Scalar::Int(..)),
148149
"{msg}: second component of scalar pair should be an integer, but has provenance"
@@ -572,7 +573,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
572573
assert_eq!(size, mplace.layout.size, "abi::Scalar size does not match layout size");
573574
let scalar = alloc.read_scalar(
574575
alloc_range(Size::ZERO, size),
575-
/*read_provenance*/ matches!(s, abi::Pointer(_)),
576+
/*read_provenance*/ matches!(s, abi::Primitive::Pointer(_)),
576577
)?;
577578
Some(ImmTy::from_scalar(scalar, mplace.layout))
578579
}
@@ -588,11 +589,11 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
588589
assert!(b_offset.bytes() > 0); // in `operand_field` we use the offset to tell apart the fields
589590
let a_val = alloc.read_scalar(
590591
alloc_range(Size::ZERO, a_size),
591-
/*read_provenance*/ matches!(a, abi::Pointer(_)),
592+
/*read_provenance*/ matches!(a, abi::Primitive::Pointer(_)),
592593
)?;
593594
let b_val = alloc.read_scalar(
594595
alloc_range(b_offset, b_size),
595-
/*read_provenance*/ matches!(b, abi::Pointer(_)),
596+
/*read_provenance*/ matches!(b, abi::Primitive::Pointer(_)),
596597
)?;
597598
Some(ImmTy::from_immediate(Immediate::ScalarPair(a_val, b_val), mplace.layout))
598599
}

compiler/rustc_hir_typeck/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ edition = "2021"
66
[dependencies]
77
# tidy-alphabetical-start
88
itertools = "0.12"
9+
rustc_abi = { path = "../rustc_abi" }
910
rustc_ast = { path = "../rustc_ast" }
1011
rustc_ast_ir = { path = "../rustc_ast_ir" }
1112
rustc_attr = { path = "../rustc_attr" }

0 commit comments

Comments
 (0)