Skip to main content

Module memory

Module memory 

Source
Expand description

The memory subsystem.

Generally, we use Pointer to denote memory addresses. However, some operations have a β€œsize”-like parameter, and they take Scalar for the address because if the size is 0, then the pointer can also be a (properly aligned, non-null) integer. It is crucial that these operations call check_align before short-circuiting the empty case!

Re-exportsΒ§

use std::borrow::Borrow; πŸ”’
use std::borrow::Cow; πŸ”’
use std::cell::Cell; πŸ”’
use std::collections::VecDeque; πŸ”’
use std::assert_matches; πŸ”’
use std::fmt; πŸ”’
use std::ptr; πŸ”’
use rustc_abi::Align; πŸ”’
use rustc_abi::HasDataLayout; πŸ”’
use rustc_abi::Size; πŸ”’
use rustc_ast::Mutability; πŸ”’
use rustc_data_structures::fx::FxHashSet; πŸ”’
use rustc_data_structures::fx::FxIndexMap; πŸ”’
use rustc_middle::mir::display_allocation; πŸ”’
use rustc_middle::ty; πŸ”’
use rustc_middle::ty::Instance; πŸ”’
use rustc_middle::ty::Ty; πŸ”’
use rustc_middle::ty::TyCtxt; πŸ”’
use rustc_span::bug; πŸ”’
use tracing::debug; πŸ”’
use tracing::instrument; πŸ”’
use tracing::instrument; πŸ”’
use tracing::trace; πŸ”’
use super::AllocBytes; πŸ”’
use super::AllocId; πŸ”’
use super::AllocInit; πŸ”’
use super::AllocMap; πŸ”’
use super::AllocRange; πŸ”’
use super::Allocation; πŸ”’
use super::CheckAlignMsg; πŸ”’
use super::CheckInAllocMsg; πŸ”’
use super::CtfeProvenance; πŸ”’
use super::GlobalAlloc; πŸ”’
use super::InterpCx; πŸ”’
use super::InterpResult; πŸ”’
use super::MPlaceTy; πŸ”’
use super::Machine; πŸ”’
use super::MayLeak; πŸ”’
use super::Misalignment; πŸ”’
use super::Pointer; πŸ”’
use super::PointerArithmetic; πŸ”’
use super::Provenance; πŸ”’
use super::Scalar; πŸ”’
use super::alloc_range; πŸ”’
use super::err_ub; πŸ”’
use super::err_ub_format; πŸ”’
use super::interp_ok; πŸ”’
use super::throw_ub; πŸ”’
use super::throw_ub_format; πŸ”’
use super::throw_unsup; πŸ”’
use super::throw_unsup_format; πŸ”’
use crate::const_eval::ConstEvalErrKind; πŸ”’

StructsΒ§

AllocInfo
Metadata about an AllocId.
AllocRef
A reference to some allocation that was already bounds-checked for the given region and had the on-access machine hooks run.
AllocRefMut
A reference to some allocation that was already bounds-checked for the given region and had the on-access machine hooks run.
Memory

EnumsΒ§

AllocKind
The return value of get_alloc_info indicates the β€œkind” of the allocation.
FnVal
The value of a function pointer.
MemoryKind