1
Fork 0

Rollup merge of #94756 - ChrisDenton:unreachable, r=yaahc

Use `unreachable!` for an unreachable code path

Closes #73212
This commit is contained in:
Dylan DPC 2022-03-09 06:38:53 +01:00 committed by GitHub
commit 28d06bdec9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -224,8 +224,14 @@ where
} as usize; } as usize;
if k == n && c::GetLastError() == c::ERROR_INSUFFICIENT_BUFFER { if k == n && c::GetLastError() == c::ERROR_INSUFFICIENT_BUFFER {
n *= 2; n *= 2;
} else if k >= n { } else if k > n {
n = k; 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 { } else {
return Ok(f2(&buf[..k])); return Ok(f2(&buf[..k]));
} }