Skip to content

Commit 2fdbf07

Browse files
committed
Auto merge of #99707 - JohnTitor:rollup-74rb8vq, r=JohnTitor
Rollup of 7 pull requests Successful merges: - #95040 (protect `std::io::Take::limit` from overflow in `read`) - #95916 (kmc-solid: Use `libc::abort` to abort a program) - #99494 (Use non-relocatable code in nofile-limit.rs test) - #99581 (Improve error messages involving `derive` and `packed`.) - #99643 (Add `sign-ext` target feature to the WASM target) - #99659 (Use `VecMap::get` in `ConstraintLocator::check`) - #99690 (add miri-track-caller to more intrinsic-exposing methods) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2f320a2 + d1e4342 commit 2fdbf07

File tree

19 files changed

+140
-111
lines changed

19 files changed

+140
-111
lines changed

compiler/rustc_codegen_ssa/src/target_features.rs

+1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ const WASM_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
249249
("bulk-memory", Some(sym::wasm_target_feature)),
250250
("mutable-globals", Some(sym::wasm_target_feature)),
251251
("reference-types", Some(sym::wasm_target_feature)),
252+
("sign-ext", Some(sym::wasm_target_feature)),
252253
];
253254

254255
const BPF_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[("alu32", Some(sym::bpf_target_feature))];

compiler/rustc_mir_transform/src/check_packed_ref.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ fn unsafe_derive_on_repr_packed(tcx: TyCtxt<'_>, def_id: LocalDefId) {
3636
tcx.struct_span_lint_hir(UNALIGNED_REFERENCES, lint_hir_id, tcx.def_span(def_id), |lint| {
3737
// FIXME: when we make this a hard error, this should have its
3838
// own error code.
39-
let message = if tcx.generics_of(def_id).own_requires_monomorphization() {
40-
"`#[derive]` can't be used on a `#[repr(packed)]` struct with \
41-
type or const parameters (error E0133)"
39+
let extra = if tcx.generics_of(def_id).own_requires_monomorphization() {
40+
"with type or const parameters"
4241
} else {
43-
"`#[derive]` can't be used on a `#[repr(packed)]` struct that \
44-
does not derive Copy (error E0133)"
42+
"that does not derive `Copy`"
4543
};
44+
let message = format!(
45+
"`{}` can't be derived on this `#[repr(packed)]` struct {} (error E0133)",
46+
tcx.item_name(tcx.trait_id_of_impl(def_id.to_def_id()).expect("derived trait name")),
47+
extra
48+
);
4649
lint.build(message).emit();
4750
});
4851
}

compiler/rustc_typeck/src/collect/type_of.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,9 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
538538

539539
impl ConstraintLocator<'_> {
540540
#[instrument(skip(self), level = "debug")]
541-
fn check(&mut self, def_id: LocalDefId) {
541+
fn check(&mut self, item_def_id: LocalDefId) {
542542
// Don't try to check items that cannot possibly constrain the type.
543-
if !self.tcx.has_typeck_results(def_id) {
543+
if !self.tcx.has_typeck_results(item_def_id) {
544544
debug!("no constraint: no typeck results");
545545
return;
546546
}
@@ -555,26 +555,20 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> {
555555
// // because we again need to reveal `Foo` so we can check whether the
556556
// // constant does not contain interior mutability.
557557
// ```
558-
let tables = self.tcx.typeck(def_id);
558+
let tables = self.tcx.typeck(item_def_id);
559559
if let Some(_) = tables.tainted_by_errors {
560560
self.found = Some(ty::OpaqueHiddenType { span: DUMMY_SP, ty: self.tcx.ty_error() });
561561
return;
562562
}
563-
if tables.concrete_opaque_types.get(&self.def_id).is_none() {
563+
if !tables.concrete_opaque_types.contains_key(&self.def_id) {
564564
debug!("no constraints in typeck results");
565565
return;
566566
}
567567
// Use borrowck to get the type with unerased regions.
568-
let concrete_opaque_types = &self.tcx.mir_borrowck(def_id).concrete_opaque_types;
568+
let concrete_opaque_types = &self.tcx.mir_borrowck(item_def_id).concrete_opaque_types;
569569
debug!(?concrete_opaque_types);
570-
for &(def_id, concrete_type) in concrete_opaque_types {
571-
if def_id != self.def_id {
572-
// Ignore constraints for other opaque types.
573-
continue;
574-
}
575-
570+
if let Some(&concrete_type) = concrete_opaque_types.get(&self.def_id) {
576571
debug!(?concrete_type, "found constraint");
577-
578572
if let Some(prev) = self.found {
579573
if concrete_type.ty != prev.ty && !(concrete_type, prev).references_error() {
580574
prev.report_mismatch(&concrete_type, self.tcx);

library/core/src/hint.rs

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ use crate::intrinsics;
9696
#[inline]
9797
#[stable(feature = "unreachable", since = "1.27.0")]
9898
#[rustc_const_stable(feature = "const_unreachable_unchecked", since = "1.57.0")]
99+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
99100
pub const unsafe fn unreachable_unchecked() -> ! {
100101
// SAFETY: the safety contract for `intrinsics::unreachable` must
101102
// be upheld by the caller.

library/core/src/intrinsics.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2449,6 +2449,7 @@ pub(crate) fn is_nonoverlapping<T>(src: *const T, dst: *const T, count: usize) -
24492449
#[cfg_attr(not(bootstrap), rustc_allowed_through_unstable_modules)]
24502450
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
24512451
#[inline]
2452+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
24522453
pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
24532454
extern "rust-intrinsic" {
24542455
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
@@ -2535,6 +2536,7 @@ pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: us
25352536
#[cfg_attr(not(bootstrap), rustc_allowed_through_unstable_modules)]
25362537
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
25372538
#[inline]
2539+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
25382540
pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
25392541
extern "rust-intrinsic" {
25402542
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]

library/core/src/mem/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,7 @@ impl<T> fmt::Debug for Discriminant<T> {
11241124
#[stable(feature = "discriminant_value", since = "1.21.0")]
11251125
#[rustc_const_unstable(feature = "const_discriminant", issue = "69821")]
11261126
#[cfg_attr(not(test), rustc_diagnostic_item = "mem_discriminant")]
1127+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
11271128
pub const fn discriminant<T>(v: &T) -> Discriminant<T> {
11281129
Discriminant(intrinsics::discriminant_value(v))
11291130
}

library/core/src/num/int_macros.rs

+5
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ macro_rules! int_impl {
449449
without modifying the original"]
450450
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
451451
#[inline(always)]
452+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
452453
pub const unsafe fn unchecked_add(self, rhs: Self) -> Self {
453454
// SAFETY: the caller must uphold the safety contract for
454455
// `unchecked_add`.
@@ -517,6 +518,7 @@ macro_rules! int_impl {
517518
without modifying the original"]
518519
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
519520
#[inline(always)]
521+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
520522
pub const unsafe fn unchecked_sub(self, rhs: Self) -> Self {
521523
// SAFETY: the caller must uphold the safety contract for
522524
// `unchecked_sub`.
@@ -585,6 +587,7 @@ macro_rules! int_impl {
585587
without modifying the original"]
586588
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
587589
#[inline(always)]
590+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
588591
pub const unsafe fn unchecked_mul(self, rhs: Self) -> Self {
589592
// SAFETY: the caller must uphold the safety contract for
590593
// `unchecked_mul`.
@@ -757,6 +760,7 @@ macro_rules! int_impl {
757760
without modifying the original"]
758761
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
759762
#[inline(always)]
763+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
760764
pub const unsafe fn unchecked_shl(self, rhs: Self) -> Self {
761765
// SAFETY: the caller must uphold the safety contract for
762766
// `unchecked_shl`.
@@ -803,6 +807,7 @@ macro_rules! int_impl {
803807
without modifying the original"]
804808
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
805809
#[inline(always)]
810+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
806811
pub const unsafe fn unchecked_shr(self, rhs: Self) -> Self {
807812
// SAFETY: the caller must uphold the safety contract for
808813
// `unchecked_shr`.

library/core/src/num/uint_macros.rs

+5
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ macro_rules! uint_impl {
459459
without modifying the original"]
460460
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
461461
#[inline(always)]
462+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
462463
pub const unsafe fn unchecked_add(self, rhs: Self) -> Self {
463464
// SAFETY: the caller must uphold the safety contract for
464465
// `unchecked_add`.
@@ -528,6 +529,7 @@ macro_rules! uint_impl {
528529
without modifying the original"]
529530
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
530531
#[inline(always)]
532+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
531533
pub const unsafe fn unchecked_sub(self, rhs: Self) -> Self {
532534
// SAFETY: the caller must uphold the safety contract for
533535
// `unchecked_sub`.
@@ -574,6 +576,7 @@ macro_rules! uint_impl {
574576
without modifying the original"]
575577
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
576578
#[inline(always)]
579+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
577580
pub const unsafe fn unchecked_mul(self, rhs: Self) -> Self {
578581
// SAFETY: the caller must uphold the safety contract for
579582
// `unchecked_mul`.
@@ -933,6 +936,7 @@ macro_rules! uint_impl {
933936
without modifying the original"]
934937
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
935938
#[inline(always)]
939+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
936940
pub const unsafe fn unchecked_shl(self, rhs: Self) -> Self {
937941
// SAFETY: the caller must uphold the safety contract for
938942
// `unchecked_shl`.
@@ -979,6 +983,7 @@ macro_rules! uint_impl {
979983
without modifying the original"]
980984
#[rustc_const_unstable(feature = "const_inherent_unchecked_arith", issue = "85122")]
981985
#[inline(always)]
986+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
982987
pub const unsafe fn unchecked_shr(self, rhs: Self) -> Self {
983988
// SAFETY: the caller must uphold the safety contract for
984989
// `unchecked_shr`.

library/core/src/ptr/const_ptr.rs

+11
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ impl<T: ?Sized> *const T {
449449
#[must_use = "returns a new pointer rather than modifying its argument"]
450450
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
451451
#[inline(always)]
452+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
452453
pub const unsafe fn offset(self, count: isize) -> *const T
453454
where
454455
T: Sized,
@@ -471,6 +472,7 @@ impl<T: ?Sized> *const T {
471472
#[inline(always)]
472473
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
473474
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
475+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
474476
pub const unsafe fn byte_offset(self, count: isize) -> Self {
475477
// SAFETY: the caller must uphold the safety contract for `offset`.
476478
let this = unsafe { self.cast::<u8>().offset(count).cast::<()>() };
@@ -641,6 +643,7 @@ impl<T: ?Sized> *const T {
641643
#[stable(feature = "ptr_offset_from", since = "1.47.0")]
642644
#[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "92980")]
643645
#[inline]
646+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
644647
pub const unsafe fn offset_from(self, origin: *const T) -> isize
645648
where
646649
T: Sized,
@@ -663,6 +666,7 @@ impl<T: ?Sized> *const T {
663666
#[inline(always)]
664667
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
665668
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
669+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
666670
pub const unsafe fn byte_offset_from(self, origin: *const T) -> isize {
667671
// SAFETY: the caller must uphold the safety contract for `offset_from`.
668672
unsafe { self.cast::<u8>().offset_from(origin.cast::<u8>()) }
@@ -731,6 +735,7 @@ impl<T: ?Sized> *const T {
731735
#[unstable(feature = "ptr_sub_ptr", issue = "95892")]
732736
#[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")]
733737
#[inline]
738+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
734739
pub const unsafe fn sub_ptr(self, origin: *const T) -> usize
735740
where
736741
T: Sized,
@@ -862,6 +867,7 @@ impl<T: ?Sized> *const T {
862867
#[must_use = "returns a new pointer rather than modifying its argument"]
863868
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
864869
#[inline(always)]
870+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
865871
pub const unsafe fn add(self, count: usize) -> Self
866872
where
867873
T: Sized,
@@ -884,6 +890,7 @@ impl<T: ?Sized> *const T {
884890
#[inline(always)]
885891
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
886892
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
893+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
887894
pub const unsafe fn byte_add(self, count: usize) -> Self {
888895
// SAFETY: the caller must uphold the safety contract for `add`.
889896
let this = unsafe { self.cast::<u8>().add(count).cast::<()>() };
@@ -946,6 +953,7 @@ impl<T: ?Sized> *const T {
946953
#[must_use = "returns a new pointer rather than modifying its argument"]
947954
#[rustc_const_stable(feature = "const_ptr_offset", since = "1.61.0")]
948955
#[inline]
956+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
949957
pub const unsafe fn sub(self, count: usize) -> Self
950958
where
951959
T: Sized,
@@ -969,6 +977,7 @@ impl<T: ?Sized> *const T {
969977
#[inline(always)]
970978
#[unstable(feature = "pointer_byte_offsets", issue = "96283")]
971979
#[rustc_const_unstable(feature = "const_pointer_byte_offsets", issue = "96283")]
980+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
972981
pub const unsafe fn byte_sub(self, count: usize) -> Self {
973982
// SAFETY: the caller must uphold the safety contract for `sub`.
974983
let this = unsafe { self.cast::<u8>().sub(count).cast::<()>() };
@@ -1205,6 +1214,7 @@ impl<T: ?Sized> *const T {
12051214
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
12061215
#[stable(feature = "pointer_methods", since = "1.26.0")]
12071216
#[inline]
1217+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
12081218
pub const unsafe fn copy_to(self, dest: *mut T, count: usize)
12091219
where
12101220
T: Sized,
@@ -1224,6 +1234,7 @@ impl<T: ?Sized> *const T {
12241234
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
12251235
#[stable(feature = "pointer_methods", since = "1.26.0")]
12261236
#[inline]
1237+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
12271238
pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
12281239
where
12291240
T: Sized,

0 commit comments

Comments
 (0)