Skip to content

Commit 922325b

Browse files
committed
Auto merge of #160238 - JonathanBrouwer:rollup-6GZndbU, r=JonathanBrouwer
Rollup of 25 pull requests Successful merges: - #160204 (Sync from portable simd 2026 07 30) - #138230 (Add `raw_borrows_via_references` lint) - #158057 (Don't escape U+FF9E and U+FF9F in `escape_debug_ext`) - #160015 (refactor(mir-transform): Merge `can_be_overridden`, `is_required` and `is_enabled` into one) - #160031 (std: make positioned I/O unsupported on VxWorks) - #160125 (Fix typing mode handling in transmute checks and rustc_dump_layout) - #160152 (Create on-demand CI job for testing EC2 instances) - #160232 (rustdoc: fix ICE when a grapheme cluster joins a Prepend-class character to `_` or `:`) - #159214 (std: improve the documentation of the random feature) - #159818 (Resolve vars before calling `unnormalized_obligations`) - #159955 (Stop using higher-order macros to declare arenas) - #159958 (Fix avoid cycle for self referential return type notation) - #160040 (Split function parsing out of `item.rs` to a new module.) - #160044 (Add regression tests for fixed dead-code issues) - #160144 (renovate: group lockfiles PRs) - #160149 (Fix Windows on Arm PAC default) - #160164 (Derive `GenericTypeVisitable` for `RegionConstraint`) - #160175 (Try to recover less from incorrectly parsed const arg) - #160177 (A few more "predicate"-to-"clause" renamings) - #160181 (Mark `Tuple` and `FnPtr` traits `#[fundamental]`) - #160192 (Fix ICE for parsing issue with a closing brace) - #160209 (bootstrap: Remove method `Subcommand::kind`) - #160221 (Remove `Copy` supertrait from `VaList`) - #160223 (interpret: rename validate_operand → validate_place) - #160234 (Always use short ty path for call with missing arguments suggestion)
2 parents 8ab9fdf + 21f8e37 commit 922325b

167 files changed

Lines changed: 2867 additions & 1898 deletions

File tree

Some content is hidden

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

‎.github/renovate.json5‎

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,40 @@
3131
"dependencyDashboardApproval": false
3232
},
3333
{
34-
// Only maintain the Cargo lockfiles managed by update-lockfile.sh.
34+
// Update all Cargo.lock files except library/Cargo.lock in one PR.
3535
"matchManagers": ["cargo"],
3636
"matchUpdateTypes": ["lockFileMaintenance"],
37-
"enabled": false
37+
"groupName": "Cargo lock file maintenance",
38+
"commitMessageAction": "Cargo lock file maintenance"
39+
},
40+
{
41+
// Update library/Cargo.lock in a dedicated PR.
42+
"matchManagers": ["cargo"],
43+
"matchUpdateTypes": ["lockFileMaintenance"],
44+
"matchFileNames": ["library/Cargo.lock"],
45+
"groupName": "library lock file maintenance",
46+
"commitMessageAction": "Library lock file maintenance"
3847
},
3948
{
49+
// These packages don't have a committed Cargo.lock file.
4050
"matchManagers": ["cargo"],
4151
"matchUpdateTypes": ["lockFileMaintenance"],
4252
"matchFileNames": [
43-
"Cargo.toml",
44-
"library/Cargo.toml",
45-
"src/tools/rustbook/Cargo.toml"
53+
"library/rustc-std-workspace-*/Cargo.toml",
4654
],
47-
"enabled": true
55+
"enabled": false
56+
},
57+
{
58+
// Update yarn.lock in a dedicated PR.
59+
"matchManagers": ["npm"],
60+
"matchUpdateTypes": ["lockFileMaintenance"],
61+
"groupName": "Yarn lock file maintenance",
62+
"commitMessageAction": "Yarn lock file maintenance"
4863
}
4964
],
50-
// Don't manage dependencies inside subtrees. They are updated upstream and
51-
// synced in. See `src/doc/rustc-dev-guide/src/external-repos.md` for the list.
5265
"ignorePaths": [
66+
// Don't manage dependencies inside subtrees. They are updated upstream and
67+
// synced in. See `src/doc/rustc-dev-guide/src/external-repos.md` for the list.
5368
"compiler/rustc_codegen_cranelift/**",
5469
"compiler/rustc_codegen_gcc/**",
5570
"library/compiler-builtins/**",
@@ -59,6 +74,10 @@
5974
"src/tools/clippy/**",
6075
"src/tools/miri/**",
6176
"src/tools/rust-analyzer/**",
62-
"src/tools/rustfmt/**"
77+
"src/tools/rustfmt/**",
78+
79+
// Test manifests are fixtures; their versions and lockfiles may
80+
// intentionally be part of the test input.
81+
"tests/**",
6382
]
6483
}

‎compiler/rustc_arena/src/lib.rs‎

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -598,21 +598,32 @@ impl DroplessArena {
598598
}
599599
}
600600

601-
/// Declare an `Arena` containing one dropless arena and many typed arenas (the
602-
/// types of the typed arenas are specified by the arguments).
601+
/// Declares an `Arena` that can allocate values of a variety of `Copy`, `needs_drop` and
602+
/// `!needs_drop` types.
603603
///
604-
/// There are three cases of interest.
605-
/// - Types that are `Copy`: these need not be specified in the arguments. They
606-
/// will use the `DroplessArena`.
607-
/// - Types that are `!Copy` and `!Drop`: these must be specified in the
608-
/// arguments. An empty `TypedArena` will be created for each one, but the
609-
/// `DroplessArena` will always be used and the `TypedArena` will stay empty.
610-
/// This is odd but harmless, because an empty arena allocates no memory.
611-
/// - Types that are `!Copy` and `Drop`: these must be specified in the
612-
/// arguments. The `TypedArena` will be used for them.
604+
/// The declared arena actually contains a single [`DroplessArena`], plus a separate
605+
/// [`TypedArena`] for each of the types listed in the body of the macro invocation.
613606
///
607+
/// Any type that is `Copy` can be allocated in the arena without needing to be listed
608+
/// explicitly. Those values will be stored in the [`DroplessArena`].
609+
///
610+
/// Types that are `!Copy` can only be allocated if they are listed in the macro invocation.
611+
/// For types that are `!Copy + needs_drop`, values will be stored in the corresponding
612+
/// [`TypedArena`] and will be dropped when the arena is dropped.
613+
///
614+
/// As an optimization, types that are `!Copy + !needs_drop` will actually be stored in the
615+
/// [`DroplessArena`], and the corresponding [`TypedArena`] will remain empty. This makes
616+
/// better use of the dropless arena's storage blocks, while the overhead of having a few
617+
/// unused typed-arenas is negligible.
614618
#[rustc_macro_transparency = "semiopaque"]
615-
pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*]) {
619+
pub macro declare_arena(
620+
// Each of these entries becomes a `$name: TypedArena<$ty>` field in the arena.
621+
// This allows values of non-copy type $ty to be allocated in the arena.
622+
// The field names must be distinct, but have no further significance.
623+
$(
624+
$name:ident: $ty:ty,
625+
)*
626+
) {
616627
#[derive(Default)]
617628
pub struct Arena<'tcx> {
618629
pub dropless: $crate::DroplessArena,

‎compiler/rustc_codegen_llvm/src/attributes.rs‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,7 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
530530
to_add.extend(sanitize_attrs(cx, tcx, codegen_fn_attrs.sanitizers));
531531

532532
// For non-naked functions, set branch protection attributes on aarch64.
533-
if let Some(BranchProtection { bti, pac_ret, gcs }) =
534-
sess.opts.unstable_opts.branch_protection
535-
{
533+
if let Some(BranchProtection { bti, pac_ret, gcs }) = sess.branch_protection() {
536534
assert!(sess.target.arch == Arch::AArch64);
537535
if bti {
538536
to_add.push(llvm::CreateAttrString(cx.llcx, "branch-target-enforcement"));

‎compiler/rustc_codegen_llvm/src/context.rs‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,7 @@ pub(crate) unsafe fn create_module<'ll>(
405405
);
406406
}
407407

408-
if let Some(BranchProtection { bti, pac_ret, gcs }) = sess.opts.unstable_opts.branch_protection
409-
{
408+
if let Some(BranchProtection { bti, pac_ret, gcs }) = sess.branch_protection() {
410409
if sess.target.arch == Arch::AArch64 {
411410
llvm::add_module_flag_u32(
412411
llmod,
@@ -420,7 +419,11 @@ pub(crate) unsafe fn create_module<'ll>(
420419
"sign-return-address",
421420
pac_ret.is_some().into(),
422421
);
423-
let pac_opts = pac_ret.unwrap_or(PacRet { leaf: false, pc: false, key: PAuthKey::A });
422+
let pac_opts = pac_ret.unwrap_or_else(|| {
423+
// Windows on Arm only supports PAC key B.
424+
let key = if sess.target.os == Os::Windows { PAuthKey::B } else { PAuthKey::A };
425+
PacRet { leaf: false, pc: false, key }
426+
});
424427
llvm::add_module_flag_u32(
425428
llmod,
426429
llvm::ModuleFlagMergeBehavior::Min,

‎compiler/rustc_const_eval/src/const_eval/eval_queries.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ fn const_validate_mplace<'tcx>(
484484
CtfeValidationMode::Const { allow_immutable_unsafe_cell: !inner }
485485
}
486486
};
487-
ecx.const_validate_operand(&mplace.into(), path, &mut ref_tracking, mode)
487+
ecx.const_validate_place(&mplace.into(), path, &mut ref_tracking, mode)
488488
.report_err()
489489
// Instead of just reporting the `InterpError` via the usual machinery, we give a more targeted
490490
// error about the validation failure.

‎compiler/rustc_const_eval/src/interpret/intrinsics.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
11171117
// ourselves. This value is now in `left.` The one that started out in `left` already got
11181118
// validated by the copy above.
11191119
if M::enforce_validity(self, left.layout) {
1120-
self.validate_operand(
1120+
self.validate_place(
11211121
&left.clone().into(),
11221122
M::enforce_validity_recursively(self, left.layout),
11231123
/*reset_provenance_and_padding*/ true,

‎compiler/rustc_const_eval/src/interpret/place.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ where
626626
if M::enforce_validity(self, dest.layout()) {
627627
// Data got changed, better make sure it matches the type!
628628
// Also needed to reset padding.
629-
self.validate_operand(
629+
self.validate_place(
630630
&dest.to_place(),
631631
M::enforce_validity_recursively(self, dest.layout()),
632632
/*reset_provenance_and_padding*/ true,
@@ -858,13 +858,13 @@ where
858858
// shared reference.
859859
// But if the types are identical, that is strictly redundant so we only do one pass.
860860
if src.layout().ty != dest.layout().ty {
861-
self.validate_operand(
861+
self.validate_place(
862862
&dest.transmute(src.layout(), self)?,
863863
M::enforce_validity_recursively(self, src.layout()),
864864
/*reset_provenance_and_padding*/ true,
865865
)?;
866866
}
867-
self.validate_operand(
867+
self.validate_place(
868868
&dest,
869869
M::enforce_validity_recursively(self, dest.layout()),
870870
/*reset_provenance_and_padding*/ true,

‎compiler/rustc_const_eval/src/interpret/step.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
342342
// Validate that the entire thing is valid, and reset padding that might be in between the
343343
// fields.
344344
if M::enforce_validity(self, dest.layout()) {
345-
self.validate_operand(
345+
self.validate_place(
346346
dest,
347347
M::enforce_validity_recursively(self, dest.layout()),
348348
/*reset_provenance_and_padding*/ true,

‎compiler/rustc_const_eval/src/interpret/validity.rs‎

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ struct ValidityVisitor<'rt, 'tcx, M: Machine<'tcx>> {
363363
/// we only store a (range) set of offsets -- the base pointer is the same throughout the entire
364364
/// visit, after all.
365365
/// If this is `Some`, then `reset_provenance_and_padding` must be true (but not vice versa:
366-
/// we might not track data vs padding bytes if the operand isn't stored in memory anyway).
366+
/// we might not track data vs padding bytes if the place isn't stored in memory anyway).
367367
data_bytes: Option<RangeSet>,
368368
/// True if we are inside of `MaybeDangling`. This disables pointer access checks.
369369
may_dangle: bool,
@@ -1573,7 +1573,7 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValueVisitor<'tcx, M> for ValidityVisitor<'rt,
15731573

15741574
impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
15751575
/// The internal core entry point for all validation operations.
1576-
fn validate_operand_internal(
1576+
fn validate_place_internal(
15771577
&mut self,
15781578
val: &PlaceTy<'tcx, M::Provenance>,
15791579
path: Path<'tcx>,
@@ -1582,7 +1582,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
15821582
reset_provenance_and_padding: bool,
15831583
start_in_may_dangle: bool,
15841584
) -> InterpResult<'tcx> {
1585-
trace!("validate_operand_internal: {:?}, {:?}", *val, val.layout.ty);
1585+
trace!("validate_place_internal: {:?}, {:?}", *val, val.layout.ty);
15861586

15871587
// Run the visitor.
15881588
self.run_for_validation_mut(|ecx| {
@@ -1621,7 +1621,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
16211621
}
16221622

16231623
/// This function checks the data at `val` to be const-valid.
1624-
/// `val` is assumed to cover valid memory if it is an indirect operand.
1624+
/// `val` is assumed to cover valid memory.
16251625
/// It will error if the bits at the destination do not match the ones described by the layout.
16261626
///
16271627
/// `ref_tracking` is used to record references that we encounter so that they
@@ -1631,14 +1631,14 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
16311631
/// - no pointers to statics.
16321632
/// - no `UnsafeCell` or non-ZST `&mut`.
16331633
#[inline(always)]
1634-
pub(crate) fn const_validate_operand(
1634+
pub(crate) fn const_validate_place(
16351635
&mut self,
16361636
val: &PlaceTy<'tcx, M::Provenance>,
16371637
path: Path<'tcx>,
16381638
ref_tracking: &mut RefTracking<MPlaceTy<'tcx, M::Provenance>, Path<'tcx>>,
16391639
ctfe_mode: CtfeValidationMode,
16401640
) -> InterpResult<'tcx> {
1641-
self.validate_operand_internal(
1641+
self.validate_place_internal(
16421642
val,
16431643
path,
16441644
Some(ref_tracking),
@@ -1649,27 +1649,22 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
16491649
}
16501650

16511651
/// This function checks the data at `val` to be runtime-valid.
1652-
/// `val` is assumed to cover valid memory if it is an indirect operand.
1652+
/// `val` is assumed to cover valid memory.
16531653
/// It will error if the bits at the destination do not match the ones described by the layout.
16541654
#[inline(always)]
1655-
pub fn validate_operand(
1655+
pub fn validate_place(
16561656
&mut self,
16571657
val: &PlaceTy<'tcx, M::Provenance>,
16581658
recursive: bool,
16591659
reset_provenance_and_padding: bool,
16601660
) -> InterpResult<'tcx> {
1661-
let _trace = enter_trace_span!(
1662-
M,
1663-
"validate_operand",
1664-
recursive,
1665-
reset_provenance_and_padding,
1666-
?val,
1667-
);
1661+
let _trace =
1662+
enter_trace_span!(M, "validate_place", recursive, reset_provenance_and_padding, ?val,);
16681663
// Note that we *could* actually be in CTFE here with `-Zextra-const-ub-checks`, but it's
16691664
// still correct to not use `ctfe_mode`: that mode is for validation of the final constant
16701665
// value, it rules out things like `UnsafeCell` in awkward places.
16711666
if !recursive {
1672-
return self.validate_operand_internal(
1667+
return self.validate_place_internal(
16731668
val,
16741669
Path::new(val.layout.ty),
16751670
None,
@@ -1680,7 +1675,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
16801675
}
16811676
// Do a recursive check.
16821677
let mut ref_tracking = RefTracking::empty();
1683-
self.validate_operand_internal(
1678+
self.validate_place_internal(
16841679
val,
16851680
Path::new(val.layout.ty),
16861681
Some(&mut ref_tracking),
@@ -1692,7 +1687,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
16921687
// Things behind reference do *not* have the provenance reset. In fact
16931688
// we treat the entire thing as being inside MaybeDangling, i.e., references
16941689
// do not have to be dereferenceable.
1695-
self.validate_operand_internal(
1690+
self.validate_place_internal(
16961691
&mplace.into(),
16971692
path,
16981693
None, // no further recursion

‎compiler/rustc_const_eval/src/util/check_validity_requirement.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn check_validity_requirement_strict<'tcx>(
7676
// option this is fine, but if this is ever meant to be stable we should probably add
7777
// a "fast mode" to validation.
7878
with_no_trimmed_paths!(
79-
cx.validate_operand(
79+
cx.validate_place(
8080
&allocated.into(),
8181
/*recursive*/ false,
8282
/*reset_provenance_and_padding*/ false,
@@ -200,7 +200,7 @@ pub(crate) fn validate_scalar_in_layout<'tcx>(
200200

201201
cx.write_scalar(scalar, &allocated).unwrap();
202202

203-
cx.validate_operand(
203+
cx.validate_place(
204204
&allocated.into(),
205205
/*recursive*/ false,
206206
/*reset_provenance_and_padding*/ false,

0 commit comments

Comments
 (0)