Skip to content

Commit 948d606

Browse files
committed
Fix usages of Result::ok for discarding errors
1 parent 947add3 commit 948d606

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

compiler/rustc_data_structures/src/jobserver.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn default_client() -> Client {
4747
let client = Client::new(32).expect("failed to create jobserver");
4848

4949
// Acquire a token for the main thread which we can release later
50-
client.acquire_raw().ok();
50+
let _ = client.acquire_raw().ok();
5151

5252
client
5353
}
@@ -62,7 +62,7 @@ pub fn initialize_checked(report_warning: impl FnOnce(&'static str)) {
6262
default_client()
6363
}
6464
};
65-
GLOBAL_CLIENT_CHECKED.set(client_checked).ok();
65+
let _ = GLOBAL_CLIENT_CHECKED.set(client_checked);
6666
}
6767

6868
const ACCESS_ERROR: &str = "jobserver check should have been called earlier";
@@ -72,9 +72,9 @@ pub fn client() -> Client {
7272
}
7373

7474
pub fn acquire_thread() {
75-
GLOBAL_CLIENT_CHECKED.get().expect(ACCESS_ERROR).acquire_raw().ok();
75+
let _ = GLOBAL_CLIENT_CHECKED.get().expect(ACCESS_ERROR).acquire_raw();
7676
}
7777

7878
pub fn release_thread() {
79-
GLOBAL_CLIENT_CHECKED.get().expect(ACCESS_ERROR).release_raw().ok();
79+
let _ = GLOBAL_CLIENT_CHECKED.get().expect(ACCESS_ERROR).release_raw();
8080
}

compiler/rustc_data_structures/src/sync/worker_local.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl Registry {
7979
drop(threads);
8080
panic!("Thread already has a registry");
8181
}
82-
registry.set(self.clone()).ok();
82+
let _ = registry.set(self.clone());
8383
THREAD_DATA.with(|data| {
8484
data.registry_id.set(self.id());
8585
data.index.set(*threads);

compiler/rustc_query_system/src/query/caches.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ where
9999

100100
#[inline]
101101
fn complete(&self, _key: (), value: V, index: DepNodeIndex) {
102-
self.cache.set((value, index)).ok();
102+
let _ = self.cache.set((value, index));
103103
}
104104

105105
fn iter(&self, f: &mut dyn FnMut(&Self::Key, &Self::Value, DepNodeIndex)) {

library/std/src/collections/hash/set/tests.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -446,14 +446,13 @@ fn test_extract_if_drop_panic_leak() {
446446

447447
let mut set = (0..3).map(|i| D(i)).collect::<HashSet<_>>();
448448

449-
catch_unwind(move || {
449+
let _ = catch_unwind(move || {
450450
set.extract_if(|_| {
451451
PREDS.fetch_add(1, Ordering::SeqCst);
452452
true
453453
})
454454
.for_each(drop)
455-
})
456-
.ok();
455+
});
457456

458457
assert_eq!(PREDS.load(Ordering::SeqCst), 2);
459458
assert_eq!(DROPS.load(Ordering::SeqCst), 3);
@@ -475,14 +474,13 @@ fn test_extract_if_pred_panic_leak() {
475474

476475
let mut set: HashSet<_> = (0..3).map(|_| D).collect();
477476

478-
catch_unwind(AssertUnwindSafe(|| {
477+
let _ = catch_unwind(AssertUnwindSafe(|| {
479478
set.extract_if(|_| match PREDS.fetch_add(1, Ordering::SeqCst) {
480479
0 => true,
481480
_ => panic!(),
482481
})
483482
.for_each(drop)
484-
}))
485-
.ok();
483+
}));
486484

487485
assert_eq!(PREDS.load(Ordering::SeqCst), 1);
488486
assert_eq!(DROPS.load(Ordering::SeqCst), 3);

library/std/src/panicking.rs

+1-1
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)