Skip to content

Commit

Permalink
Run cargo-fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
grovesNL authored and eqrion committed Jan 11, 2019
1 parent 8c3e264 commit 678e5a8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 29 deletions.
21 changes: 9 additions & 12 deletions src/bindgen/ir/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,23 +201,20 @@ impl Constant {
_ => false,
};

if !ty.is_primitive_or_ptr_primitive() && !can_handle_const_expr
{
if !ty.is_primitive_or_ptr_primitive() && !can_handle_const_expr {
return Err("Unhandled const definition".to_owned());
}

let expr = Literal::load(
match item.expr {
syn::Expr::Struct(syn::ExprStruct { ref fields, .. }) => {
if is_transparent && fields.len() == 1 {
&fields[0].expr
} else {
&item.expr
}
let expr = Literal::load(match item.expr {
syn::Expr::Struct(syn::ExprStruct { ref fields, .. }) => {
if is_transparent && fields.len() == 1 {
&fields[0].expr
} else {
&item.expr
}
_ => &item.expr,
}
)?;
_ => &item.expr,
})?;

let full_name = Path::new(format!("{}_{}", struct_path, name));

Expand Down
34 changes: 17 additions & 17 deletions src/bindgen/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,12 +522,10 @@ impl Parse {
self.load_syn_ty(crate_name, mod_cfg, item);
}
syn::Item::Impl(ref item_impl) => {
let has_assoc_const = item_impl.items
.iter()
.any(|item| match item {
syn::ImplItem::Const(_) => true,
_ => false,
});
let has_assoc_const = item_impl.items.iter().any(|item| match item {
syn::ImplItem::Const(_) => true,
_ => false,
});
if has_assoc_const {
impls_with_assoc_consts.push(item_impl);
}
Expand All @@ -537,12 +535,10 @@ impl Parse {
}

for item_impl in impls_with_assoc_consts {
let associated_constants = item_impl.items
.iter()
.filter_map(|item| match item {
syn::ImplItem::Const(ref associated_constant) => Some(associated_constant),
_ => None,
});
let associated_constants = item_impl.items.iter().filter_map(|item| match item {
syn::ImplItem::Const(ref associated_constant) => Some(associated_constant),
_ => None,
});
self.load_syn_assoc_consts(
binding_crate_name,
crate_name,
Expand Down Expand Up @@ -648,7 +644,10 @@ impl Parse {
}
}

fn is_assoc_const_of_transparent_struct(&self, const_item: &syn::ImplItemConst) -> Result<bool, ()> {
fn is_assoc_const_of_transparent_struct(
&self,
const_item: &syn::ImplItemConst,
) -> Result<bool, ()> {
let ty = match Type::load(&const_item.ty) {
Ok(Some(t)) => t,
_ => return Ok(false),
Expand Down Expand Up @@ -698,10 +697,11 @@ impl Parse {
let impl_path = ty.unwrap().get_root_path().unwrap();

for item in items.into_iter() {
let is_assoc_const_of_transparent_struct = match self.is_assoc_const_of_transparent_struct(&item) {
Ok(b) => b,
Err(_) => continue,
};
let is_assoc_const_of_transparent_struct =
match self.is_assoc_const_of_transparent_struct(&item) {
Ok(b) => b,
Err(_) => continue,
};

if crate_name != binding_crate_name {
info!(
Expand Down

0 comments on commit 678e5a8

Please sign in to comment.