File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
compiler/rustc_data_structures/src Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -18,8 +18,14 @@ impl Mmap {
1818 /// However in practice most callers do not ensure this, so uses of this function are likely unsound.
1919 #[ inline]
2020 pub unsafe fn map ( file : File ) -> io:: Result < Self > {
21- // Safety: the caller must ensure that this is safe.
22- unsafe { memmap2:: Mmap :: map ( & file) . map ( Mmap ) }
21+ // By default, memmap2 creates shared mappings, implying that we could see updates to the
22+ // file through the mapping. That would violate our precondition; so by requesting a
23+ // map_copy_read_only we do not lose anything.
24+ // This mapping mode also improves our support for filesystems such as cacheless virtiofs.
25+ // For more details see https://github.com/rust-lang/rust/issues/122262
26+ //
27+ // SAFETY: The caller must ensure that this is safe.
28+ unsafe { memmap2:: MmapOptions :: new ( ) . map_copy_read_only ( & file) . map ( Mmap ) }
2329 }
2430}
2531
You can’t perform that action at this time.
0 commit comments