Skip to content

Commit 3d9d393

Browse files
committed
Auto merge of rust-lang#3985 - rust-lang:rustup-2024-10-22, r=RalfJung
Automatic Rustup
2 parents 695a1b6 + cd8c123 commit 3d9d393

File tree

232 files changed

+2810
-3352
lines changed

Some content is hidden

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

232 files changed

+2810
-3352
lines changed

Cargo.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,7 +1907,7 @@ dependencies = [
19071907
"anyhow",
19081908
"clap",
19091909
"fs-err",
1910-
"rustc-hash 1.1.0",
1910+
"rustc-hash 2.0.0",
19111911
"rustdoc-json-types",
19121912
"serde",
19131913
"serde_json",
@@ -3514,7 +3514,7 @@ dependencies = [
35143514
"memmap2",
35153515
"parking_lot",
35163516
"portable-atomic",
3517-
"rustc-hash 1.1.0",
3517+
"rustc-hash 2.0.0",
35183518
"rustc-rayon",
35193519
"rustc-stable-hash",
35203520
"rustc_arena",
@@ -4211,7 +4211,7 @@ dependencies = [
42114211
name = "rustc_pattern_analysis"
42124212
version = "0.0.0"
42134213
dependencies = [
4214-
"rustc-hash 1.1.0",
4214+
"rustc-hash 2.0.0",
42154215
"rustc_apfloat",
42164216
"rustc_arena",
42174217
"rustc_data_structures",
@@ -4609,7 +4609,7 @@ name = "rustdoc-json-types"
46094609
version = "0.1.0"
46104610
dependencies = [
46114611
"bincode",
4612-
"rustc-hash 1.1.0",
4612+
"rustc-hash 2.0.0",
46134613
"serde",
46144614
"serde_json",
46154615
]
@@ -5239,7 +5239,7 @@ dependencies = [
52395239
"ignore",
52405240
"miropt-test-tools",
52415241
"regex",
5242-
"rustc-hash 1.1.0",
5242+
"rustc-hash 2.0.0",
52435243
"semver",
52445244
"similar",
52455245
"termcolor",

compiler/rustc_abi/src/callconv.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@ mod abi {
33
pub(crate) use crate::Variants;
44
}
55

6+
#[cfg(feature = "nightly")]
67
use rustc_macros::HashStable_Generic;
78

8-
use crate::{Abi, Align, FieldsShape, HasDataLayout, Size, TyAbiInterface, TyAndLayout};
9+
#[cfg(feature = "nightly")]
10+
use crate::{Abi, FieldsShape, TyAbiInterface, TyAndLayout};
11+
use crate::{Align, HasDataLayout, Size};
912

10-
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)]
13+
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
14+
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
1115
pub enum RegKind {
1216
Integer,
1317
Float,
1418
Vector,
1519
}
1620

17-
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)]
21+
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
22+
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
1823
pub struct Reg {
1924
pub kind: RegKind,
2025
pub size: Size,
@@ -108,15 +113,8 @@ impl HomogeneousAggregate {
108113
}
109114
}
110115

116+
#[cfg(feature = "nightly")]
111117
impl<'a, Ty> TyAndLayout<'a, Ty> {
112-
/// Returns `true` if this is an aggregate type (including a ScalarPair!)
113-
pub fn is_aggregate(&self) -> bool {
114-
match self.abi {
115-
Abi::Uninhabited | Abi::Scalar(_) | Abi::Vector { .. } => false,
116-
Abi::ScalarPair(..) | Abi::Aggregate { .. } => true,
117-
}
118-
}
119-
120118
/// Returns `Homogeneous` if this layout is an aggregate containing fields of
121119
/// only a single type (e.g., `(u32, u32)`). Such aggregates are often
122120
/// special-cased in ABIs.

compiler/rustc_abi/src/layout.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ use crate::{
1111
Variants, WrappingRange,
1212
};
1313

14+
#[cfg(feature = "nightly")]
1415
mod ty;
1516

17+
#[cfg(feature = "nightly")]
1618
pub use ty::{FIRST_VARIANT, FieldIdx, Layout, TyAbiInterface, TyAndLayout, VariantIdx};
1719

1820
// A variant is absent if it's uninhabited and only has ZST fields.

compiler/rustc_abi/src/lib.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ mod layout;
2929
mod tests;
3030

3131
pub use callconv::{Heterogeneous, HomogeneousAggregate, Reg, RegKind};
32-
pub use layout::{
33-
FIRST_VARIANT, FieldIdx, Layout, LayoutCalculator, LayoutCalculatorError, TyAbiInterface,
34-
TyAndLayout, VariantIdx,
35-
};
32+
#[cfg(feature = "nightly")]
33+
pub use layout::{FIRST_VARIANT, FieldIdx, Layout, TyAbiInterface, TyAndLayout, VariantIdx};
34+
pub use layout::{LayoutCalculator, LayoutCalculatorError};
3635

3736
/// Requirements for a `StableHashingContext` to be used in this crate.
3837
/// This is a hack to allow using the `HashStable_Generic` derive macro
3938
/// instead of implementing everything in `rustc_middle`.
39+
#[cfg(feature = "nightly")]
4040
pub trait HashStableContext {}
4141

4242
#[derive(Clone, Copy, PartialEq, Eq, Default)]
@@ -1644,6 +1644,14 @@ pub struct LayoutS<FieldIdx: Idx, VariantIdx: Idx> {
16441644
}
16451645

16461646
impl<FieldIdx: Idx, VariantIdx: Idx> LayoutS<FieldIdx, VariantIdx> {
1647+
/// Returns `true` if this is an aggregate type (including a ScalarPair!)
1648+
pub fn is_aggregate(&self) -> bool {
1649+
match self.abi {
1650+
Abi::Uninhabited | Abi::Scalar(_) | Abi::Vector { .. } => false,
1651+
Abi::ScalarPair(..) | Abi::Aggregate { .. } => true,
1652+
}
1653+
}
1654+
16471655
pub fn scalar<C: HasDataLayout>(cx: &C, scalar: Scalar) -> Self {
16481656
let largest_niche = Niche::from_scalar(cx, Size::ZERO, scalar);
16491657
let size = scalar.size(cx);

compiler/rustc_arena/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#![feature(maybe_uninit_slice)]
2424
#![feature(rustc_attrs)]
2525
#![feature(rustdoc_internals)]
26-
#![feature(strict_provenance)]
2726
#![warn(unreachable_pub)]
2827
// tidy-alphabetical-end
2928

compiler/rustc_borrowck/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ fn do_mir_borrowck<'tcx>(
187187

188188
let location_table = LocationTable::new(body);
189189

190-
let move_data = MoveData::gather_moves(body, tcx, param_env, |_| true);
190+
let move_data = MoveData::gather_moves(body, tcx, |_| true);
191191
let promoted_move_data = promoted
192192
.iter_enumerated()
193-
.map(|(idx, body)| (idx, MoveData::gather_moves(body, tcx, param_env, |_| true)));
193+
.map(|(idx, body)| (idx, MoveData::gather_moves(body, tcx, |_| true)));
194194

195195
let mut flow_inits = MaybeInitializedPlaces::new(tcx, body, &move_data)
196196
.into_engine(tcx, body)

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
11281128
}
11291129
let projected_ty = curr_projected_ty.projection_ty_core(
11301130
tcx,
1131-
self.param_env,
11321131
proj,
11331132
|this, field, ()| {
11341133
let ty = this.field_ty(tcx, field);
@@ -1919,7 +1918,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19191918
// than 1.
19201919
// If the length is larger than 1, the repeat expression will need to copy the
19211920
// element, so we require the `Copy` trait.
1922-
if len.try_eval_target_usize(tcx, self.param_env).map_or(true, |len| len > 1) {
1921+
if len.try_to_target_usize(tcx).is_none_or(|len| len > 1) {
19231922
match operand {
19241923
Operand::Copy(..) | Operand::Constant(..) => {
19251924
// These are always okay: direct use of a const, or a value that can evidently be copied.

compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
133133
.expect_const()
134134
.try_to_valtree()
135135
.expect("expected monomorphic const in codegen")
136+
.0
136137
.unwrap_branch();
137138

138139
assert_eq!(x.layout(), y.layout());
@@ -806,8 +807,10 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
806807
ty::Uint(i) if i.bit_width() == Some(expected_int_bits) => m.load_scalar(fx),
807808
ty::Array(elem, len)
808809
if matches!(elem.kind(), ty::Uint(ty::UintTy::U8))
809-
&& len.try_eval_target_usize(fx.tcx, ty::ParamEnv::reveal_all())
810-
== Some(expected_bytes) =>
810+
&& len
811+
.try_to_target_usize(fx.tcx)
812+
.expect("expected monomorphic const in codegen")
813+
== expected_bytes =>
811814
{
812815
m.force_stack(fx).0.load(
813816
fx,
@@ -907,8 +910,10 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
907910
ty::Uint(i) if i.bit_width() == Some(expected_int_bits) => {}
908911
ty::Array(elem, len)
909912
if matches!(elem.kind(), ty::Uint(ty::UintTy::U8))
910-
&& len.try_eval_target_usize(fx.tcx, ty::ParamEnv::reveal_all())
911-
== Some(expected_bytes) => {}
913+
&& len
914+
.try_to_target_usize(fx.tcx)
915+
.expect("expected monomorphic const in codegen")
916+
== expected_bytes => {}
912917
_ => {
913918
fx.tcx.dcx().span_fatal(
914919
span,

compiler/rustc_codegen_gcc/src/intrinsic/simd.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
7676
ty::Uint(i) if i.bit_width() == Some(expected_int_bits) => args[0].immediate(),
7777
ty::Array(elem, len)
7878
if matches!(*elem.kind(), ty::Uint(ty::UintTy::U8))
79-
&& len.try_eval_target_usize(bx.tcx, ty::ParamEnv::reveal_all())
80-
== Some(expected_bytes) =>
79+
&& len
80+
.try_to_target_usize(bx.tcx)
81+
.expect("expected monomorphic const in codegen")
82+
== expected_bytes =>
8183
{
8284
let place = PlaceRef::alloca(bx, args[0].layout);
8385
args[0].val.store(bx, place);
@@ -696,8 +698,10 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
696698
}
697699
ty::Array(elem, len)
698700
if matches!(*elem.kind(), ty::Uint(ty::UintTy::U8))
699-
&& len.try_eval_target_usize(bx.tcx, ty::ParamEnv::reveal_all())
700-
== Some(expected_bytes) =>
701+
&& len
702+
.try_to_target_usize(bx.tcx)
703+
.expect("expected monomorphic const in codegen")
704+
== expected_bytes =>
701705
{
702706
// Zero-extend iN to the array length:
703707
let ze = bx.zext(result, bx.type_ix(expected_bytes * 8));

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,8 +1179,10 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
11791179
ty::Uint(i) if i.bit_width() == Some(expected_int_bits) => args[0].immediate(),
11801180
ty::Array(elem, len)
11811181
if matches!(elem.kind(), ty::Uint(ty::UintTy::U8))
1182-
&& len.try_eval_target_usize(bx.tcx, ty::ParamEnv::reveal_all())
1183-
== Some(expected_bytes) =>
1182+
&& len
1183+
.try_to_target_usize(bx.tcx)
1184+
.expect("expected monomorphic const in codegen")
1185+
== expected_bytes =>
11841186
{
11851187
let place = PlaceRef::alloca(bx, args[0].layout);
11861188
args[0].val.store(bx, place);
@@ -1245,12 +1247,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
12451247
}
12461248

12471249
if name == sym::simd_shuffle_generic {
1248-
let idx = fn_args[2]
1249-
.expect_const()
1250-
.eval(tcx, ty::ParamEnv::reveal_all(), span)
1251-
.unwrap()
1252-
.1
1253-
.unwrap_branch();
1250+
let idx = fn_args[2].expect_const().try_to_valtree().unwrap().0.unwrap_branch();
12541251
let n = idx.len() as u64;
12551252

12561253
let (out_len, out_ty) = require_simd!(ret_ty, SimdReturn);
@@ -1469,8 +1466,10 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
14691466
}
14701467
ty::Array(elem, len)
14711468
if matches!(elem.kind(), ty::Uint(ty::UintTy::U8))
1472-
&& len.try_eval_target_usize(bx.tcx, ty::ParamEnv::reveal_all())
1473-
== Some(expected_bytes) =>
1469+
&& len
1470+
.try_to_target_usize(bx.tcx)
1471+
.expect("expected monomorphic const in codegen")
1472+
== expected_bytes =>
14741473
{
14751474
// Zero-extend iN to the array length:
14761475
let ze = bx.zext(i_, bx.type_ix(expected_bytes * 8));

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use rustc_middle::ty::layout::{IntegerExt, TyAndLayout};
2323
use rustc_middle::ty::{
2424
self, ExistentialProjection, GenericArgKind, GenericArgsRef, ParamEnv, Ty, TyCtxt,
2525
};
26-
use rustc_span::DUMMY_SP;
2726
use rustc_target::abi::Integer;
2827
use smallvec::SmallVec;
2928

@@ -685,21 +684,25 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S
685684
ty::ConstKind::Param(param) => {
686685
write!(output, "{}", param.name)
687686
}
688-
ty::ConstKind::Value(ty, _) => {
687+
ty::ConstKind::Value(ty, valtree) => {
689688
match ty.kind() {
690689
ty::Int(ity) => {
691690
// FIXME: directly extract the bits from a valtree instead of evaluating an
692691
// already evaluated `Const` in order to get the bits.
693-
let bits = ct.eval_bits(tcx, ty::ParamEnv::reveal_all());
692+
let bits = ct
693+
.try_to_bits(tcx, ty::ParamEnv::reveal_all())
694+
.expect("expected monomorphic const in codegen");
694695
let val = Integer::from_int_ty(&tcx, *ity).size().sign_extend(bits) as i128;
695696
write!(output, "{val}")
696697
}
697698
ty::Uint(_) => {
698-
let val = ct.eval_bits(tcx, ty::ParamEnv::reveal_all());
699+
let val = ct
700+
.try_to_bits(tcx, ty::ParamEnv::reveal_all())
701+
.expect("expected monomorphic const in codegen");
699702
write!(output, "{val}")
700703
}
701704
ty::Bool => {
702-
let val = ct.try_eval_bool(tcx, ty::ParamEnv::reveal_all()).unwrap();
705+
let val = ct.try_to_bool().expect("expected monomorphic const in codegen");
703706
write!(output, "{val}")
704707
}
705708
_ => {
@@ -711,8 +714,9 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S
711714
// avoiding collisions and will make the emitted type names shorter.
712715
let hash_short = tcx.with_stable_hashing_context(|mut hcx| {
713716
let mut hasher = StableHasher::new();
714-
let ct = ct.eval(tcx, ty::ParamEnv::reveal_all(), DUMMY_SP).unwrap();
715-
hcx.while_hashing_spans(false, |hcx| ct.hash_stable(hcx, &mut hasher));
717+
hcx.while_hashing_spans(false, |hcx| {
718+
(ty, valtree).hash_stable(hcx, &mut hasher)
719+
});
716720
hasher.finish::<Hash64>()
717721
});
718722

compiler/rustc_codegen_ssa/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#![feature(let_chains)]
1212
#![feature(negative_impls)]
1313
#![feature(rustdoc_internals)]
14-
#![feature(strict_provenance)]
1514
#![feature(trait_alias)]
1615
#![feature(try_blocks)]
1716
#![warn(unreachable_pub)]

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,16 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
361361
(Int(..) | Float(_), Int(..) | Float(_)) => bx.bitcast(imm, to_backend_ty),
362362
(Pointer(..), Pointer(..)) => bx.pointercast(imm, to_backend_ty),
363363
(Int(..), Pointer(..)) => bx.ptradd(bx.const_null(bx.type_ptr()), imm),
364-
(Pointer(..), Int(..)) => bx.ptrtoint(imm, to_backend_ty),
364+
(Pointer(..), Int(..)) => {
365+
// FIXME: this exposes the provenance, which shouldn't be necessary.
366+
bx.ptrtoint(imm, to_backend_ty)
367+
}
365368
(Float(_), Pointer(..)) => {
366369
let int_imm = bx.bitcast(imm, bx.cx().type_isize());
367370
bx.ptradd(bx.const_null(bx.type_ptr()), int_imm)
368371
}
369372
(Pointer(..), Float(_)) => {
373+
// FIXME: this exposes the provenance, which shouldn't be necessary.
370374
let int_imm = bx.ptrtoint(imm, bx.cx().type_isize());
371375
bx.bitcast(int_imm, to_backend_ty)
372376
}

0 commit comments

Comments
 (0)