Skip to content

Commit d64356f

Browse files
authored
Rollup merge of rust-lang#80774 - LingMan:patch-1, r=nagisa
Fix safety comment The size assertion in the comment was inverted compared to the code. After fixing that the implication that `(new_size >= old_size) => new_size != 0` still doesn't hold so explain why `old_size != 0` at this point.
2 parents f90c7f0 + 769fb8a commit d64356f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

library/std/src/alloc.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,9 @@ impl System {
166166
match old_layout.size() {
167167
0 => self.alloc_impl(new_layout, zeroed),
168168

169-
// SAFETY: `new_size` is non-zero as `old_size` is greater than or equal to `new_size`
170-
// as required by safety conditions. Other conditions must be upheld by the caller
169+
// SAFETY: `new_size` is non-zero as `new_size` is greater than or equal to `old_size`
170+
// as required by safety conditions and the `old_size == 0` case was handled in the
171+
// previous match arm. Other conditions must be upheld by the caller
171172
old_size if old_layout.align() == new_layout.align() => unsafe {
172173
let new_size = new_layout.size();
173174

0 commit comments

Comments
 (0)