{"record":{"id":"a85312d7f09c11a6","repo":"nautechsystems/nautilus_trader","slug":"checked-above","errorCode":null,"errorMessage":"checked above","messagePattern":"checked above","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"crates/adapters/derive/src/common/rate_limit.rs","lineNumber":335,"sourceCode":"                Some(wait) => {\n                    self.rollback_window(acquired, window);\n                    self.clock.sleep(wait).await;\n                }\n            }\n        }\n    }\n\n    /// Waits for the buckets a request class draws from, honoring the venue's\n    /// per-instrument matching allowance when the request carries an\n    /// instrument.\n    pub(crate) async fn await_class_ready(\n        &self,\n        class: RateClass,\n        instrument_name: Option<&Ustr>,\n    ) -> u32 {\n        match class {\n            RateClass::Matching if instrument_name.is_some() => {\n                let instrument = instrument_name.expect(\"checked above\");\n                self.await_buckets_ready(&[\n                    RateBucket::Matching,\n                    RateBucket::PerInstrument(instrument),\n                ])\n                .await\n            }\n            RateClass::Matching => self.await_buckets_ready(&[RateBucket::Matching]).await,\n            RateClass::NonMatching => self.await_buckets_ready(&[RateBucket::NonMatching]).await,\n            RateClass::CancelAll => self.await_buckets_ready(&[RateBucket::CancelAll]).await,\n            RateClass::CancelByLabel => {\n                self.await_buckets_ready(&[RateBucket::CancelByLabel]).await\n            }\n        }\n    }\n\n    /// Returns one consumed cell per key, but only while its cell still holds\n    /// `window`. Once a cell moved to a later window, the stale consumption\n    /// was already superseded and there is nothing to undo.","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/derive/src/common/rate_limit.rs#L317-L353","documentation":"In `await_class_ready`, the match arm `RateClass::Matching if instrument_name.is_some()` unwraps `instrument_name` with an `.expect(\"checked above\")`. The guard makes the panic logically unreachable — it is a compiler-workaround unwrap, not a real failure mode.","triggerScenarios":"Never, under correct code: the match guard guarantees `instrument_name` is `Some` before the expect runs. It would only fire if the guard and the expect were desynchronized by a future edit.","commonSituations":"Developers hitting this are almost certainly misreading the code; a real panic would require a Rust compiler bug or a refactor that separated the guard from the unwrap.","solutions":["No user action needed — unreachable by construction.","If you maintain the code, refactor to `if let Some(instrument) = instrument_name` to remove the unwrap entirely."],"exampleFix":"// before\nRateClass::Matching if instrument_name.is_some() => {\n    let instrument = instrument_name.expect(\"checked above\");\n// after\nRateClass::Matching => {\n    let instrument = instrument_name.expect(\"checked above\"); // or: if let Some(instrument)\n","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["No user action needed; the guard `instrument_name.is_some()` makes it unreachable."],"tags":["rust","panic","unreachable","rate-limit"],"backgroundTag":"null-argument","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}