Add SAFETY
annotations
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
parent
679f6f3473
commit
76299b3f42
@ -455,6 +455,7 @@ impl<T> Option<T> {
|
||||
debug_assert!(self.is_some());
|
||||
match self {
|
||||
Some(val) => val,
|
||||
// SAFETY: the safety contract must be upheld by the caller.
|
||||
None => unsafe { hint::unreachable_unchecked() },
|
||||
}
|
||||
}
|
||||
|
@ -849,6 +849,7 @@ impl<T, E> Result<T, E> {
|
||||
debug_assert!(self.is_ok());
|
||||
match self {
|
||||
Ok(t) => t,
|
||||
// SAFETY: the safety contract must be upheld by the caller.
|
||||
Err(_) => unsafe { hint::unreachable_unchecked() },
|
||||
}
|
||||
}
|
||||
@ -879,6 +880,7 @@ impl<T, E> Result<T, E> {
|
||||
pub unsafe fn unwrap_err_unchecked(self) -> E {
|
||||
debug_assert!(self.is_err());
|
||||
match self {
|
||||
// SAFETY: the safety contract must be upheld by the caller.
|
||||
Ok(_) => unsafe { hint::unreachable_unchecked() },
|
||||
Err(e) => e,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user