diff options
| author | LingMan <LingMan@users.noreply.github.com> | 2021-01-07 09:13:21 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-07 09:13:21 +0100 |
| commit | 769fb8a8b7933f0810001353881410d1892e9268 (patch) | |
| tree | b9b38e643198f65dba2dfc819d3005fc80185f59 | |
| parent | dfdfaa1f0442dac516ba87d274d832c00464b3c2 (diff) | |
| download | rust-769fb8a8b7933f0810001353881410d1892e9268.tar.gz rust-769fb8a8b7933f0810001353881410d1892e9268.zip | |
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.
| -rw-r--r-- | library/std/src/alloc.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/library/std/src/alloc.rs b/library/std/src/alloc.rs index 8491ff40033..843ef09a584 100644 --- a/library/std/src/alloc.rs +++ b/library/std/src/alloc.rs @@ -166,8 +166,9 @@ impl System { match old_layout.size() { 0 => self.alloc_impl(new_layout, zeroed), - // SAFETY: `new_size` is non-zero as `old_size` is greater than or equal to `new_size` - // as required by safety conditions. Other conditions must be upheld by the caller + // SAFETY: `new_size` is non-zero as `new_size` is greater than or equal to `old_size` + // as required by safety conditions and the `old_size == 0` case was handled in the + // previous match arm. Other conditions must be upheld by the caller old_size if old_layout.align() == new_layout.align() => unsafe { let new_size = new_layout.size(); |
