Skip to content

Commit 5c45343

Browse files
committed
Auto merge of #61625 - RalfJung:eval-interp, r=oli-obk
Rename remaining "Eval" to "Interp" Renaming done by sed. r? @oli-obk Fixes #54395.
2 parents fb7cca3 + b86c050 commit 5c45343

21 files changed

+274
-271
lines changed

src/librustc/mir/interpret/allocation.rs

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! The virtual memory representation of the MIR interpreter.
22
33
use super::{
4-
Pointer, EvalResult, AllocId, ScalarMaybeUndef, write_target_uint, read_target_uint, Scalar,
4+
Pointer, InterpResult, AllocId, ScalarMaybeUndef, write_target_uint, read_target_uint, Scalar,
55
};
66

77
use crate::ty::layout::{Size, Align};
@@ -82,7 +82,7 @@ pub trait AllocationExtra<Tag>: ::std::fmt::Debug + Clone {
8282
_alloc: &Allocation<Tag, Self>,
8383
_ptr: Pointer<Tag>,
8484
_size: Size,
85-
) -> EvalResult<'tcx> {
85+
) -> InterpResult<'tcx> {
8686
Ok(())
8787
}
8888

@@ -92,7 +92,7 @@ pub trait AllocationExtra<Tag>: ::std::fmt::Debug + Clone {
9292
_alloc: &mut Allocation<Tag, Self>,
9393
_ptr: Pointer<Tag>,
9494
_size: Size,
95-
) -> EvalResult<'tcx> {
95+
) -> InterpResult<'tcx> {
9696
Ok(())
9797
}
9898

@@ -103,7 +103,7 @@ pub trait AllocationExtra<Tag>: ::std::fmt::Debug + Clone {
103103
_alloc: &mut Allocation<Tag, Self>,
104104
_ptr: Pointer<Tag>,
105105
_size: Size,
106-
) -> EvalResult<'tcx> {
106+
) -> InterpResult<'tcx> {
107107
Ok(())
108108
}
109109
}
@@ -156,7 +156,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
156156
&self,
157157
ptr: Pointer<Tag>,
158158
msg: CheckInAllocMsg,
159-
) -> EvalResult<'tcx> {
159+
) -> InterpResult<'tcx> {
160160
let allocation_size = self.bytes.len() as u64;
161161
ptr.check_in_alloc(Size::from_bytes(allocation_size), msg)
162162
}
@@ -169,7 +169,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
169169
ptr: Pointer<Tag>,
170170
size: Size,
171171
msg: CheckInAllocMsg,
172-
) -> EvalResult<'tcx> {
172+
) -> InterpResult<'tcx> {
173173
// if ptr.offset is in bounds, then so is ptr (because offset checks for overflow)
174174
self.check_bounds_ptr(ptr.offset(size, cx)?, msg)
175175
}
@@ -191,7 +191,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
191191
size: Size,
192192
check_defined_and_ptr: bool,
193193
msg: CheckInAllocMsg,
194-
) -> EvalResult<'tcx, &[u8]>
194+
) -> InterpResult<'tcx, &[u8]>
195195
{
196196
self.check_bounds(cx, ptr, size, msg)?;
197197

@@ -217,7 +217,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
217217
cx: &impl HasDataLayout,
218218
ptr: Pointer<Tag>,
219219
size: Size,
220-
) -> EvalResult<'tcx, &[u8]>
220+
) -> InterpResult<'tcx, &[u8]>
221221
{
222222
self.get_bytes_internal(cx, ptr, size, true, CheckInAllocMsg::MemoryAccessTest)
223223
}
@@ -230,7 +230,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
230230
cx: &impl HasDataLayout,
231231
ptr: Pointer<Tag>,
232232
size: Size,
233-
) -> EvalResult<'tcx, &[u8]>
233+
) -> InterpResult<'tcx, &[u8]>
234234
{
235235
self.get_bytes_internal(cx, ptr, size, false, CheckInAllocMsg::MemoryAccessTest)
236236
}
@@ -242,7 +242,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
242242
cx: &impl HasDataLayout,
243243
ptr: Pointer<Tag>,
244244
size: Size,
245-
) -> EvalResult<'tcx, &mut [u8]>
245+
) -> InterpResult<'tcx, &mut [u8]>
246246
{
247247
assert_ne!(size.bytes(), 0, "0-sized accesses should never even get a `Pointer`");
248248
self.check_bounds(cx, ptr, size, CheckInAllocMsg::MemoryAccessTest)?;
@@ -267,7 +267,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
267267
&self,
268268
cx: &impl HasDataLayout,
269269
ptr: Pointer<Tag>,
270-
) -> EvalResult<'tcx, &[u8]>
270+
) -> InterpResult<'tcx, &[u8]>
271271
{
272272
assert_eq!(ptr.offset.bytes() as usize as u64, ptr.offset.bytes());
273273
let offset = ptr.offset.bytes() as usize;
@@ -292,7 +292,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
292292
ptr: Pointer<Tag>,
293293
size: Size,
294294
allow_ptr_and_undef: bool,
295-
) -> EvalResult<'tcx>
295+
) -> InterpResult<'tcx>
296296
{
297297
// Check bounds and relocations on the edges
298298
self.get_bytes_with_undef_and_ptr(cx, ptr, size)?;
@@ -312,7 +312,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
312312
cx: &impl HasDataLayout,
313313
ptr: Pointer<Tag>,
314314
src: &[u8],
315-
) -> EvalResult<'tcx>
315+
) -> InterpResult<'tcx>
316316
{
317317
let bytes = self.get_bytes_mut(cx, ptr, Size::from_bytes(src.len() as u64))?;
318318
bytes.clone_from_slice(src);
@@ -326,7 +326,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
326326
ptr: Pointer<Tag>,
327327
val: u8,
328328
count: Size
329-
) -> EvalResult<'tcx>
329+
) -> InterpResult<'tcx>
330330
{
331331
let bytes = self.get_bytes_mut(cx, ptr, count)?;
332332
for b in bytes {
@@ -348,7 +348,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
348348
cx: &impl HasDataLayout,
349349
ptr: Pointer<Tag>,
350350
size: Size
351-
) -> EvalResult<'tcx, ScalarMaybeUndef<Tag>>
351+
) -> InterpResult<'tcx, ScalarMaybeUndef<Tag>>
352352
{
353353
// get_bytes_unchecked tests relocation edges
354354
let bytes = self.get_bytes_with_undef_and_ptr(cx, ptr, size)?;
@@ -383,7 +383,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
383383
&self,
384384
cx: &impl HasDataLayout,
385385
ptr: Pointer<Tag>,
386-
) -> EvalResult<'tcx, ScalarMaybeUndef<Tag>>
386+
) -> InterpResult<'tcx, ScalarMaybeUndef<Tag>>
387387
{
388388
self.read_scalar(cx, ptr, cx.data_layout().pointer_size)
389389
}
@@ -402,7 +402,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
402402
ptr: Pointer<Tag>,
403403
val: ScalarMaybeUndef<Tag>,
404404
type_size: Size,
405-
) -> EvalResult<'tcx>
405+
) -> InterpResult<'tcx>
406406
{
407407
let val = match val {
408408
ScalarMaybeUndef::Scalar(scalar) => scalar,
@@ -438,7 +438,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
438438
cx: &impl HasDataLayout,
439439
ptr: Pointer<Tag>,
440440
val: ScalarMaybeUndef<Tag>
441-
) -> EvalResult<'tcx>
441+
) -> InterpResult<'tcx>
442442
{
443443
let ptr_size = cx.data_layout().pointer_size;
444444
self.write_scalar(cx, ptr.into(), val, ptr_size)
@@ -468,7 +468,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
468468
cx: &impl HasDataLayout,
469469
ptr: Pointer<Tag>,
470470
size: Size,
471-
) -> EvalResult<'tcx> {
471+
) -> InterpResult<'tcx> {
472472
if self.relocations(cx, ptr, size).is_empty() {
473473
Ok(())
474474
} else {
@@ -487,7 +487,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
487487
cx: &impl HasDataLayout,
488488
ptr: Pointer<Tag>,
489489
size: Size,
490-
) -> EvalResult<'tcx> {
490+
) -> InterpResult<'tcx> {
491491
// Find the start and end of the given range and its outermost relocations.
492492
let (first, last) = {
493493
// Find all relocations overlapping the given range.
@@ -525,7 +525,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
525525
cx: &impl HasDataLayout,
526526
ptr: Pointer<Tag>,
527527
size: Size,
528-
) -> EvalResult<'tcx> {
528+
) -> InterpResult<'tcx> {
529529
self.check_relocations(cx, ptr, Size::ZERO)?;
530530
self.check_relocations(cx, ptr.offset(size, cx)?, Size::ZERO)?;
531531
Ok(())
@@ -538,7 +538,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
538538
/// Checks that a range of bytes is defined. If not, returns the `ReadUndefBytes`
539539
/// error which will report the first byte which is undefined.
540540
#[inline]
541-
fn check_defined(&self, ptr: Pointer<Tag>, size: Size) -> EvalResult<'tcx> {
541+
fn check_defined(&self, ptr: Pointer<Tag>, size: Size) -> InterpResult<'tcx> {
542542
self.undef_mask.is_range_defined(
543543
ptr.offset,
544544
ptr.offset + size,
@@ -550,7 +550,7 @@ impl<'tcx, Tag, Extra> Allocation<Tag, Extra> {
550550
ptr: Pointer<Tag>,
551551
size: Size,
552552
new_state: bool,
553-
) -> EvalResult<'tcx> {
553+
) -> InterpResult<'tcx> {
554554
if size.bytes() == 0 {
555555
return Ok(());
556556
}

src/librustc/mir/interpret/error.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ pub fn struct_error<'a, 'gcx, 'tcx>(
185185
/// a `InterpError`. In `librustc_mir::interpret`, we have the `err!`
186186
/// macro for this
187187
#[derive(Debug, Clone)]
188-
pub struct EvalError<'tcx> {
188+
pub struct InterpErrorInfo<'tcx> {
189189
pub kind: InterpError<'tcx, u64>,
190190
backtrace: Option<Box<Backtrace>>,
191191
}
192192

193-
impl<'tcx> EvalError<'tcx> {
193+
impl<'tcx> InterpErrorInfo<'tcx> {
194194
pub fn print_backtrace(&mut self) {
195195
if let Some(ref mut backtrace) = self.backtrace {
196196
print_backtrace(&mut *backtrace);
@@ -203,7 +203,7 @@ fn print_backtrace(backtrace: &mut Backtrace) {
203203
eprintln!("\n\nAn error occurred in miri:\n{:?}", backtrace);
204204
}
205205

206-
impl<'tcx> From<InterpError<'tcx, u64>> for EvalError<'tcx> {
206+
impl<'tcx> From<InterpError<'tcx, u64>> for InterpErrorInfo<'tcx> {
207207
fn from(kind: InterpError<'tcx, u64>) -> Self {
208208
let backtrace = match env::var("RUST_CTFE_BACKTRACE") {
209209
// Matching `RUST_BACKTRACE` -- we treat "0" the same as "not present".
@@ -220,7 +220,7 @@ impl<'tcx> From<InterpError<'tcx, u64>> for EvalError<'tcx> {
220220
},
221221
_ => None,
222222
};
223-
EvalError {
223+
InterpErrorInfo {
224224
kind,
225225
backtrace,
226226
}
@@ -320,7 +320,7 @@ pub enum InterpError<'tcx, O> {
320320
InfiniteLoop,
321321
}
322322

323-
pub type EvalResult<'tcx, T = ()> = Result<T, EvalError<'tcx>>;
323+
pub type InterpResult<'tcx, T = ()> = Result<T, InterpErrorInfo<'tcx>>;
324324

325325
impl<'tcx, O> InterpError<'tcx, O> {
326326
pub fn description(&self) -> &str {
@@ -456,7 +456,7 @@ impl<'tcx, O> InterpError<'tcx, O> {
456456
}
457457
}
458458

459-
impl<'tcx> fmt::Display for EvalError<'tcx> {
459+
impl<'tcx> fmt::Display for InterpErrorInfo<'tcx> {
460460
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
461461
write!(f, "{}", self.kind)
462462
}

src/librustc/mir/interpret/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mod allocation;
1111
mod pointer;
1212

1313
pub use self::error::{
14-
EvalError, EvalResult, InterpError, AssertMessage, ConstEvalErr, struct_error,
14+
InterpErrorInfo, InterpResult, InterpError, AssertMessage, ConstEvalErr, struct_error,
1515
FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled,
1616
};
1717

src/librustc/mir/interpret/pointer.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::ty::layout::{self, HasDataLayout, Size};
55
use rustc_macros::HashStable;
66

77
use super::{
8-
AllocId, EvalResult, CheckInAllocMsg
8+
AllocId, InterpResult, CheckInAllocMsg
99
};
1010

1111
////////////////////////////////////////////////////////////////////////////////
@@ -52,13 +52,13 @@ pub trait PointerArithmetic: layout::HasDataLayout {
5252
}
5353

5454
#[inline]
55-
fn offset<'tcx>(&self, val: u64, i: u64) -> EvalResult<'tcx, u64> {
55+
fn offset<'tcx>(&self, val: u64, i: u64) -> InterpResult<'tcx, u64> {
5656
let (res, over) = self.overflowing_offset(val, i);
5757
if over { err!(Overflow(mir::BinOp::Add)) } else { Ok(res) }
5858
}
5959

6060
#[inline]
61-
fn signed_offset<'tcx>(&self, val: u64, i: i64) -> EvalResult<'tcx, u64> {
61+
fn signed_offset<'tcx>(&self, val: u64, i: i64) -> InterpResult<'tcx, u64> {
6262
let (res, over) = self.overflowing_signed_offset(val, i128::from(i));
6363
if over { err!(Overflow(mir::BinOp::Add)) } else { Ok(res) }
6464
}
@@ -125,7 +125,7 @@ impl<'tcx, Tag> Pointer<Tag> {
125125
}
126126

127127
#[inline]
128-
pub fn offset(self, i: Size, cx: &impl HasDataLayout) -> EvalResult<'tcx, Self> {
128+
pub fn offset(self, i: Size, cx: &impl HasDataLayout) -> InterpResult<'tcx, Self> {
129129
Ok(Pointer::new_with_tag(
130130
self.alloc_id,
131131
Size::from_bytes(cx.data_layout().offset(self.offset.bytes(), i.bytes())?),
@@ -145,7 +145,7 @@ impl<'tcx, Tag> Pointer<Tag> {
145145
}
146146

147147
#[inline]
148-
pub fn signed_offset(self, i: i64, cx: &impl HasDataLayout) -> EvalResult<'tcx, Self> {
148+
pub fn signed_offset(self, i: i64, cx: &impl HasDataLayout) -> InterpResult<'tcx, Self> {
149149
Ok(Pointer::new_with_tag(
150150
self.alloc_id,
151151
Size::from_bytes(cx.data_layout().signed_offset(self.offset.bytes(), i)?),
@@ -174,7 +174,7 @@ impl<'tcx, Tag> Pointer<Tag> {
174174
self,
175175
allocation_size: Size,
176176
msg: CheckInAllocMsg,
177-
) -> EvalResult<'tcx, ()> {
177+
) -> InterpResult<'tcx, ()> {
178178
if self.offset > allocation_size {
179179
err!(PointerOutOfBounds {
180180
ptr: self.erase_tag(),

0 commit comments

Comments
 (0)