Skip to content

Commit 458adf7

Browse files
committed
Auto merge of #131934 - matthiaskrgr:rollup-pd3dwxu, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #127462 (std: uefi: Add basic Env variables) - #131537 (Fix range misleading field access) - #131838 (bootstrap: allow setting `--jobs` in config.toml) - #131890 (Update `use` keyword docs to describe precise capturing) - #131899 (Mark unexpected variant res suggestion as having placeholders) - #131908 (rustdoc: Switch from FxHash to sha256 for static file hashing.) - #131916 (small interpreter error cleanup) - #131919 (zero-sized accesses are fine on null pointers) r? `@ghost` `@rustbot` modify labels: rollup
2 parents cbf09bf + 5bc1ffc commit 458adf7

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
lines changed

src/borrow_tracker/stacked_borrows/diagnostics.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn err_sb_ub<'tcx>(
1313
msg: String,
1414
help: Vec<String>,
1515
history: Option<TagHistory>,
16-
) -> InterpError<'tcx> {
16+
) -> InterpErrorKind<'tcx> {
1717
err_machine_stop!(TerminationInfo::StackedBorrowsUb { msg, help, history })
1818
}
1919

@@ -376,7 +376,7 @@ impl<'history, 'ecx, 'tcx> DiagnosticCx<'history, 'ecx, 'tcx> {
376376

377377
/// Report a descriptive error when `new` could not be granted from `derived_from`.
378378
#[inline(never)] // This is only called on fatal code paths
379-
pub(super) fn grant_error(&self, stack: &Stack) -> InterpError<'tcx> {
379+
pub(super) fn grant_error(&self, stack: &Stack) -> InterpErrorKind<'tcx> {
380380
let Operation::Retag(op) = &self.operation else {
381381
unreachable!("grant_error should only be called during a retag")
382382
};
@@ -402,7 +402,7 @@ impl<'history, 'ecx, 'tcx> DiagnosticCx<'history, 'ecx, 'tcx> {
402402

403403
/// Report a descriptive error when `access` is not permitted based on `tag`.
404404
#[inline(never)] // This is only called on fatal code paths
405-
pub(super) fn access_error(&self, stack: &Stack) -> InterpError<'tcx> {
405+
pub(super) fn access_error(&self, stack: &Stack) -> InterpErrorKind<'tcx> {
406406
// Deallocation and retagging also do an access as part of their thing, so handle that here, too.
407407
let op = match &self.operation {
408408
Operation::Access(op) => op,
@@ -424,7 +424,7 @@ impl<'history, 'ecx, 'tcx> DiagnosticCx<'history, 'ecx, 'tcx> {
424424
}
425425

426426
#[inline(never)] // This is only called on fatal code paths
427-
pub(super) fn protector_error(&self, item: &Item, kind: ProtectorKind) -> InterpError<'tcx> {
427+
pub(super) fn protector_error(&self, item: &Item, kind: ProtectorKind) -> InterpErrorKind<'tcx> {
428428
let protected = match kind {
429429
ProtectorKind::WeakProtector => "weakly protected",
430430
ProtectorKind::StrongProtector => "strongly protected",
@@ -445,7 +445,7 @@ impl<'history, 'ecx, 'tcx> DiagnosticCx<'history, 'ecx, 'tcx> {
445445
}
446446

447447
#[inline(never)] // This is only called on fatal code paths
448-
pub fn dealloc_error(&self, stack: &Stack) -> InterpError<'tcx> {
448+
pub fn dealloc_error(&self, stack: &Stack) -> InterpErrorKind<'tcx> {
449449
let Operation::Dealloc(op) = &self.operation else {
450450
unreachable!("dealloc_error should only be called during a deallocation")
451451
};

src/borrow_tracker/tree_borrows/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ pub(super) struct TbError<'node> {
298298

299299
impl TbError<'_> {
300300
/// Produce a UB error.
301-
pub fn build<'tcx>(self) -> InterpError<'tcx> {
301+
pub fn build<'tcx>(self) -> InterpErrorKind<'tcx> {
302302
use TransitionError::*;
303303
let cause = self.access_cause;
304304
let accessed = self.accessed_info;

src/borrow_tracker/tree_borrows/tree.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ impl<'tcx> Tree {
674674
Ok(())
675675
}
676676
},
677-
|args: ErrHandlerArgs<'_, TransitionError>| -> InterpError<'tcx> {
677+
|args: ErrHandlerArgs<'_, TransitionError>| -> InterpErrorKind<'tcx> {
678678
let ErrHandlerArgs { error_kind, conflicting_info, accessed_info } = args;
679679
TbError {
680680
conflicting_info,
@@ -772,7 +772,7 @@ impl<'tcx> Tree {
772772
let err_handler = |perms_range: Range<u64>,
773773
access_cause: diagnostics::AccessCause,
774774
args: ErrHandlerArgs<'_, TransitionError>|
775-
-> InterpError<'tcx> {
775+
-> InterpErrorKind<'tcx> {
776776
let ErrHandlerArgs { error_kind, conflicting_info, accessed_info } = args;
777777
TbError {
778778
conflicting_info,

src/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ pub fn report_error<'tcx>(
214214
ecx: &InterpCx<'tcx, MiriMachine<'tcx>>,
215215
e: InterpErrorInfo<'tcx>,
216216
) -> Option<(i64, bool)> {
217-
use InterpError::*;
217+
use InterpErrorKind::*;
218218
use UndefinedBehaviorInfo::*;
219219

220220
let mut msg = vec![];

src/intrinsics/simd.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -245,17 +245,17 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
245245
let val = match which {
246246
Op::MirOp(mir_op) => {
247247
// This does NaN adjustments.
248-
let val = this.binary_op(mir_op, &left, &right).map_err(|err| {
249-
match err.kind() {
250-
&InterpError::UndefinedBehavior(UndefinedBehaviorInfo::ShiftOverflow { shift_amount, .. }) => {
248+
let val = this.binary_op(mir_op, &left, &right).map_err_kind(|kind| {
249+
match kind {
250+
InterpErrorKind::UndefinedBehavior(UndefinedBehaviorInfo::ShiftOverflow { shift_amount, .. }) => {
251251
// This resets the interpreter backtrace, but it's not worth avoiding that.
252252
let shift_amount = match shift_amount {
253253
Either::Left(v) => v.to_string(),
254254
Either::Right(v) => v.to_string(),
255255
};
256-
err_ub_format!("overflowing shift by {shift_amount} in `simd_{intrinsic_name}` in lane {i}").into()
256+
err_ub_format!("overflowing shift by {shift_amount} in `simd_{intrinsic_name}` in lane {i}")
257257
}
258-
_ => err
258+
kind => kind
259259
}
260260
})?;
261261
if matches!(mir_op, BinOp::Eq | BinOp::Ne | BinOp::Lt | BinOp::Le | BinOp::Gt | BinOp::Ge) {

src/shims/foreign_items.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,10 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
289289
"miri_get_alloc_id" => {
290290
let [ptr] = this.check_shim(abi, Abi::Rust, link_name, args)?;
291291
let ptr = this.read_pointer(ptr)?;
292-
let (alloc_id, _, _) = this.ptr_get_alloc_id(ptr, 0).map_err(|_e| {
292+
let (alloc_id, _, _) = this.ptr_get_alloc_id(ptr, 0).map_err_kind(|_e| {
293293
err_machine_stop!(TerminationInfo::Abort(format!(
294294
"pointer passed to `miri_get_alloc_id` must not be dangling, got {ptr:?}"
295295
)))
296-
.into()
297296
})?;
298297
this.write_scalar(Scalar::from_u64(alloc_id.0.get()), dest)?;
299298
}

0 commit comments

Comments
 (0)