diff options
Diffstat (limited to 'libbindgen/src')
-rw-r--r-- | libbindgen/src/clang.rs | 4 | ||||
-rw-r--r-- | libbindgen/src/codegen/mod.rs | 15 | ||||
-rw-r--r-- | libbindgen/src/ir/context.rs | 13 | ||||
-rw-r--r-- | libbindgen/src/ir/enum_ty.rs | 18 | ||||
-rw-r--r-- | libbindgen/src/ir/item.rs | 13 | ||||
-rw-r--r-- | libbindgen/src/ir/ty.rs | 4 | ||||
-rw-r--r-- | libbindgen/src/lib.rs | 23 |
7 files changed, 49 insertions, 41 deletions
diff --git a/libbindgen/src/clang.rs b/libbindgen/src/clang.rs index fc5575b3..de0ebf15 100644 --- a/libbindgen/src/clang.rs +++ b/libbindgen/src/clang.rs @@ -832,8 +832,8 @@ impl SourceLocation { &mut col, &mut off); (File { - x: file, - }, + x: file, + }, line as usize, col as usize, off as usize) diff --git a/libbindgen/src/codegen/mod.rs b/libbindgen/src/codegen/mod.rs index 6213a068..69d5f651 100644 --- a/libbindgen/src/codegen/mod.rs +++ b/libbindgen/src/codegen/mod.rs @@ -727,14 +727,15 @@ impl CodeGenerator for CompInfo { let layout = item.kind().expect_type().layout(ctx); if let Some(layout) = layout { - let fn_name = format!("__bindgen_test_layout_template_{}", result.next_id()); + let fn_name = format!("__bindgen_test_layout_template_{}", + result.next_id()); let fn_name = ctx.rust_ident_raw(&fn_name); let ident = item.to_rust_ty(ctx); let prefix = ctx.trait_prefix(); let size_of_expr = quote_expr!(ctx.ext_cx(), - ::$prefix::mem::size_of::<$ident>()); + ::$prefix::mem::size_of::<$ident>()); let align_of_expr = quote_expr!(ctx.ext_cx(), - ::$prefix::mem::align_of::<$ident>()); + ::$prefix::mem::align_of::<$ident>()); let size = layout.size; let align = layout.align; let item = quote_item!(ctx.ext_cx(), @@ -894,7 +895,7 @@ impl CodeGenerator for CompInfo { // Try to catch a bitfield contination early. if let (Some(ref mut bitfield_width), Some(width)) = - (current_bitfield_width, field.bitfield()) { + (current_bitfield_width, field.bitfield()) { let layout = current_bitfield_layout.unwrap(); debug!("Testing bitfield continuation {} {} {:?}", *bitfield_width, width, layout); @@ -1562,8 +1563,7 @@ impl CodeGenerator for Enum { }; let signed = repr.is_signed(); - let size = layout - .map(|l| l.size) + let size = layout.map(|l| l.size) .or_else(|| repr.known_size()) .unwrap_or(0); @@ -1621,7 +1621,8 @@ impl CodeGenerator for Enum { // Only to avoid recomputing every time. enum_canonical_name: &str, // May be the same as "variant" if it's because the - // enum is unnamed and we still haven't seen the value. + // enum is unnamed and we still haven't seen the + // value. variant_name: &str, referenced_name: &str, enum_rust_ty: P<ast::Ty>, diff --git a/libbindgen/src/ir/context.rs b/libbindgen/src/ir/context.rs index ba8ffe82..3ffe50c8 100644 --- a/libbindgen/src/ir/context.rs +++ b/libbindgen/src/ir/context.rs @@ -1135,7 +1135,8 @@ impl<'ctx, 'gen> Iterator for WhitelistedItemsIter<'ctx, 'gen> /// An iterator to find any dangling items. /// -/// See `BindgenContext::assert_no_dangling_item_traversal` for more information. +/// See `BindgenContext::assert_no_dangling_item_traversal` for more +/// information. pub struct AssertNoDanglingItemIter<'ctx, 'gen> where 'gen: 'ctx, { @@ -1152,8 +1153,8 @@ impl<'ctx, 'gen> Iterator for AssertNoDanglingItemIter<'ctx, 'gen> fn next(&mut self) -> Option<Self::Item> { let id = match self.to_iterate.pop_front() { None => { - // We've traversed everything reachable from the previous root(s), see if - // we have any more roots. + // We've traversed everything reachable from the previous + // root(s), see if we have any more roots. match self.ctx .items() .filter(|&(id, _)| !self.seen.contains_key(id)) @@ -1177,8 +1178,10 @@ impl<'ctx, 'gen> Iterator for AssertNoDanglingItemIter<'ctx, 'gen> let mut path = vec![]; let mut current = id; loop { - let predecessor = *self.seen.get(¤t) - .expect("We know we found this item id, so it must have a predecessor"); + let predecessor = *self.seen + .get(¤t) + .expect("We know we found this item id, so it must have a \ + predecessor"); if predecessor == current { break; } diff --git a/libbindgen/src/ir/enum_ty.rs b/libbindgen/src/ir/enum_ty.rs index b65d3c06..5c1ead45 100644 --- a/libbindgen/src/ir/enum_ty.rs +++ b/libbindgen/src/ir/enum_ty.rs @@ -54,17 +54,17 @@ impl Enum { let mut variants = vec![]; // Assume signedness since the default type by the C standard is an int. - let is_signed = repr - .and_then(|r| ctx.resolve_type(r).safe_canonical_type(ctx)) - .map_or(true, |ty| { - match *ty.kind() { - TypeKind::Int(ref int_kind) => int_kind.is_signed(), - ref other => { - panic!("Since when enums can be non-integers? {:?}", + let is_signed = + repr.and_then(|r| ctx.resolve_type(r).safe_canonical_type(ctx)) + .map_or(true, |ty| { + match *ty.kind() { + TypeKind::Int(ref int_kind) => int_kind.is_signed(), + ref other => { + panic!("Since when enums can be non-integers? {:?}", other) + } } - } - }); + }); declaration.visit(|cursor| { if cursor.kind() == CXCursor_EnumConstantDecl { diff --git a/libbindgen/src/ir/item.rs b/libbindgen/src/ir/item.rs index b3302919..0d5e6ba2 100644 --- a/libbindgen/src/ir/item.rs +++ b/libbindgen/src/ir/item.rs @@ -696,7 +696,9 @@ impl Item { } ItemKind::Type(ref ty) => { let name = match *ty.kind() { - TypeKind::ResolvedTypeRef(..) => panic!("should have resolved this in name_target()"), + TypeKind::ResolvedTypeRef(..) => { + panic!("should have resolved this in name_target()") + } _ => ty.name(), }; name.map(ToOwned::to_owned) @@ -1075,7 +1077,7 @@ impl ClangItemParser for Item { } if let Some(ty) = - ctx.builtin_or_resolved_ty(id, parent_id, ty, location) { + ctx.builtin_or_resolved_ty(id, parent_id, ty, location) { return Ok(ty); } @@ -1093,9 +1095,10 @@ impl ClangItemParser for Item { }; if valid_decl { - if let Some(&(_, item_id)) = ctx.currently_parsed_types - .iter() - .find(|&&(d, _)| d == declaration_to_look_for) { + if let Some(&(_, item_id)) = + ctx.currently_parsed_types + .iter() + .find(|&&(d, _)| d == declaration_to_look_for) { debug!("Avoiding recursion parsing type: {:?}", ty); return Ok(item_id); } diff --git a/libbindgen/src/ir/ty.rs b/libbindgen/src/ir/ty.rs index 1878471d..60092d54 100644 --- a/libbindgen/src/ir/ty.rs +++ b/libbindgen/src/ir/ty.rs @@ -696,8 +696,8 @@ impl Type { let inner_type = match inner { Ok(inner) => inner, Err(..) => { - error!("Failed to parse template alias {:?}", - location); + error!("Failed to parse template alias \ + {:?}", location); return Err(ParseError::Continue); } }; diff --git a/libbindgen/src/lib.rs b/libbindgen/src/lib.rs index 473dcf29..a74c1799 100644 --- a/libbindgen/src/lib.rs +++ b/libbindgen/src/lib.rs @@ -517,7 +517,8 @@ fn ensure_libclang_is_loaded() { // TODO(emilio): Return meaningful error (breaking). clang_sys::load().expect("Unable to find libclang"); *libclang = Some(clang_sys::get_library() - .expect("We just loaded libclang and it had better still be here!")); + .expect("We just loaded libclang and it had \ + better still be here!")); } else { clang_sys::set_library(libclang.clone()); } @@ -630,16 +631,16 @@ impl<'ctx> Bindings<'ctx> { /// /// See the `uses` module for more information. pub fn write_dummy_uses(&mut self) -> io::Result<()> { - let file = - if let Some(ref dummy_path) = self.context.options().dummy_uses { - Some(try!(OpenOptions::new() - .write(true) - .truncate(true) - .create(true) - .open(dummy_path))) - } else { - None - }; + let file = if let Some(ref dummy_path) = + self.context.options().dummy_uses { + Some(try!(OpenOptions::new() + .write(true) + .truncate(true) + .create(true) + .open(dummy_path))) + } else { + None + }; if let Some(file) = file { try!(uses::generate_dummy_uses(&mut self.context, file)); |