From e60cf473b3ba1b5c0295d69e93e7d266f62ed60a Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Tue, 15 Jul 2025 06:56:30 +0200 Subject: refactor(crates/yt): Allow `missing_panic_docs` and use expect --- crates/yt/src/unreachable.rs | 50 -------------------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 crates/yt/src/unreachable.rs (limited to 'crates/yt/src/unreachable.rs') diff --git a/crates/yt/src/unreachable.rs b/crates/yt/src/unreachable.rs deleted file mode 100644 index 436fbb6..0000000 --- a/crates/yt/src/unreachable.rs +++ /dev/null @@ -1,50 +0,0 @@ -// yt - A fully featured command line YouTube client -// -// Copyright (C) 2024 Benedikt Peetz -// Copyright (C) 2025 Benedikt Peetz -// SPDX-License-Identifier: GPL-3.0-or-later -// -// This file is part of Yt. -// -// You should have received a copy of the License along with this program. -// If not, see . - -// This has been taken from: https://gitlab.torproject.org/tpo/core/arti/-/issues/950 - -// The functions here should be annotated with `#[inline(always)]`. -#![allow(clippy::inline_always)] - -use std::fmt::Debug; - -/// Trait for something that can possibly be unwrapped, like a Result or Option. -/// It provides semantic information, that unwrapping here should never happen. -pub trait Unreachable { - /// Like `expect()`, but does not trigger clippy. - /// - /// # Usage - /// - /// This method only exists so that we can use it without hitting - /// `clippy::missing_panics_docs`. Therefore, we should only use it - /// for situations where we are certain that the panic cannot occur - /// unless something else is very broken. Consider instead using - /// `expect()` and adding a `Panics` section to your function - /// documentation. - /// - /// # Panics - /// - /// Panics if this is not an object that can be unwrapped, such as - /// None or an Err. - fn unreachable(self, msg: &str) -> T; -} -impl Unreachable for Option { - #[inline(always)] - fn unreachable(self, msg: &str) -> T { - self.expect(msg) - } -} -impl Unreachable for Result { - #[inline(always)] - fn unreachable(self, msg: &str) -> T { - self.expect(msg) - } -} -- cgit 1.4.1