Skip to content

Commit

Permalink
Clean-up following MSRV bump
Browse files Browse the repository at this point in the history
  • Loading branch information
meithecatte committed Apr 1, 2023
1 parent 67704d7 commit e58ea05
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
30 changes: 7 additions & 23 deletions enumflags_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,8 @@ enum FlagValue<'a> {
}

impl FlagValue<'_> {
// matches! is beyond our MSRV
#[allow(clippy::match_like_matches_macro)]
fn is_inferred(&self) -> bool {
match self {
FlagValue::Inferred(_) => true,
_ => false,
}
matches!(self, FlagValue::Inferred(_))
}
}

Expand Down Expand Up @@ -110,15 +105,11 @@ fn collect_flags<'a>(
) -> Result<Vec<Flag<'a>>, syn::Error> {
variants
.map(|variant| {
// MSRV: Would this be cleaner with `matches!`?
match variant.fields {
syn::Fields::Unit => (),
_ => {
return Err(syn::Error::new_spanned(
&variant.fields,
"Bitflag variants cannot contain additional data",
))
}
if !matches!(variant.fields, syn::Fields::Unit) {
return Err(syn::Error::new_spanned(
&variant.fields,
"Bitflag variants cannot contain additional data",
));
}

let name = variant.ident.clone();
Expand Down Expand Up @@ -244,15 +235,8 @@ fn check_flag(type_name: &Ident, flag: &Flag, bits: u8) -> Result<Option<TokenSt
Inferred(_) => Ok(None),
Deferred => {
let variant_name = &flag.name;
// MSRV: Use an unnamed constant (`const _: ...`).
let assertion_name = syn::Ident::new(
&format!("__enumflags_assertion_{}_{}", type_name, flag.name),
Span::call_site(),
); // call_site because def_site is unstable

Ok(Some(quote_spanned!(flag.span =>
#[doc(hidden)]
const #assertion_name:
const _:
<<[(); (
(#type_name::#variant_name as u128).is_power_of_two()
) as usize] as enumflags2::_internal::AssertionHelper>
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ pub mod _internal {

pub const fn next_bit(x: u128) -> u128 {
// trailing_ones is beyond our MSRV

This comment has been minimized.

Copy link
@mwkmwkmwk

mwkmwkmwk Apr 1, 2023

Contributor

comment should be nuked

1 << (!x).trailing_zeros()
1 << x.trailing_ones()
}
}

Expand Down

0 comments on commit e58ea05

Please sign in to comment.