Skip to content

Commit e58ea05

Browse files
committed
Clean-up following MSRV bump
1 parent 67704d7 commit e58ea05

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

enumflags_derive/src/lib.rs

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,8 @@ enum FlagValue<'a> {
2525
}
2626

2727
impl FlagValue<'_> {
28-
// matches! is beyond our MSRV
29-
#[allow(clippy::match_like_matches_macro)]
3028
fn is_inferred(&self) -> bool {
31-
match self {
32-
FlagValue::Inferred(_) => true,
33-
_ => false,
34-
}
29+
matches!(self, FlagValue::Inferred(_))
3530
}
3631
}
3732

@@ -110,15 +105,11 @@ fn collect_flags<'a>(
110105
) -> Result<Vec<Flag<'a>>, syn::Error> {
111106
variants
112107
.map(|variant| {
113-
// MSRV: Would this be cleaner with `matches!`?
114-
match variant.fields {
115-
syn::Fields::Unit => (),
116-
_ => {
117-
return Err(syn::Error::new_spanned(
118-
&variant.fields,
119-
"Bitflag variants cannot contain additional data",
120-
))
121-
}
108+
if !matches!(variant.fields, syn::Fields::Unit) {
109+
return Err(syn::Error::new_spanned(
110+
&variant.fields,
111+
"Bitflag variants cannot contain additional data",
112+
));
122113
}
123114

124115
let name = variant.ident.clone();
@@ -244,15 +235,8 @@ fn check_flag(type_name: &Ident, flag: &Flag, bits: u8) -> Result<Option<TokenSt
244235
Inferred(_) => Ok(None),
245236
Deferred => {
246237
let variant_name = &flag.name;
247-
// MSRV: Use an unnamed constant (`const _: ...`).
248-
let assertion_name = syn::Ident::new(
249-
&format!("__enumflags_assertion_{}_{}", type_name, flag.name),
250-
Span::call_site(),
251-
); // call_site because def_site is unstable
252-
253238
Ok(Some(quote_spanned!(flag.span =>
254-
#[doc(hidden)]
255-
const #assertion_name:
239+
const _:
256240
<<[(); (
257241
(#type_name::#variant_name as u128).is_power_of_two()
258242
) as usize] as enumflags2::_internal::AssertionHelper>

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ pub mod _internal {
285285

286286
pub const fn next_bit(x: u128) -> u128 {
287287
// trailing_ones is beyond our MSRV
288-
1 << (!x).trailing_zeros()
288+
1 << x.trailing_ones()
289289
}
290290
}
291291

0 commit comments

Comments
 (0)