rust/compiler/rustc_metadata/src
bors 3223b0b5e8 Auto merge of #115542 - saethlin:fileencoder-is-bufwriter, r=WaffleLapkin
Simplify/Optimize FileEncoder

FileEncoder is basically a BufWriter except that it exposes access to the not-written-to-yet region of the buffer so that some users can write directly to the buffer. This strategy is awesome because it lets us avoid calling memcpy for small copies, but the previous strategy was based on the writer accessing a `&mut [MaybeUninit<u8>; N]` and returning a `&[u8]` which is an API which currently mandates the use of unsafe code, making that interface in general not that appealing.

So this PR cleans up the FileEncoder implementation and builds on that general idea of direct buffer access in order to prevent `memcpy` calls in a few key places when encoding the dep graph and rmeta tables. The interface used here is now 100% safe, but with the caveat that internally we need to avoid trusting the number of bytes that the provided function claims to have written.

The original primary objective of this PR was to clean up the FileEncoder implementation so that the fix for the following issues would be easy to implement. The fix for these issues is to correctly update self.buffered even when writes fail, which I think it's easy to verify manually is now done, because all the FileEncoder methods are small.

Fixes https://github.com/rust-lang/rust/issues/115298
Fixes https://github.com/rust-lang/rust/issues/114671
Fixes https://github.com/rust-lang/rust/issues/114045
Fixes https://github.com/rust-lang/rust/issues/108100
Fixes https://github.com/rust-lang/rust/issues/106787
2023-09-20 21:47:54 +00:00
..
rmeta Auto merge of #115542 - saethlin:fileencoder-is-bufwriter, r=WaffleLapkin 2023-09-20 21:47:54 +00:00
creader.rs Use FreezeLock for CStore 2023-09-09 16:02:11 +02:00
dependency_format.rs rustc: Move crate_types from Session to GlobalCtxt 2023-08-09 14:17:54 +08:00
errors.rs Suggest x build library for a custom toolchain that fails to load core 2023-07-04 09:37:40 +08:00
foreign_modules.rs Do not fetch HIR in native_libs. 2023-07-17 07:37:03 +00:00
fs.rs Auto merge of #114750 - Enselic:metadata-dep-info, r=compiler-errors 2023-09-17 11:45:53 +00:00
lib.rs Reuse const rendering from rustdoc in rmeta encoding 2023-09-01 17:22:48 -04:00
locator.rs Show lib features in -Zls and allow configuring which things are shown 2023-09-10 13:24:20 +00:00
native_libs.rs rustc: Move crate_types from Session to GlobalCtxt 2023-08-09 14:17:54 +08:00