Vec-growing logic emitted for Vecs which never grow #118563
Labels
I-heavy
Issue: Problems and improvements with respect to binary size of generated code.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-libs
Relevant to the library team, which will review and decide on the PR/issue.
Consider these two examples:
Godbolt: https://rust.godbolt.org/z/PhrMr7dYr
Neither are ever going to grow their Vec from the initial size. Yet,
RawVec::reserve_for_push
and friends are emitted when compiling.Uncommenting the
unreachable_unchecked
hints allows the optimizer to clean everything up. Might be asking a lot of the compiler but it would be great if it could figure that out by itself.Tested with Rust 1.74 and with 1.76.0-nightly (87e1447 2023-11-30).
The text was updated successfully, but these errors were encountered: