Skip to content

Commit dcc8371

Browse files
committed
move CheckInAllocMsg to more logical place
1 parent c50b9d1 commit dcc8371

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

src/librustc/mir/interpret/allocation.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,6 @@ pub enum InboundsCheck {
2222
MaybeDead,
2323
}
2424

25-
/// Used by `check_in_alloc` to indicate context of check
26-
#[derive(Debug, Copy, Clone, RustcEncodable, RustcDecodable, HashStable)]
27-
pub enum CheckInAllocMsg {
28-
MemoryAccessTest,
29-
NullPointerTest,
30-
PointerArithmeticTest,
31-
InboundsTest,
32-
}
33-
34-
impl Display for CheckInAllocMsg {
35-
/// When this is printed as an error the context looks like this
36-
/// "{test name} failed: pointer must be in-bounds at offset..."
37-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
38-
write!(f, "{}", match *self {
39-
CheckInAllocMsg::MemoryAccessTest => "Memory access",
40-
CheckInAllocMsg::NullPointerTest => "Null pointer test",
41-
CheckInAllocMsg::PointerArithmeticTest => "Pointer arithmetic",
42-
CheckInAllocMsg::InboundsTest => "Inbounds test",
43-
})
44-
}
45-
}
46-
4725
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
4826
pub struct Allocation<Tag=(),Extra=()> {
4927
/// The actual bytes of the allocation.

src/librustc/mir/interpret/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ pub use self::value::{Scalar, ScalarMaybeUndef, RawConst, ConstValue};
1919

2020
pub use self::allocation::{
2121
InboundsCheck, Allocation, AllocationExtra,
22-
Relocations, UndefMask, CheckInAllocMsg,
22+
Relocations, UndefMask,
2323
};
2424

25-
pub use self::pointer::{Pointer, PointerArithmetic};
25+
pub use self::pointer::{Pointer, PointerArithmetic, CheckInAllocMsg};
2626

2727
use std::fmt;
2828
use crate::mir;

src/librustc/mir/interpret/pointer.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,31 @@ use crate::ty::layout::{self, HasDataLayout, Size};
55
use rustc_macros::HashStable;
66

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

11+
/// Used by `check_in_alloc` to indicate context of check
12+
#[derive(Debug, Copy, Clone, RustcEncodable, RustcDecodable, HashStable)]
13+
pub enum CheckInAllocMsg {
14+
MemoryAccessTest,
15+
NullPointerTest,
16+
PointerArithmeticTest,
17+
InboundsTest,
18+
}
19+
20+
impl Display for CheckInAllocMsg {
21+
/// When this is printed as an error the context looks like this
22+
/// "{test name} failed: pointer must be in-bounds at offset..."
23+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24+
write!(f, "{}", match *self {
25+
CheckInAllocMsg::MemoryAccessTest => "Memory access",
26+
CheckInAllocMsg::NullPointerTest => "Null pointer test",
27+
CheckInAllocMsg::PointerArithmeticTest => "Pointer arithmetic",
28+
CheckInAllocMsg::InboundsTest => "Inbounds test",
29+
})
30+
}
31+
}
32+
1133
////////////////////////////////////////////////////////////////////////////////
1234
// Pointer arithmetic
1335
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)