Skip to content

Commit 57442be

Browse files
committed
Use unreachable! for an unreachable code path
1 parent 1eb7258 commit 57442be

File tree

1 file changed

+7
-1
lines changed
  • library/std/src/sys/windows

1 file changed

+7
-1
lines changed

library/std/src/sys/windows/mod.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,14 @@ where
224224
} as usize;
225225
if k == n && c::GetLastError() == c::ERROR_INSUFFICIENT_BUFFER {
226226
n *= 2;
227-
} else if k >= n {
227+
} else if k > n {
228228
n = k;
229+
} else if k == n {
230+
// It is impossible to reach this point.
231+
// On success, k is the returned string length excluding the null.
232+
// On failure, k is the required buffer length including the null.
233+
// Therefore k never equals n.
234+
unreachable!();
229235
} else {
230236
return Ok(f2(&buf[..k]));
231237
}

0 commit comments

Comments
 (0)