Skip to content

Commit ac4883a

Browse files
committed
internal: verify_flag_values: Use ? for error handling
1 parent 6c28951 commit ac4883a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

enumflags_derive/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ fn verify_flag_values<'a>(
119119
let discr = variant.discriminant.as_ref()
120120
.ok_or_else(|| syn::Error::new_spanned(variant,
121121
"Please add an explicit discriminant"))?;
122-
match fold_expr(&discr.1) {
123-
Ok(Some(flag)) => {
122+
match fold_expr(&discr.1)? {
123+
Some(flag) => {
124124
if !flag.is_power_of_two() {
125125
return Err(syn::Error::new_spanned(&discr.1,
126126
"Flags must have exactly one set bit"));
127127
}
128128
}
129-
Ok(None) => {
129+
None => {
130130
let variant_name = &variant.ident;
131131
// TODO: Remove this madness when Debian ships a new compiler.
132132
let assertion_name = syn::Ident::new(
@@ -145,7 +145,6 @@ fn verify_flag_values<'a>(
145145
};
146146
));
147147
}
148-
Err(why) => return Err(why.into()),
149148
}
150149
}
151150

0 commit comments

Comments
 (0)