Skip to content

Commit

Permalink
Rollup merge of rust-lang#94756 - ChrisDenton:unreachable, r=yaahc
Browse files Browse the repository at this point in the history
Use `unreachable!` for an unreachable code path

Closes rust-lang#73212
  • Loading branch information
Dylan-DPC committed Mar 9, 2022
2 parents 4de06d4 + 57442be commit 28d06bd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion library/std/src/sys/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]));
}
Expand Down

0 comments on commit 28d06bd

Please sign in to comment.