From 432d0197dfc526306f061e84ba211e92ec69166d Mon Sep 17 00:00:00 2001 From: Niklas Dusenlund Date: Wed, 18 Jun 2025 13:56:08 +0200 Subject: [PATCH] clippy: fix lints --- bindgen-tests/build.rs | 8 ++++++-- bindgen-tests/tests/tests.rs | 4 ++-- bindgen/ir/context.rs | 8 ++++---- bindgen/lib.rs | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/bindgen-tests/build.rs b/bindgen-tests/build.rs index 8fb33716a1..15081e6eb5 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-tests/tests/tests.rs b/bindgen-tests/tests/tests.rs index 3cc7cbe415..11121736ee 100644 --- a/bindgen-tests/tests/tests.rs +++ b/bindgen-tests/tests/tests.rs @@ -41,9 +41,9 @@ fn error_diff_mismatch( filename: &Path, ) -> Result<(), Error> { println!("diff expected generated"); - println!("--- expected: {filename:?}"); + println!("--- expected: \"{}\"", filename.display()); if let Some(header) = header { - println!("+++ generated from: {header:?}"); + println!("+++ generated from: \"{}\"", header.display()); } show_diff(expected, actual); 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));