Skip to content

Commit 2b2345f

Browse files
authored
chore: Solve clippy::unwrap_in_result FIXMEs (#1213)
1 parent fd86c0e commit 2b2345f

3 files changed

Lines changed: 11 additions & 25 deletions

File tree

crates/k8s-version/src/level/mod.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,18 @@ pub enum Level {
4747
impl FromStr for Level {
4848
type Err = ParseLevelError;
4949

50-
// SAFETY: We purposefully allow the `clippy::unwrap_in_result` lint below in this function.
51-
// We can use expect here, because the correct match labels must be used.
52-
//
53-
// FIXME (@Techassi): This attribute can be used on individual unwrap and expect calls since
54-
// Rust 1.91.0. We should move this attribute to not contaminate an unnecessarily large scope
55-
// once we bump the toolchain to 1.91.0.
56-
// See https://github.com/rust-lang/rust-clippy/pull/15445
57-
#[allow(clippy::unwrap_in_result)]
5850
fn from_str(input: &str) -> Result<Self, Self::Err> {
5951
let captures = LEVEL_REGEX.captures(input).context(InvalidFormatSnafu)?;
6052

53+
// SAFETY: We purposefully allow the `clippy::unwrap_in_result` lint here and below.
54+
// We can use expect here, because the correct match labels must be used.
55+
#[allow(clippy::unwrap_in_result)]
6156
let identifier = captures
6257
.name("identifier")
6358
.expect("internal error: check that the correct match label is specified")
6459
.as_str();
6560

61+
#[allow(clippy::unwrap_in_result)]
6662
let version = captures
6763
.name("version")
6864
.expect("internal error: check that the correct match label is specified")

crates/k8s-version/src/version/mod.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,13 @@ pub struct Version {
5353
impl FromStr for Version {
5454
type Err = ParseVersionError;
5555

56-
// SAFETY: We purposefully allow the `clippy::unwrap_in_result` lint below in this function.
57-
// We can use expect here, because the correct match label must be used.
58-
//
59-
// FIXME (@Techassi): This attribute can be used on individual unwrap and expect calls since
60-
// Rust 1.91.0. We should move this attribute to not contaminate an unnecessarily large scope
61-
// once we bump the toolchain to 1.91.0.
62-
// See https://github.com/rust-lang/rust-clippy/pull/15445
6356
#[allow(clippy::unwrap_in_result)]
6457
fn from_str(input: &str) -> Result<Self, Self::Err> {
6558
let captures = VERSION_REGEX.captures(input).context(InvalidFormatSnafu)?;
6659

60+
// SAFETY: We purposefully allow the `clippy::unwrap_in_result` lint below.
61+
// We can use expect here, because the correct match label must be used.
62+
#[allow(clippy::unwrap_in_result)]
6763
let major = captures
6864
.name("major")
6965
.expect("internal error: check that the correct match label is specified")

crates/stackable-certs/src/ca/mod.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,6 @@ where
205205
/// validity, this function offers complete control over these parameters.
206206
/// If this level of control is not needed, use [`CertificateAuthority::new`]
207207
/// instead.
208-
//
209-
// SAFETY: We purposefully allow the `clippy::unwrap_in_result` lint below in this function.
210-
// We can use expect here, because the subject name is defined as a constant which must be able
211-
// to be parsed.
212-
//
213-
// FIXME (@Techassi): This attribute can be used on individual unwrap and expect calls since
214-
// Rust 1.91.0. We should move this attribute to not contaminate an unnecessarily large scope
215-
// once we bump the toolchain to 1.91.0.
216-
// See https://github.com/rust-lang/rust-clippy/pull/15445
217-
#[allow(clippy::unwrap_in_result)]
218208
#[instrument(name = "create_certificate_authority_with", skip(signing_key_pair))]
219209
pub fn new_with(signing_key_pair: S, serial_number: u64, validity: Duration) -> Result<Self> {
220210
let serial_number = SerialNumber::from(serial_number);
@@ -223,6 +213,10 @@ where
223213
// We don't allow customization of the CA subject by callers. Every CA
224214
// created by us should contain the same subject consisting a common set
225215
// of distinguished names (DNs).
216+
// SAFETY: We purposefully allow the `clippy::unwrap_in_result` lint below.
217+
// We can use expect here, because the subject name is defined as a constant which must be
218+
// able to be parsed.
219+
#[allow(clippy::unwrap_in_result)]
226220
let subject = Name::from_str(SDP_ROOT_CA_SUBJECT)
227221
.expect("the constant SDP_ROOT_CA_SUBJECT must be a valid subject");
228222

0 commit comments

Comments
 (0)