Skip to content

Commit 91796cf

Browse files
committed
Review fixes
1 parent 83cfe89 commit 91796cf

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

src/ir/comp.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use peeking_take_while::PeekableExt;
1717
use std::cmp;
1818
use std::io;
1919
use std::mem;
20+
use std::collections::HashMap;
2021

2122
/// The kind of compound type.
2223
#[derive(Debug, Copy, Clone, PartialEq)]
@@ -344,11 +345,6 @@ impl Bitfield {
344345
self.data.bitfield().unwrap()
345346
}
346347

347-
/// Get the name of this bitfield.
348-
fn name(&self) -> Option<&str> {
349-
self.data.name()
350-
}
351-
352348
/// Name of the generated Rust getter for this bitfield.
353349
///
354350
/// Panics if called before assigning bitfield accessor names or if
@@ -703,8 +699,6 @@ impl CompFields {
703699
}
704700

705701
fn deanonymize_fields(&mut self, ctx: &BindgenContext, methods: &[Method]) {
706-
use std::collections::HashMap;
707-
708702
let fields = match *self {
709703
CompFields::AfterComputingBitfieldUnits(ref mut fields) => fields,
710704
CompFields::BeforeComputingBitfieldUnits(_) => {

src/ir/context.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -975,17 +975,18 @@ impl BindgenContext {
975975
///
976976
/// Panics if attempt to resolve given `ItemId` inside the given
977977
/// closure is made.
978-
fn with_loaned_item<F: FnOnce(&BindgenContext, &mut Item)>(
979-
&mut self,
980-
item_id: ItemId,
981-
f: F,
982-
) {
983-
let mut item = self.items.remove(&item_id).unwrap();
978+
fn with_loaned_item<F, T>(&mut self, id: ItemId, f: F) -> T
979+
where
980+
F: (FnOnce(&BindgenContext, &mut Item) -> T)
981+
{
982+
let mut item = self.items.remove(&id).unwrap();
984983

985-
f(self, &mut item);
984+
let result = f(self, &mut item);
986985

987-
let existing = self.items.insert(item_id, item);
986+
let existing = self.items.insert(id, item);
988987
assert!(existing.is_none());
988+
989+
result
989990
}
990991

991992
/// Compute the bitfield allocation units for all `TypeKind::Comp` items we

0 commit comments

Comments
 (0)