Skip to content

Commit ab66c3f

Browse files
committed
Add comment with reasoning for non-determinism
1 parent a59fafe commit ab66c3f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

compiler/rustc_middle/src/mir/interpret/allocation.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@ impl<Tag> Allocation<Tag> {
127127
pub fn uninit(size: Size, align: Align) -> InterpResult<'static, Self> {
128128
let mut bytes = Vec::new();
129129
bytes.try_reserve(size.bytes_usize()).map_err(|_| {
130+
// This results in an error that can happen non-deterministically, since the memory
131+
// available to the compiler can change between runs. Normally queries are always
132+
// deterministic. However, we can be non-determinstic here because all uses of const
133+
// evaluation do one of:
134+
// - cause a fatal compiler error when they see this error as the result of const
135+
// evaluation
136+
// - panic on evaluation failure
137+
// - always evaluate very small constants that are practically unlikely to result in
138+
// memory exhaustion
130139
InterpError::ResourceExhaustion(ResourceExhaustionInfo::MemoryExhausted)
131140
})?;
132141
bytes.resize(size.bytes_usize(), 0);

0 commit comments

Comments
 (0)