From bda6d1f158a71efe84d86da2011eac0c45a232c5 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 3 Apr 2021 14:51:05 +0200 Subject: Add safety comment to StableAddress impl for Mmap --- compiler/rustc_data_structures/src/memmap.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'compiler/rustc_data_structures/src') diff --git a/compiler/rustc_data_structures/src/memmap.rs b/compiler/rustc_data_structures/src/memmap.rs index 29e999efeb1..26b26415eea 100644 --- a/compiler/rustc_data_structures/src/memmap.rs +++ b/compiler/rustc_data_structures/src/memmap.rs @@ -40,4 +40,8 @@ impl Deref for Mmap { } } +// SAFETY: On architectures other than WASM, mmap is used as backing storage. The address of this +// memory map is stable. On WASM, `Vec` is used as backing storage. The `Mmap` type doesn't +// export any function that can cause the `Vec` to be re-allocated. As such the address of the +// bytes inside this `Vec` is stable. unsafe impl StableAddress for Mmap {} -- cgit 1.4.1-3-g733a5