Skip to content

Commit 76299b3

Browse files
committed
Add SAFETY annotations
Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 679f6f3 commit 76299b3

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

library/core/src/option.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ impl<T> Option<T> {
455455
debug_assert!(self.is_some());
456456
match self {
457457
Some(val) => val,
458+
// SAFETY: the safety contract must be upheld by the caller.
458459
None => unsafe { hint::unreachable_unchecked() },
459460
}
460461
}

library/core/src/result.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ impl<T, E> Result<T, E> {
849849
debug_assert!(self.is_ok());
850850
match self {
851851
Ok(t) => t,
852+
// SAFETY: the safety contract must be upheld by the caller.
852853
Err(_) => unsafe { hint::unreachable_unchecked() },
853854
}
854855
}
@@ -879,6 +880,7 @@ impl<T, E> Result<T, E> {
879880
pub unsafe fn unwrap_err_unchecked(self) -> E {
880881
debug_assert!(self.is_err());
881882
match self {
883+
// SAFETY: the safety contract must be upheld by the caller.
882884
Ok(_) => unsafe { hint::unreachable_unchecked() },
883885
Err(e) => e,
884886
}

0 commit comments

Comments
 (0)