summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ir/comp.rs8
-rw-r--r--src/ir/context.rs17
2 files changed, 10 insertions, 15 deletions
diff --git a/src/ir/comp.rs b/src/ir/comp.rs
index 9ff1e5df..230ba5b4 100644
--- a/src/ir/comp.rs
+++ b/src/ir/comp.rs
@@ -17,6 +17,7 @@ use peeking_take_while::PeekableExt;
use std::cmp;
use std::io;
use std::mem;
+use std::collections::HashMap;
/// The kind of compound type.
#[derive(Debug, Copy, Clone, PartialEq)]
@@ -344,11 +345,6 @@ impl Bitfield {
self.data.bitfield().unwrap()
}
- /// Get the name of this bitfield.
- fn name(&self) -> Option<&str> {
- self.data.name()
- }
-
/// Name of the generated Rust getter for this bitfield.
///
/// Panics if called before assigning bitfield accessor names or if
@@ -703,8 +699,6 @@ impl CompFields {
}
fn deanonymize_fields(&mut self, ctx: &BindgenContext, methods: &[Method]) {
- use std::collections::HashMap;
-
let fields = match *self {
CompFields::AfterComputingBitfieldUnits(ref mut fields) => fields,
CompFields::BeforeComputingBitfieldUnits(_) => {
diff --git a/src/ir/context.rs b/src/ir/context.rs
index 61dce891..8f361094 100644
--- a/src/ir/context.rs
+++ b/src/ir/context.rs
@@ -975,17 +975,18 @@ impl BindgenContext {
///
/// Panics if attempt to resolve given `ItemId` inside the given
/// closure is made.
- fn with_loaned_item<F: FnOnce(&BindgenContext, &mut Item)>(
- &mut self,
- item_id: ItemId,
- f: F,
- ) {
- let mut item = self.items.remove(&item_id).unwrap();
+ fn with_loaned_item<F, T>(&mut self, id: ItemId, f: F) -> T
+ where
+ F: (FnOnce(&BindgenContext, &mut Item) -> T)
+ {
+ let mut item = self.items.remove(&id).unwrap();
- f(self, &mut item);
+ let result = f(self, &mut item);
- let existing = self.items.insert(item_id, item);
+ let existing = self.items.insert(id, item);
assert!(existing.is_none());
+
+ result
}
/// Compute the bitfield allocation units for all `TypeKind::Comp` items we