core: rewrite panic sites as explicit match+panic
Replace implicit unwrap()/expect() in the lock-ordered core with explicit
match arms. Lock-poison sites use one uniform message
("smarm: <lock> lock poisoned (core corrupt): {e}"); invariant sites panic
with a descriptive message naming the violated invariant. No behaviour
change: each rewrite preserves the prior panic-on-bad-arm semantics. Also
clears the accompanying clippy hygiene in these files (redundant_closure,
len_without_is_empty, too_many_arguments, unnecessary_sort_by,
missing_safety_doc, nonminimal_bool/unnecessary_unwrap).
This commit is contained in:
@@ -94,10 +94,28 @@ unsafe extern "C" fn switch_to_actor_asm() {
|
||||
}
|
||||
|
||||
/// Resume the actor whose sp is in `ACTOR_SP`. Returns when the actor yields.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The caller must be running on a scheduler thread with a valid actor stack
|
||||
/// pointer installed in `ACTOR_SP` — either by `init_actor_stack` (first
|
||||
/// resume) or by a prior `switch_to_scheduler` (subsequent resumes). Resuming
|
||||
/// with an unset or stale `ACTOR_SP` transfers control to an arbitrary address.
|
||||
/// Must not be called from within an actor (only the scheduler side may resume).
|
||||
pub unsafe fn switch_to_actor() {
|
||||
unsafe { switch_to_actor_asm() };
|
||||
}
|
||||
|
||||
/// Yield from the running actor back to its scheduler thread. Returns when the
|
||||
/// actor is next resumed via [`switch_to_actor`].
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The caller must be running on an actor stack that was entered through
|
||||
/// [`switch_to_actor`], so that `SCHEDULER_SP` holds the live saved stack
|
||||
/// pointer of the scheduler side. Calling this from the scheduler thread, or
|
||||
/// before any actor has been resumed, transfers control to an arbitrary
|
||||
/// address.
|
||||
#[unsafe(naked)]
|
||||
pub unsafe extern "C" fn switch_to_scheduler() {
|
||||
core::arch::naked_asm!(
|
||||
|
||||
Reference in New Issue
Block a user