From ef8aa8833b10532db0a8c9e0b8a71ea554efa6ed Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Wed, 11 Jun 2025 14:47:20 -0400 Subject: [PATCH] fix: address Clippy change --- bindgen-tests/build.rs | 8 ++++++-- bindgen/ir/context.rs | 8 ++++---- bindgen/lib.rs | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bindgen-tests/build.rs b/bindgen-tests/build.rs index 8fb33716a1..af66bd96a6 100644 --- a/bindgen-tests/build.rs +++ b/bindgen-tests/build.rs @@ -33,8 +33,12 @@ pub fn main() { .replace(|c| !char::is_alphanumeric(c), "_") .replace("__", "_") .to_lowercase(); - writeln!(dst, "test_header!(header_{func}, {:?});", entry.path()) - .unwrap(); + writeln!( + dst, + "test_header!(header_{func}, {});", + entry.path().display() + ) + .unwrap(); } } diff --git a/bindgen/ir/context.rs b/bindgen/ir/context.rs index c0201a114b..6adbcd5989 100644 --- a/bindgen/ir/context.rs +++ b/bindgen/ir/context.rs @@ -724,7 +724,7 @@ If you encounter an error missing from this list, please file an issue or a PR!" self.need_bitfield_allocation.push(id); } - let old_item = mem::replace(&mut self.items[id.0], Some(item)); + let old_item = self.items[id.0].replace(item); assert!( old_item.is_none(), "should not have already associated an item with the given id" @@ -827,7 +827,7 @@ If you encounter an error missing from this list, please file an issue or a PR!" self.add_item_to_module(&item); let id = item.id(); - let old_item = mem::replace(&mut self.items[id.0], Some(item)); + let old_item = self.items[id.0].replace(item); assert!( old_item.is_none(), "should not have already associated an item with the given id" @@ -987,7 +987,7 @@ If you encounter an error missing from this list, please file an issue or a PR!" let result = f(self, &mut item); - let existing = mem::replace(&mut self.items[id.0], Some(item)); + let existing = self.items[id.0].replace(item); assert!(existing.is_none()); result @@ -1434,7 +1434,7 @@ If you encounter an error missing from this list, please file an issue or a PR!" debug_assert!(item.kind().is_type()); self.add_item_to_module(&item); let id = item.id(); - let old_item = mem::replace(&mut self.items[id.0], Some(item)); + let old_item = self.items[id.0].replace(item); assert!(old_item.is_none(), "Inserted type twice?"); } diff --git a/bindgen/lib.rs b/bindgen/lib.rs index b2fecc2c3b..55b082e8df 100644 --- a/bindgen/lib.rs +++ b/bindgen/lib.rs @@ -980,7 +980,7 @@ impl Bindings { } /// Gets the rustfmt path to rustfmt the generated bindings. - fn rustfmt_path(&self) -> io::Result> { + fn rustfmt_path(&self) -> io::Result> { debug_assert!(matches!(self.options.formatter, Formatter::Rustfmt)); if let Some(ref p) = self.options.rustfmt_path { return Ok(Cow::Borrowed(p));