Skip to content

Commit b5b1356

Browse files
committed
Auto merge of #126240 - matthiaskrgr:rollup-ks4o2n9, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #126063 (Remove some unused crate dependencies.) - #126115 (Fix ICE due to `unwrap` in `probe_for_name_many`) - #126159 (ScalarInt: size mismatches are a bug, do not delay the panic) - #126184 (interpret: do not ICE on padded non-pow2 SIMD vectors) - #126191 (Fix `NonZero` doctest inconsistencies) - #126211 (migrate tests/run-make/llvm-outputs to use rmake.rs) - #126212 (fix: build on haiku) - #126215 (Add explanatory note to async block type mismatch error) - #126223 (run-make: add `run_in_tmpdir` self-test) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d402830 + d762ef1 commit b5b1356

File tree

74 files changed

+448
-379
lines changed

Some content is hidden

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

74 files changed

+448
-379
lines changed

Cargo.lock

-19
Original file line numberDiff line numberDiff line change
@@ -3627,7 +3627,6 @@ dependencies = [
36273627
"rustc_macros",
36283628
"rustc_serialize",
36293629
"rustc_span",
3630-
"smallvec",
36313630
]
36323631

36333632
[[package]]
@@ -3708,7 +3707,6 @@ dependencies = [
37083707
"icu_locid",
37093708
"icu_locid_transform",
37103709
"icu_provider",
3711-
"icu_provider_adapters",
37123710
"zerovec",
37133711
]
37143712

@@ -3889,7 +3887,6 @@ dependencies = [
38893887
"portable-atomic",
38903888
"rustc-hash",
38913889
"rustc-rayon",
3892-
"rustc-rayon-core",
38933890
"rustc_arena",
38943891
"rustc_graphviz",
38953892
"rustc_index",
@@ -3930,7 +3927,6 @@ dependencies = [
39303927
"rustc_expand",
39313928
"rustc_feature",
39323929
"rustc_fluent_macro",
3933-
"rustc_hir",
39343930
"rustc_hir_analysis",
39353931
"rustc_hir_pretty",
39363932
"rustc_hir_typeck",
@@ -4193,7 +4189,6 @@ dependencies = [
41934189
"proc-macro2",
41944190
"quote",
41954191
"syn 2.0.66",
4196-
"synstructure",
41974192
]
41984193

41994194
[[package]]
@@ -4385,7 +4380,6 @@ dependencies = [
43854380
"field-offset",
43864381
"gsgdt",
43874382
"polonius-engine",
4388-
"rustc-rayon",
43894383
"rustc-rayon-core",
43904384
"rustc_apfloat",
43914385
"rustc_arena",
@@ -4417,7 +4411,6 @@ dependencies = [
44174411
name = "rustc_mir_build"
44184412
version = "0.0.0"
44194413
dependencies = [
4420-
"either",
44214414
"itertools 0.12.1",
44224415
"rustc_apfloat",
44234416
"rustc_arena",
@@ -4436,7 +4429,6 @@ dependencies = [
44364429
"rustc_span",
44374430
"rustc_target",
44384431
"rustc_trait_selection",
4439-
"smallvec",
44404432
"tracing",
44414433
]
44424434

@@ -4511,14 +4503,7 @@ dependencies = [
45114503
name = "rustc_next_trait_solver"
45124504
version = "0.0.0"
45134505
dependencies = [
4514-
"derivative",
4515-
"rustc_ast_ir",
4516-
"rustc_data_structures",
4517-
"rustc_macros",
4518-
"rustc_serialize",
45194506
"rustc_type_ir",
4520-
"rustc_type_ir_macros",
4521-
"tracing",
45224507
]
45234508

45244509
[[package]]
@@ -4623,7 +4608,6 @@ version = "0.0.0"
46234608
dependencies = [
46244609
"field-offset",
46254610
"measureme",
4626-
"rustc-rayon-core",
46274611
"rustc_data_structures",
46284612
"rustc_errors",
46294613
"rustc_hir",
@@ -5329,7 +5313,6 @@ name = "stable_mir"
53295313
version = "0.1.0-preview"
53305314
dependencies = [
53315315
"scoped-tls",
5332-
"tracing",
53335316
]
53345317

53355318
[[package]]
@@ -5625,8 +5608,6 @@ dependencies = [
56255608
"core",
56265609
"getopts",
56275610
"libc",
5628-
"panic_abort",
5629-
"panic_unwind",
56305611
"std",
56315612
]
56325613

compiler/rustc_ast_ir/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ rustc_data_structures = { path = "../rustc_data_structures", optional = true }
99
rustc_macros = { path = "../rustc_macros", optional = true }
1010
rustc_serialize = { path = "../rustc_serialize", optional = true }
1111
rustc_span = { path = "../rustc_span", optional = true }
12-
smallvec = { version = "1.8.1" }
1312
# tidy-alphabetical-end
1413

1514
[features]

compiler/rustc_baked_icu_data/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ icu_list = "1.2"
99
icu_locid = "1.2"
1010
icu_locid_transform = "1.3.2"
1111
icu_provider = "1.2"
12-
icu_provider_adapters = "1.2"
1312
zerovec = "0.10.0"
1413
# tidy-alphabetical-end
1514

compiler/rustc_codegen_cranelift/src/constant.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub(crate) fn codegen_const_value<'tcx>(
110110
if fx.clif_type(layout.ty).is_some() {
111111
return CValue::const_val(fx, layout, int);
112112
} else {
113-
let raw_val = int.size().truncate(int.assert_bits(int.size()));
113+
let raw_val = int.size().truncate(int.to_bits(int.size()));
114114
let val = match int.size().bytes() {
115115
1 => fx.bcx.ins().iconst(types::I8, raw_val as i64),
116116
2 => fx.bcx.ins().iconst(types::I16, raw_val as i64),
@@ -501,12 +501,12 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
501501
Ordering::Equal => scalar_int,
502502
Ordering::Less => match ty.kind() {
503503
ty::Uint(_) => ScalarInt::try_from_uint(
504-
scalar_int.assert_uint(scalar_int.size()),
504+
scalar_int.to_uint(scalar_int.size()),
505505
fx.layout_of(*ty).size,
506506
)
507507
.unwrap(),
508508
ty::Int(_) => ScalarInt::try_from_int(
509-
scalar_int.assert_int(scalar_int.size()),
509+
scalar_int.to_int(scalar_int.size()),
510510
fx.layout_of(*ty).size,
511511
)
512512
.unwrap(),

compiler/rustc_codegen_cranelift/src/intrinsics/llvm_x86.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
902902
.span_fatal(span, "Index argument for `_mm_cmpestri` is not a constant");
903903
};
904904

905-
let imm8 = imm8.try_to_u8().unwrap_or_else(|_| panic!("kind not scalar: {:?}", imm8));
905+
let imm8 = imm8.to_u8();
906906

907907
codegen_inline_asm_inner(
908908
fx,
@@ -955,7 +955,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
955955
.span_fatal(span, "Index argument for `_mm_cmpestrm` is not a constant");
956956
};
957957

958-
let imm8 = imm8.try_to_u8().unwrap_or_else(|_| panic!("kind not scalar: {:?}", imm8));
958+
let imm8 = imm8.to_u8();
959959

960960
codegen_inline_asm_inner(
961961
fx,
@@ -1003,7 +1003,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
10031003
);
10041004
};
10051005

1006-
let imm8 = imm8.try_to_u8().unwrap_or_else(|_| panic!("kind not scalar: {:?}", imm8));
1006+
let imm8 = imm8.to_u8();
10071007

10081008
codegen_inline_asm_inner(
10091009
fx,
@@ -1040,7 +1040,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
10401040
);
10411041
};
10421042

1043-
let imm8 = imm8.try_to_u8().unwrap_or_else(|_| panic!("kind not scalar: {:?}", imm8));
1043+
let imm8 = imm8.to_u8();
10441044

10451045
codegen_inline_asm_inner(
10461046
fx,
@@ -1195,7 +1195,7 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
11951195
.span_fatal(span, "Func argument for `_mm_sha1rnds4_epu32` is not a constant");
11961196
};
11971197

1198-
let func = func.try_to_u8().unwrap_or_else(|_| panic!("kind not scalar: {:?}", func));
1198+
let func = func.to_u8();
11991199

12001200
codegen_inline_asm_inner(
12011201
fx,

compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
147147

148148
let total_len = lane_count * 2;
149149

150-
let indexes =
151-
idx.iter().map(|idx| idx.unwrap_leaf().try_to_u32().unwrap()).collect::<Vec<u32>>();
150+
let indexes = idx.iter().map(|idx| idx.unwrap_leaf().to_u32()).collect::<Vec<u32>>();
152151

153152
for &idx in &indexes {
154153
assert!(u64::from(idx) < total_len, "idx {} out of range 0..{}", idx, total_len);
@@ -282,9 +281,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
282281
fx.tcx.dcx().span_fatal(span, "Index argument for `simd_insert` is not a constant");
283282
};
284283

285-
let idx: u32 = idx_const
286-
.try_to_u32()
287-
.unwrap_or_else(|_| panic!("kind not scalar: {:?}", idx_const));
284+
let idx: u32 = idx_const.to_u32();
288285
let (lane_count, _lane_ty) = base.layout().ty.simd_size_and_type(fx.tcx);
289286
if u64::from(idx) >= lane_count {
290287
fx.tcx.dcx().span_fatal(
@@ -330,9 +327,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
330327
return;
331328
};
332329

333-
let idx = idx_const
334-
.try_to_u32()
335-
.unwrap_or_else(|_| panic!("kind not scalar: {:?}", idx_const));
330+
let idx = idx_const.to_u32();
336331
let (lane_count, _lane_ty) = v.layout().ty.simd_size_and_type(fx.tcx);
337332
if u64::from(idx) >= lane_count {
338333
fx.tcx.dcx().span_fatal(

compiler/rustc_codegen_cranelift/src/value_and_place.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ impl<'tcx> CValue<'tcx> {
327327

328328
let val = match layout.ty.kind() {
329329
ty::Uint(UintTy::U128) | ty::Int(IntTy::I128) => {
330-
let const_val = const_val.assert_bits(layout.size);
330+
let const_val = const_val.to_bits(layout.size);
331331
let lsb = fx.bcx.ins().iconst(types::I64, const_val as u64 as i64);
332332
let msb = fx.bcx.ins().iconst(types::I64, (const_val >> 64) as u64 as i64);
333333
fx.bcx.ins().iconcat(lsb, msb)
@@ -339,7 +339,7 @@ impl<'tcx> CValue<'tcx> {
339339
| ty::Ref(..)
340340
| ty::RawPtr(..)
341341
| ty::FnPtr(..) => {
342-
let raw_val = const_val.size().truncate(const_val.assert_bits(layout.size));
342+
let raw_val = const_val.size().truncate(const_val.to_bits(layout.size));
343343
fx.bcx.ins().iconst(clif_ty, raw_val as i64)
344344
}
345345
ty::Float(FloatTy::F32) => {

compiler/rustc_codegen_gcc/src/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
166166
let bitsize = if layout.is_bool() { 1 } else { layout.size(self).bits() };
167167
match cv {
168168
Scalar::Int(int) => {
169-
let data = int.assert_bits(layout.size(self));
169+
let data = int.to_bits(layout.size(self));
170170

171171
// FIXME(antoyo): there's some issues with using the u128 code that follows, so hard-code
172172
// the paths for floating-point values.

compiler/rustc_codegen_llvm/src/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
244244
let bitsize = if layout.is_bool() { 1 } else { layout.size(self).bits() };
245245
match cv {
246246
Scalar::Int(int) => {
247-
let data = int.assert_bits(layout.size(self));
247+
let data = int.to_bits(layout.size(self));
248248
let llval = self.const_uint_big(self.type_ix(bitsize), data);
249249
if matches!(layout.primitive(), Pointer(_)) {
250250
unsafe { llvm::LLVMConstIntToPtr(llval, llty) }

compiler/rustc_codegen_llvm/src/intrinsic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
12231223
.iter()
12241224
.enumerate()
12251225
.map(|(arg_idx, val)| {
1226-
let idx = val.unwrap_leaf().try_to_i32().unwrap();
1226+
let idx = val.unwrap_leaf().to_i32();
12271227
if idx >= i32::try_from(total_len).unwrap() {
12281228
bx.sess().dcx().emit_err(InvalidMonomorphization::SimdIndexOutOfBounds {
12291229
span,

compiler/rustc_codegen_ssa/src/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ pub fn asm_const_to_str<'tcx>(
163163
let mir::ConstValue::Scalar(scalar) = const_value else {
164164
span_bug!(sp, "expected Scalar for promoted asm const, but got {:#?}", const_value)
165165
};
166-
let value = scalar.assert_bits(ty_and_layout.size);
166+
let value = scalar.assert_scalar_int().to_bits(ty_and_layout.size);
167167
match ty_and_layout.ty.kind() {
168168
ty::Uint(_) => value.to_string(),
169169
ty::Int(int_ty) => match int_ty.normalize(tcx.sess.target.pointer_width) {

compiler/rustc_const_eval/src/const_eval/valtrees.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ fn const_to_valtree_inner<'tcx>(
9595
}
9696
ty::Bool | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Char => {
9797
let val = ecx.read_immediate(place)?;
98-
let val = val.to_scalar();
98+
let val = val.to_scalar_int().unwrap();
9999
*num_nodes += 1;
100100

101-
Ok(ty::ValTree::Leaf(val.assert_int()))
101+
Ok(ty::ValTree::Leaf(val))
102102
}
103103

104104
ty::Pat(base, ..) => {
@@ -125,7 +125,7 @@ fn const_to_valtree_inner<'tcx>(
125125
let val = val.to_scalar();
126126
// We are in the CTFE machine, so ptr-to-int casts will fail.
127127
// This can only be `Ok` if `val` already is an integer.
128-
let Ok(val) = val.try_to_int() else {
128+
let Ok(val) = val.try_to_scalar_int() else {
129129
return Err(ValTreeCreationError::NonSupportedType);
130130
};
131131
// It's just a ScalarInt!
@@ -411,7 +411,7 @@ fn valtree_into_mplace<'tcx>(
411411
ty::Adt(def, _) if def.is_enum() => {
412412
// First element of valtree corresponds to variant
413413
let scalar_int = branches[0].unwrap_leaf();
414-
let variant_idx = VariantIdx::from_u32(scalar_int.try_to_u32().unwrap());
414+
let variant_idx = VariantIdx::from_u32(scalar_int.to_u32());
415415
let variant = def.variant(variant_idx);
416416
debug!(?variant);
417417

compiler/rustc_const_eval/src/interpret/discriminant.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,14 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
123123
// (`tag_bits` itself is only used for error messages below.)
124124
let tag_bits = tag_val
125125
.to_scalar()
126-
.try_to_int()
126+
.try_to_scalar_int()
127127
.map_err(|dbg_val| err_ub!(InvalidTag(dbg_val)))?
128-
.assert_bits(tag_layout.size);
128+
.to_bits(tag_layout.size);
129129
// Cast bits from tag layout to discriminant layout.
130130
// After the checks we did above, this cannot fail, as
131131
// discriminants are int-like.
132132
let discr_val = self.int_to_int_or_float(&tag_val, discr_layout).unwrap();
133-
let discr_bits = discr_val.to_scalar().assert_bits(discr_layout.size);
133+
let discr_bits = discr_val.to_scalar().to_bits(discr_layout.size)?;
134134
// Convert discriminant to variant index, and catch invalid discriminants.
135135
let index = match *ty.kind() {
136136
ty::Adt(adt, _) => {
@@ -152,7 +152,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
152152
// discriminant (encoded in niche/tag) and variant index are the same.
153153
let variants_start = niche_variants.start().as_u32();
154154
let variants_end = niche_variants.end().as_u32();
155-
let variant = match tag_val.try_to_int() {
155+
let variant = match tag_val.try_to_scalar_int() {
156156
Err(dbg_val) => {
157157
// So this is a pointer then, and casting to an int failed.
158158
// Can only happen during CTFE.
@@ -167,15 +167,15 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
167167
untagged_variant
168168
}
169169
Ok(tag_bits) => {
170-
let tag_bits = tag_bits.assert_bits(tag_layout.size);
170+
let tag_bits = tag_bits.to_bits(tag_layout.size);
171171
// We need to use machine arithmetic to get the relative variant idx:
172172
// variant_index_relative = tag_val - niche_start_val
173173
let tag_val = ImmTy::from_uint(tag_bits, tag_layout);
174174
let niche_start_val = ImmTy::from_uint(niche_start, tag_layout);
175175
let variant_index_relative_val =
176176
self.binary_op(mir::BinOp::Sub, &tag_val, &niche_start_val)?;
177177
let variant_index_relative =
178-
variant_index_relative_val.to_scalar().assert_bits(tag_val.layout.size);
178+
variant_index_relative_val.to_scalar().to_bits(tag_val.layout.size)?;
179179
// Check if this is in the range that indicates an actual discriminant.
180180
if variant_index_relative <= u128::from(variants_end - variants_start) {
181181
let variant_index_relative = u32::try_from(variant_index_relative)
@@ -294,8 +294,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
294294
ImmTy::from_uint(variant_index_relative, tag_layout);
295295
let tag = self
296296
.binary_op(mir::BinOp::Add, &variant_index_relative_val, &niche_start_val)?
297-
.to_scalar()
298-
.assert_int();
297+
.to_scalar_int()?;
299298
Ok(Some((tag, tag_field)))
300299
}
301300
}

compiler/rustc_const_eval/src/interpret/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
519519
// `x % y != 0` or `y == 0` or `x == T::MIN && y == -1`.
520520
// First, check x % y != 0 (or if that computation overflows).
521521
let rem = self.binary_op(BinOp::Rem, a, b)?;
522-
if rem.to_scalar().assert_bits(a.layout.size) != 0 {
522+
if rem.to_scalar().to_bits(a.layout.size)? != 0 {
523523
throw_ub_custom!(
524524
fluent::const_eval_exact_div_has_remainder,
525525
a = format!("{a}"),

compiler/rustc_const_eval/src/interpret/memory.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
13441344
/// Test if this value might be null.
13451345
/// If the machine does not support ptr-to-int casts, this is conservative.
13461346
pub fn scalar_may_be_null(&self, scalar: Scalar<M::Provenance>) -> InterpResult<'tcx, bool> {
1347-
Ok(match scalar.try_to_int() {
1347+
Ok(match scalar.try_to_scalar_int() {
13481348
Ok(int) => int.is_null(),
13491349
Err(_) => {
13501350
// Can only happen during CTFE.

0 commit comments

Comments
 (0)