Skip to content

Commit 5f3f2be

Browse files
committed
Auto merge of #148123 - Zalathar:rollup-zlxn01b, r=Zalathar
Rollup of 4 pull requests Successful merges: - #145665 (Don't require `T: RefUnwindSafe` for `vec::IntoIter<T>: UnwindSafe`) - #147728 (tests: activate misspelled `gdb-check` in `function-arg-initialization.rs`) - #148097 (tests/debuginfo/closures.rs: Activate misspelled `cdb-check`) - #148118 (Improve the ICE message for invalid nullary intrinsic calls) r? `@ghost` `@rustbot` modify labels: rollup
2 parents e517798 + 278e079 commit 5f3f2be

File tree

5 files changed

+32
-5
lines changed

5 files changed

+32
-5
lines changed

compiler/rustc_codegen_ssa/src/mir/intrinsic.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,15 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
120120
| sym::atomic_singlethreadfence
121121
| sym::caller_location => {}
122122
_ => {
123-
span_bug!(span, "nullary intrinsic {name} must either be in a const block or explicitly opted out because it is inherently a runtime intrinsic
124-
");
123+
span_bug!(
124+
span,
125+
"Nullary intrinsic {name} must be called in a const block. \
126+
If you are seeing this message from code outside the standard library, the \
127+
unstable implementation details of the relevant intrinsic may have changed. \
128+
Consider using stable APIs instead. \
129+
If you are adding a new nullary intrinsic that is inherently a runtime \
130+
intrinsic, update this check."
131+
);
125132
}
126133
}
127134
}

library/alloc/src/vec/into_iter.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use core::mem::{ManuallyDrop, MaybeUninit, SizedTypeProperties};
77
use core::num::NonZero;
88
#[cfg(not(no_global_oom_handling))]
99
use core::ops::Deref;
10+
use core::panic::UnwindSafe;
1011
use core::ptr::{self, NonNull};
1112
use core::slice::{self};
1213
use core::{array, fmt};
@@ -60,6 +61,11 @@ pub struct IntoIter<
6061
pub(super) end: *const T,
6162
}
6263

64+
// Manually mirroring what `Vec` has,
65+
// because otherwise we get `T: RefUnwindSafe` from `NonNull`.
66+
#[stable(feature = "catch_unwind", since = "1.9.0")]
67+
impl<T: UnwindSafe, A: Allocator + UnwindSafe> UnwindSafe for IntoIter<T, A> {}
68+
6369
#[stable(feature = "vec_intoiter_debug", since = "1.13.0")]
6470
impl<T: fmt::Debug, A: Allocator> fmt::Debug for IntoIter<T, A> {
6571
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

library/core/src/intrinsics/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2728,6 +2728,11 @@ pub unsafe fn vtable_align(ptr: *const ()) -> usize;
27282728
/// More specifically, this is the offset in bytes between successive
27292729
/// items of the same type, including alignment padding.
27302730
///
2731+
/// Note that, unlike most intrinsics, this can only be called at compile-time
2732+
/// as backends do not have an implementation for it. The only caller (its
2733+
/// stable counterpart) wraps this intrinsic call in a `const` block so that
2734+
/// backends only see an evaluated constant.
2735+
///
27312736
/// The stabilized version of this intrinsic is [`core::mem::size_of`].
27322737
#[rustc_nounwind]
27332738
#[unstable(feature = "core_intrinsics", issue = "none")]
@@ -2742,6 +2747,11 @@ pub const fn size_of<T>() -> usize;
27422747
/// Therefore, implementations must not require the user to uphold
27432748
/// any safety invariants.
27442749
///
2750+
/// Note that, unlike most intrinsics, this can only be called at compile-time
2751+
/// as backends do not have an implementation for it. The only caller (its
2752+
/// stable counterpart) wraps this intrinsic call in a `const` block so that
2753+
/// backends only see an evaluated constant.
2754+
///
27452755
/// The stabilized version of this intrinsic is [`core::mem::align_of`].
27462756
#[rustc_nounwind]
27472757
#[unstable(feature = "core_intrinsics", issue = "none")]

tests/debuginfo/closures.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// cdb-check: [+0x[...]] x : [...] [Type: alloc::string::String]
1818
// cdb-check: [+0x[...]] _ref__base_value : 0x[...] : 42 [Type: int *]
1919
// cdb-command:dx simple_closure
20-
// cdb-checksimple_closure [Type: closures::main::closure_env$5]
20+
// cdb-check:simple_closure [Type: closures::main::closure_env$5]
2121
// cdb-check: [+0x[...]] _ref__base_value : 0x[...] : 42 [Type: int *]
2222
// cdb-command:g
2323
// cdb-command:dx first_closure

tests/debuginfo/function-arg-initialization.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626

2727
// NON IMMEDIATE ARGS
2828
// gdb-command:print a
29-
// gdbt-check:$4 = function_arg_initialization::BigStruct {a: 3, b: 4, c: 5, d: 6, e: 7, f: 8, g: 9, h: 10}
29+
// gdb-check:$4 = function_arg_initialization::BigStruct {a: 3, b: 4, c: 5, d: 6, e: 7, f: 8, g: 9, h: 10}
3030
// gdb-command:print b
31-
// gdbt-check:$5 = function_arg_initialization::BigStruct {a: 11, b: 12, c: 13, d: 14, e: 15, f: 16, g: 17, h: 18}
31+
// gdb-check:$5 = function_arg_initialization::BigStruct {a: 11, b: 12, c: 13, d: 14, e: 15, f: 16, g: 17, h: 18}
3232
// gdb-command:continue
3333

3434
// BINDING
@@ -234,6 +234,10 @@ struct BigStruct {
234234

235235
fn non_immediate_args(a: BigStruct, b: BigStruct) {
236236
zzz(); // #break
237+
238+
// FIXME(#128973): Needed to avoid `<optimized out>` prints before #128973 has been fixed.
239+
#[cfg(target_arch = "aarch64")]
240+
std::hint::black_box(|| { let _ = (a, b);});
237241
}
238242

239243
fn binding(a: i64, b: u64, c: f64) {

0 commit comments

Comments
 (0)