Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.

Commit 03f4e23

Browse files
committed
Remove unnecessary Result<(), Alloc> from send_message
1 parent 8f3374b commit 03f4e23

File tree

61 files changed

+137
-160
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+137
-160
lines changed

liblumen_alloc/src/erts/process.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,7 @@ impl ProcessControlBlock {
336336

337337
// Send
338338

339-
pub fn send_heap_message(
340-
&self,
341-
heap_fragment: NonNull<HeapFragment>,
342-
data: Term,
343-
) -> Result<(), Alloc> {
339+
pub fn send_heap_message(&self, heap_fragment: NonNull<HeapFragment>, data: Term) {
344340
let heap_fragment_ptr = heap_fragment.as_ptr();
345341

346342
let off_heap_unsafe_ref_heap_fragment = unsafe { UnsafeRef::from_raw(heap_fragment_ptr) };
@@ -353,11 +349,11 @@ impl ProcessControlBlock {
353349
self.send_message(Message::HeapFragment(message::HeapFragment {
354350
unsafe_ref_heap_fragment: message_unsafe_ref_heap_fragment,
355351
data,
356-
}))
352+
}));
357353
}
358354

359-
pub fn send_from_self(&self, data: Term) -> Result<(), Alloc> {
360-
self.send_message(Message::Process(message::Process { data }))
355+
pub fn send_from_self(&self, data: Term) {
356+
self.send_message(Message::Process(message::Process { data }));
361357
}
362358

363359
/// Returns `true` if the process should stop waiting and be rescheduled as runnable.
@@ -368,12 +364,12 @@ impl ProcessControlBlock {
368364

369365
self.send_message(Message::Process(message::Process {
370366
data: destination_data,
371-
}))?;
367+
}));
372368
}
373369
None => {
374370
let (heap_fragment_data, heap_fragment) = data.clone_to_fragment()?;
375371

376-
self.send_heap_message(heap_fragment, heap_fragment_data)?;
372+
self.send_heap_message(heap_fragment, heap_fragment_data);
377373
}
378374
}
379375

@@ -391,10 +387,8 @@ impl ProcessControlBlock {
391387
}
392388
}
393389

394-
fn send_message(&self, message: Message) -> Result<(), Alloc> {
395-
self.mailbox.lock().borrow_mut().push(message);
396-
397-
Ok(())
390+
fn send_message(&self, message: Message) {
391+
self.mailbox.lock().borrow_mut().push(message)
398392
}
399393

400394
// Terms

lumen_runtime/src/otp/erlang.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,7 +1800,7 @@ fn cancel_timer(
18001800
timer_reference,
18011801
canceled_term,
18021802
])?;
1803-
process_control_block.send_from_self(cancel_timer_message)?;
1803+
process_control_block.send_from_self(cancel_timer_message);
18041804

18051805
atom_unchecked("ok")
18061806
} else {
@@ -1914,7 +1914,7 @@ fn read_timer(
19141914
timer_reference,
19151915
read_term,
19161916
])?;
1917-
process_control_block.send_from_self(read_timer_message)?;
1917+
process_control_block.send_from_self(read_timer_message);
19181918

19191919
atom_unchecked("ok")
19201920
} else {

lumen_runtime/src/otp/erlang/tests/cancel_timer_1/with_local_reference/with_timer/in_different_thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ where
140140

141141
fn timeout_after_half(milliseconds: Milliseconds, barrier: &Barrier) {
142142
thread::sleep(Duration::from_millis(milliseconds / 2 + 1));
143-
timer::timeout().unwrap();
143+
timer::timeout();
144144
barrier.wait();
145145
}
146146

lumen_runtime/src/otp/erlang/tests/cancel_timer_1/with_local_reference/with_timer/in_same_thread.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn without_timeout_returns_milliseconds_remaining_and_does_not_send_timeout_mess
1010
let half_milliseconds = milliseconds / 2;
1111

1212
thread::sleep(Duration::from_millis(half_milliseconds + 1));
13-
timer::timeout().unwrap();
13+
timer::timeout();
1414

1515
let timeout_message = timeout_message(timer_reference, message, process);
1616

@@ -34,7 +34,7 @@ fn without_timeout_returns_milliseconds_remaining_and_does_not_send_timeout_mess
3434
);
3535

3636
thread::sleep(Duration::from_millis(half_milliseconds + 1));
37-
timer::timeout().unwrap();
37+
timer::timeout();
3838

3939
assert!(!has_message(process, timeout_message));
4040

@@ -50,7 +50,7 @@ fn without_timeout_returns_milliseconds_remaining_and_does_not_send_timeout_mess
5050
fn with_timeout_returns_false_after_timeout_message_was_sent() {
5151
with_timer(|milliseconds, message, timer_reference, process| {
5252
thread::sleep(Duration::from_millis(milliseconds + 1));
53-
timer::timeout().unwrap();
53+
timer::timeout();
5454

5555
let timeout_message = timeout_message(timer_reference, message, process);
5656

lumen_runtime/src/otp/erlang/tests/cancel_timer_2/with_reference_timer_reference/with_empty_list_options/with_local_reference/with_timer/in_different_thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ where
138138

139139
fn timeout_after_half(milliseconds: Milliseconds, barrier: &Barrier) {
140140
thread::sleep(Duration::from_millis(milliseconds / 2 + 1));
141-
timer::timeout().unwrap();
141+
timer::timeout();
142142
barrier.wait();
143143
}
144144

lumen_runtime/src/otp/erlang/tests/cancel_timer_2/with_reference_timer_reference/with_empty_list_options/with_local_reference/with_timer/in_same_thread.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn without_timeout_returns_milliseconds_remaining_and_does_not_send_timeout_mess
99
let half_milliseconds = milliseconds / 2;
1010

1111
thread::sleep(Duration::from_millis(half_milliseconds + 1));
12-
timer::timeout().unwrap();
12+
timer::timeout();
1313

1414
let timeout_message = timeout_message(timer_reference, message, process);
1515

@@ -32,7 +32,7 @@ fn without_timeout_returns_milliseconds_remaining_and_does_not_send_timeout_mess
3232
);
3333

3434
thread::sleep(Duration::from_millis(half_milliseconds + 1));
35-
timer::timeout().unwrap();
35+
timer::timeout();
3636

3737
assert!(!has_message(process, timeout_message));
3838

@@ -48,7 +48,7 @@ fn without_timeout_returns_milliseconds_remaining_and_does_not_send_timeout_mess
4848
fn with_timeout_returns_false_after_timeout_message_was_sent() {
4949
with_timer(|milliseconds, message, timer_reference, process| {
5050
thread::sleep(Duration::from_millis(milliseconds + 1));
51-
timer::timeout().unwrap();
51+
timer::timeout();
5252

5353
let timeout_message = timeout_message(timer_reference, message, process);
5454

lumen_runtime/src/otp/erlang/tests/cancel_timer_2/with_reference_timer_reference/with_list_options/with_async_false/with_info_false/with_local_reference/with_timer/in_different_thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ where
137137

138138
fn timeout_after_half(milliseconds: Milliseconds, barrier: &Barrier) {
139139
thread::sleep(Duration::from_millis(milliseconds / 2 + 1));
140-
timer::timeout().unwrap();
140+
timer::timeout();
141141
barrier.wait();
142142
}
143143

lumen_runtime/src/otp/erlang/tests/cancel_timer_2/with_reference_timer_reference/with_list_options/with_async_false/with_info_false/with_local_reference/with_timer/in_same_thread.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn without_timeout_returns_ok_and_does_not_send_timeout_message() {
99
let half_milliseconds = milliseconds / 2;
1010

1111
thread::sleep(Duration::from_millis(half_milliseconds + 1));
12-
timer::timeout().unwrap();
12+
timer::timeout();
1313

1414
let timeout_message = timeout_message(timer_reference, message, process);
1515

@@ -27,7 +27,7 @@ fn without_timeout_returns_ok_and_does_not_send_timeout_message() {
2727
);
2828

2929
thread::sleep(Duration::from_millis(half_milliseconds + 1));
30-
timer::timeout().unwrap();
30+
timer::timeout();
3131

3232
assert!(!has_message(process, timeout_message));
3333

@@ -43,7 +43,7 @@ fn without_timeout_returns_ok_and_does_not_send_timeout_message() {
4343
fn with_timeout_returns_ok_after_timeout_message_was_sent() {
4444
with_timer(|milliseconds, message, timer_reference, process| {
4545
thread::sleep(Duration::from_millis(milliseconds + 1));
46-
timer::timeout().unwrap();
46+
timer::timeout();
4747

4848
let timeout_message = timeout_message(timer_reference, message, process);
4949

lumen_runtime/src/otp/erlang/tests/cancel_timer_2/with_reference_timer_reference/with_list_options/with_async_false/with_info_true/with_local_reference/with_timer/in_different_thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ where
140140

141141
fn timeout_after_half(milliseconds: Milliseconds, barrier: &Barrier) {
142142
thread::sleep(Duration::from_millis(milliseconds / 2 + 1));
143-
timer::timeout().unwrap();
143+
timer::timeout();
144144
barrier.wait();
145145
}
146146

lumen_runtime/src/otp/erlang/tests/cancel_timer_2/with_reference_timer_reference/with_list_options/with_async_false/with_info_true/with_local_reference/with_timer/in_same_thread.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn without_timeout_returns_milliseconds_remaining_and_does_not_send_timeout_mess
1010
let half_milliseconds = milliseconds / 2;
1111

1212
thread::sleep(Duration::from_millis(half_milliseconds + 1));
13-
timer::timeout().unwrap();
13+
timer::timeout();
1414

1515
let timeout_message = timeout_message(timer_reference, message, process);
1616

@@ -34,7 +34,7 @@ fn without_timeout_returns_milliseconds_remaining_and_does_not_send_timeout_mess
3434
);
3535

3636
thread::sleep(Duration::from_millis(half_milliseconds + 1));
37-
timer::timeout().unwrap();
37+
timer::timeout();
3838

3939
assert!(!has_message(process, timeout_message));
4040

@@ -50,7 +50,7 @@ fn without_timeout_returns_milliseconds_remaining_and_does_not_send_timeout_mess
5050
fn with_timeout_returns_false_after_timeout_message_was_sent() {
5151
with_timer(|milliseconds, message, timer_reference, process| {
5252
thread::sleep(Duration::from_millis(milliseconds + 1));
53-
timer::timeout().unwrap();
53+
timer::timeout();
5454

5555
let timeout_message = timeout_message(timer_reference, message, process);
5656

0 commit comments

Comments
 (0)