Skip to content

Commit

Permalink
Add safety comment to StableAddress impl for Mmap
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Apr 3, 2021
1 parent 5773e51 commit bda6d1f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/rustc_data_structures/src/memmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>` 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 {}

0 comments on commit bda6d1f

Please sign in to comment.