Skip to content

Commit 9ce9a1c

Browse files
nyurikemilio
authored andcommitted
use assert_eq|_ne instead of assert!
1 parent 1adcacd commit 9ce9a1c

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

bindgen/codegen/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2701,7 +2701,7 @@ impl CodeGenerator for CompInfo {
27012701
let mut method_names = Default::default();
27022702
if ctx.options().codegen_config.methods() {
27032703
for method in self.methods() {
2704-
assert!(method.kind() != MethodKind::Constructor);
2704+
assert_ne!(method.kind(), MethodKind::Constructor);
27052705
method.codegen_method(
27062706
ctx,
27072707
&mut methods,

bindgen/ir/context.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
782782
/// codegen'd, even if its parent is not allowlisted. See issue #769 for
783783
/// details.
784784
fn add_item_to_module(&mut self, item: &Item) {
785-
assert!(item.id() != self.root_module);
785+
assert_ne!(item.id(), self.root_module);
786786
assert!(self.resolve_item_fallible(item.id()).is_none());
787787

788788
if let Some(ref mut parent) = self.items[item.parent_id().0] {
@@ -804,7 +804,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
804804
self.current_module
805805
);
806806

807-
self.items[(self.current_module.0).0]
807+
self.items[self.current_module.0 .0]
808808
.as_mut()
809809
.expect("Should always have an item for self.current_module")
810810
.as_module_mut()
@@ -1232,7 +1232,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
12321232
&self,
12331233
) -> traversal::AssertNoDanglingItemsTraversal {
12341234
assert!(self.in_codegen_phase());
1235-
assert!(self.current_module == self.root_module);
1235+
assert_eq!(self.current_module, self.root_module);
12361236

12371237
let roots = self.items().map(|(id, _)| id);
12381238
traversal::AssertNoDanglingItemsTraversal::new(
@@ -1248,7 +1248,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
12481248
fn assert_every_item_in_a_module(&self) {
12491249
if cfg!(feature = "__testing_only_extra_assertions") {
12501250
assert!(self.in_codegen_phase());
1251-
assert!(self.current_module == self.root_module);
1251+
assert_eq!(self.current_module, self.root_module);
12521252

12531253
for (id, _item) in self.items() {
12541254
if id == self.root_module {
@@ -2346,7 +2346,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
23462346
/// allowlisted.
23472347
pub(crate) fn allowlisted_items(&self) -> &ItemSet {
23482348
assert!(self.in_codegen_phase());
2349-
assert!(self.current_module == self.root_module);
2349+
assert_eq!(self.current_module, self.root_module);
23502350

23512351
self.allowlisted.as_ref().unwrap()
23522352
}
@@ -2359,7 +2359,7 @@ If you encounter an error missing from this list, please file an issue or a PR!"
23592359
derive_trait: DeriveTrait,
23602360
) -> CanDerive {
23612361
assert!(self.in_codegen_phase());
2362-
assert!(self.current_module == self.root_module);
2362+
assert_eq!(self.current_module, self.root_module);
23632363

23642364
*self
23652365
.blocklisted_types_implement_traits
@@ -2407,14 +2407,14 @@ If you encounter an error missing from this list, please file an issue or a PR!"
24072407
/// Get a reference to the set of items we should generate.
24082408
pub(crate) fn codegen_items(&self) -> &ItemSet {
24092409
assert!(self.in_codegen_phase());
2410-
assert!(self.current_module == self.root_module);
2410+
assert_eq!(self.current_module, self.root_module);
24112411
self.codegen_items.as_ref().unwrap()
24122412
}
24132413

24142414
/// Compute the allowlisted items set and populate `self.allowlisted`.
24152415
fn compute_allowlisted_and_codegen_items(&mut self) {
24162416
assert!(self.in_codegen_phase());
2417-
assert!(self.current_module == self.root_module);
2417+
assert_eq!(self.current_module, self.root_module);
24182418
assert!(self.allowlisted.is_none());
24192419
let _t = self.timer("compute_allowlisted_and_codegen_items");
24202420

bindgen/ir/objc.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,7 @@ impl ObjCMethod {
294294
}
295295

296296
// Check right amount of arguments
297-
assert!(
298-
args.len() == split_name.len() - 1,
299-
"Incorrect method name or arguments for objc method, {args:?} vs {split_name:?}"
300-
);
297+
assert_eq!(args.len(), split_name.len() - 1, "Incorrect method name or arguments for objc method, {args:?} vs {split_name:?}");
301298

302299
// Get arguments without type signatures to pass to `msg_send!`
303300
let mut args_without_types = vec![];

bindgen/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1144,8 +1144,9 @@ fn parse(context: &mut BindgenContext) -> Result<(), BindgenError> {
11441144
cursor.visit_sorted(ctx, |ctx, child| parse_one(ctx, child, None));
11451145
});
11461146

1147-
assert!(
1148-
context.current_module() == context.root_module(),
1147+
assert_eq!(
1148+
context.current_module(),
1149+
context.root_module(),
11491150
"How did this happen?"
11501151
);
11511152
Ok(())

0 commit comments

Comments
 (0)