Skip to content

Commit

Permalink
Merge pull request mozilla#1084 from bendk/clippy-and-test-fixes
Browse files Browse the repository at this point in the history
Clippy and test fixes
  • Loading branch information
bendk authored Oct 28, 2021
2 parents cdeb4ea + 708d0e6 commit 78c5f66
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 24 deletions.
8 changes: 6 additions & 2 deletions fixtures/uitests/tests/ui/interface_not_sync_and_send.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ error[E0277]: `Cell<u32>` cannot be shared between threads safely
| required by this bound in `assert_impl_all`
|
= help: within `Counter`, the trait `Sync` is not implemented for `Cell<u32>`
= note: required because it appears within the type `Counter`
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
note: required because it appears within the type `Counter`
--> $DIR/interface_not_sync_and_send.rs:9:12
|
9 | pub struct Counter {
| ^^^^^^^
= note: this error originates in the macro `uniffi::deps::static_assertions::assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `Arc<Counter>: FfiConverter` is not satisfied
--> $DIR/counter.uniffi.rs:145:9
Expand Down
2 changes: 1 addition & 1 deletion uniffi/tests/ui/version_mismatch.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ error[E0080]: evaluation of constant value failed
2 | uniffi::assert_compatible_version!("0.0.1"); // An error message would go here.
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `uniffi::deps::static_assertions::const_assert` (in Nightly builds, run with -Z macro-backtrace for more info)
6 changes: 3 additions & 3 deletions uniffi_bindgen/src/bindings/kotlin/gen_kotlin/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ fn render_literal(_oracle: &dyn CodeOracle, literal: &Literal) -> String {
Literal::Boolean(v) => format!("{}", v),
Literal::String(s) => format!("\"{}\"", s),
Literal::Int(i, radix, type_) => typed_number(
&type_,
type_,
match radix {
Radix::Octal => format!("{:#x}", i),
Radix::Decimal => format!("{}", i),
Radix::Hexadecimal => format!("{:#x}", i),
},
),
Literal::UInt(i, radix, type_) => typed_number(
&type_,
type_,
match radix {
Radix::Octal => format!("{:#x}", i),
Radix::Decimal => format!("{}", i),
Radix::Hexadecimal => format!("{:#x}", i),
},
),
Literal::Float(string, type_) => typed_number(&type_, string.clone()),
Literal::Float(string, type_) => typed_number(type_, string.clone()),

_ => unreachable!("Literal"),
}
Expand Down
28 changes: 11 additions & 17 deletions uniffi_bindgen/src/interface/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,19 +660,13 @@ impl<'a> RecursiveTypeIterator<'a> {
// to a non-existent type, we just leave the existing iterator in place and allow the recursive
// call to `next()` to try again with the next pending type.
let next_iter = match next_type {
Type::Record(nm) => self
.ci
.get_record_definition(&nm)
.map(IterTypes::iter_types),
Type::Enum(nm) => self.ci.get_enum_definition(&nm).map(IterTypes::iter_types),
Type::Error(nm) => self.ci.get_error_definition(&nm).map(IterTypes::iter_types),
Type::Object(nm) => self
.ci
.get_object_definition(&nm)
.map(IterTypes::iter_types),
Type::Record(nm) => self.ci.get_record_definition(nm).map(IterTypes::iter_types),
Type::Enum(nm) => self.ci.get_enum_definition(nm).map(IterTypes::iter_types),
Type::Error(nm) => self.ci.get_error_definition(nm).map(IterTypes::iter_types),
Type::Object(nm) => self.ci.get_object_definition(nm).map(IterTypes::iter_types),
Type::CallbackInterface(nm) => self
.ci
.get_callback_interface_definition(&nm)
.get_callback_interface_definition(nm)
.map(IterTypes::iter_types),
_ => None,
};
Expand Down Expand Up @@ -922,14 +916,14 @@ mod test {
};

// check that `contains_optional_types` returns false when there is no Optional type in the interface
assert_eq!(ci.contains_optional_types(), false);
assert!(!ci.contains_optional_types());

// check that `contains_optional_types` returns true when there is an Optional type in the interface
assert!(ci
.types
.add_type_definition("TestOptional{}", Type::Optional(Box::new(Type::String)))
.is_ok());
assert_eq!(ci.contains_optional_types(), true);
assert!(ci.contains_optional_types());
}

#[test]
Expand All @@ -939,14 +933,14 @@ mod test {
};

// check that `contains_sequence_types` returns false when there is no Sequence type in the interface
assert_eq!(ci.contains_sequence_types(), false);
assert!(!ci.contains_sequence_types());

// check that `contains_sequence_types` returns true when there is a Sequence type in the interface
assert!(ci
.types
.add_type_definition("TestSequence{}", Type::Sequence(Box::new(Type::UInt64)))
.is_ok());
assert_eq!(ci.contains_sequence_types(), true);
assert!(ci.contains_sequence_types());
}

#[test]
Expand All @@ -956,14 +950,14 @@ mod test {
};

// check that `contains_map_types` returns false when there is no Map type in the interface
assert_eq!(ci.contains_map_types(), false);
assert!(!ci.contains_map_types());

// check that `contains_map_types` returns true when there is a Map type in the interface
assert!(ci
.types
.add_type_definition("Map{}", Type::Map(Box::new(Type::Boolean)))
.is_ok());
assert_eq!(ci.contains_map_types(), true);
assert!(ci.contains_map_types());
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion uniffi_bindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub fn generate_bindings<P: AsRef<Path>>(
guess_crate_root(udl_file)?,
config_file_override,
)?;
let out_dir = get_out_dir(&udl_file, out_dir_override)?;
let out_dir = get_out_dir(udl_file, out_dir_override)?;
for language in target_languages {
bindings::write_bindings(
&config.bindings,
Expand Down

0 comments on commit 78c5f66

Please sign in to comment.