diff --git a/crates/ruff_linter/src/rules/refurb/rules/hardcoded_string_charset.rs b/crates/ruff_linter/src/rules/refurb/rules/hardcoded_string_charset.rs index d29d89244b..0bc22b3a33 100644 --- a/crates/ruff_linter/src/rules/refurb/rules/hardcoded_string_charset.rs +++ b/crates/ruff_linter/src/rules/refurb/rules/hardcoded_string_charset.rs @@ -93,12 +93,7 @@ impl NamedCharset { name, bytes, // SAFETY: The named charset is guaranteed to have only ascii bytes. - // TODO: replace with `.unwrap()`, when `Option::unwrap` will be stable in `const fn` - // https://github.com/rust-lang/rust/issues/67441 - ascii_char_set: match AsciiCharSet::from_bytes(bytes) { - Some(ascii_char_set) => ascii_char_set, - None => unreachable!(), - }, + ascii_char_set: AsciiCharSet::from_bytes(bytes).unwrap(), } } } diff --git a/crates/ruff_source_file/src/line_index.rs b/crates/ruff_source_file/src/line_index.rs index 34631891bd..1f04aef240 100644 --- a/crates/ruff_source_file/src/line_index.rs +++ b/crates/ruff_source_file/src/line_index.rs @@ -562,11 +562,11 @@ pub struct OneIndexed(NonZeroUsize); impl OneIndexed { /// The largest value that can be represented by this integer type - pub const MAX: Self = unwrap(Self::new(usize::MAX)); + pub const MAX: Self = Self::new(usize::MAX).unwrap(); // SAFETY: These constants are being initialized with non-zero values /// The smallest value that can be represented by this integer type. - pub const MIN: Self = unwrap(Self::new(1)); - pub const ONE: NonZeroUsize = unwrap(NonZeroUsize::new(1)); + pub const MIN: Self = Self::new(1).unwrap(); + pub const ONE: NonZeroUsize = NonZeroUsize::new(1).unwrap(); /// Creates a non-zero if the given value is not zero. pub const fn new(value: usize) -> Option { @@ -636,15 +636,6 @@ impl fmt::Display for OneIndexed { } } -/// A const `Option::unwrap` without nightly features: -/// [Tracking issue](https://github.com/rust-lang/rust/issues/67441) -const fn unwrap(option: Option) -> T { - match option { - Some(value) => value, - None => panic!("unwrapping None"), - } -} - impl FromStr for OneIndexed { type Err = ParseIntError; fn from_str(s: &str) -> Result {