Skip to content

Commit b2063bd

Browse files
committed
Add #[must_use] annotation to Result::ok
1 parent b9ea82b commit b2063bd

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

library/core/src/result.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ impl<T, E> Result<T, E> {
655655
#[inline]
656656
#[stable(feature = "rust1", since = "1.0.0")]
657657
#[rustc_diagnostic_item = "result_ok_method"]
658+
#[must_use]
658659
pub fn ok(self) -> Option<T> {
659660
match self {
660661
Ok(x) => Some(x),

library/std/src/panicking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ fn default_hook(info: &PanicHookInfo<'_>) {
322322

323323
if let Ok(Some(local)) = try_set_output_capture(None) {
324324
write(&mut *local.lock().unwrap_or_else(|e| e.into_inner()));
325-
try_set_output_capture(Some(local)).ok();
325+
let _ = try_set_output_capture(Some(local));
326326
} else if let Some(mut out) = panic_output() {
327327
write(&mut out);
328328
}

0 commit comments

Comments
 (0)