about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-03-09 06:30:19 +0000
committerbors <bors@rust-lang.org>2022-03-09 06:30:19 +0000
commit6045c34f15d463c7d51104b968c1eabc5275b9c1 (patch)
treed540a7e2d3ed47e3058b603ec839015247cb2dac /library/std/src/sys
parent163c207fc28cadff4de1808848a93e3e5f2d1941 (diff)
parent822c4b6a92cb441728d7d871e08c258fccaa8826 (diff)
downloadrust-6045c34f15d463c7d51104b968c1eabc5275b9c1.tar.gz
rust-6045c34f15d463c7d51104b968c1eabc5275b9c1.zip
Auto merge of #94761 - Dylan-DPC:rollup-v4emqsy, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #94312 (Edit `rustc_trait_selection::infer::lattice` docs)
 - #94583 (Add a team for '`@rustbot` ping fuchsia')
 - #94686 (Do not allow `#[rustc_legacy_const_generics]` on methods)
 - #94699 (BTree: remove dead data needlessly complicating insert)
 - #94756 (Use `unreachable!` for an unreachable code path)
 - #94759 (Update cargo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/windows/mod.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/library/std/src/sys/windows/mod.rs b/library/std/src/sys/windows/mod.rs
index dc288176346..6097e628768 100644
--- a/library/std/src/sys/windows/mod.rs
+++ b/library/std/src/sys/windows/mod.rs
@@ -224,8 +224,14 @@ where
             } as usize;
             if k == n && c::GetLastError() == c::ERROR_INSUFFICIENT_BUFFER {
                 n *= 2;
-            } else if k >= n {
+            } else if k > n {
                 n = k;
+            } else if k == n {
+                // It is impossible to reach this point.
+                // On success, k is the returned string length excluding the null.
+                // On failure, k is the required buffer length including the null.
+                // Therefore k never equals n.
+                unreachable!();
             } else {
                 return Ok(f2(&buf[..k]));
             }