-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the proc-macro FfiConverter impls canonical
* Split out the proc-macro code to generate `FfiConverter` implementations and added standalone macros for that. * Removed the `FfiConverter` implementations from the Askama template code. Instead, the templates now invoke the macros. * Removed the blanket `Arc<T>` impl from `uniffi_core` and made it so we invoke a macro for each interface. The reason for this is: * I want to add some more functionality to `FfiConverter`, but don't want to implement it twice and test it two different ways. * Removing the blanket `Arc<T>` implementation allows us to customize the `FfiConverter` code for each interface. I think this makes #1457 easier. * Everything goes through one code path, which should give us some more confidence as we migrate to proc-macros. This change caused me to fix some bugs and add some features to them.
- Loading branch information
Showing
14 changed files
with
289 additions
and
298 deletions.
There are no files selected for viewing
24 changes: 13 additions & 11 deletions
24
fixtures/uitests/tests/ui/fieldless_errors_used_in_callbacks_cant_have_fields.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
error[E0063]: missing field `numerator` in initializer of `ArithmeticError` | ||
--> $OUT_DIR[uniffi_uitests]/errors.uniffi.rs | ||
| | ||
| 2 => r#ArithmeticError::r#DivisionByZero{ }, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `numerator` | ||
|
||
error[E0063]: missing field `0` in initializer of `ArithmeticError` | ||
--> $OUT_DIR[uniffi_uitests]/errors.uniffi.rs | ||
| | ||
| 3 => r#ArithmeticError::r#UnexpectedError{ }, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `0` | ||
error[E0533]: expected unit struct, unit variant or constant, found struct variant `Self::DivisionByZero` | ||
--> $OUT_DIR[uniffi_uitests]/errors.uniffi.rs | ||
| | ||
| / ::uniffi::ffi_converter_flat_error_with_read!( | ||
| | r#ArithmeticError | ||
| | { | ||
| | r#IntegerOverflow { | ||
... | | ||
| | } | ||
| | ); | ||
| |_^ | ||
| | ||
= note: this error originates in the macro `::uniffi::ffi_converter_flat_error_with_read` (in Nightly builds, run with -Z macro-backtrace for more info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,35 @@ | ||
error[E0271]: type mismatch resolving `<Arc<child::Foo> as child::_::_::{closure#0}::TypeEq>::This == Arc<Foo>` | ||
--> tests/ui/proc_macro_arc.rs:21:22 | ||
error[E0277]: the trait bound `Arc<Foo>: FfiConverter<UniFfiTag>` is not satisfied | ||
--> tests/ui/proc_macro_arc.rs:10:1 | ||
| | ||
21 | fn take_foo(foo: Arc<Foo>) { | ||
| ^^^^^^^^ type mismatch resolving `<Arc<child::Foo> as child::_::_::{closure#0}::TypeEq>::This == Arc<Foo>` | ||
10 | #[uniffi::export] | ||
| ^^^^^^^^^^^^^^^^^ the trait `FfiConverter<UniFfiTag>` is not implemented for `Arc<Foo>` | ||
| | ||
note: expected this to be `Arc<Foo>` | ||
--> tests/ui/proc_macro_arc.rs:21:22 | ||
= help: the following other types implement trait `FfiConverter<UT>`: | ||
() | ||
Duration | ||
HashMap<K, V> | ||
Option<T> | ||
String | ||
SystemTime | ||
Vec<T> | ||
bool | ||
and $N others | ||
= note: this error originates in the attribute macro `uniffi::export` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error[E0277]: the trait bound `Arc<child::Foo>: FfiConverter<UniFfiTag>` is not satisfied | ||
--> tests/ui/proc_macro_arc.rs:20:5 | ||
| | ||
21 | fn take_foo(foo: Arc<Foo>) { | ||
| ^^^ | ||
= note: enum `child::Foo` and struct `Foo` have similar names, but are actually distinct types | ||
note: enum `child::Foo` is defined in module `crate::child` of the current crate | ||
--> tests/ui/proc_macro_arc.rs:18:5 | ||
20 | #[uniffi::export] | ||
| ^^^^^^^^^^^^^^^^^ the trait `FfiConverter<UniFfiTag>` is not implemented for `Arc<child::Foo>` | ||
| | ||
18 | enum Foo {} | ||
| ^^^^^^^^ | ||
note: struct `Foo` is defined in module `crate` of the current crate | ||
--> tests/ui/proc_macro_arc.rs:8:1 | ||
| | ||
8 | pub struct Foo; | ||
| ^^^^^^^^^^^^^^ | ||
note: required by a bound in `child::_::_::{closure#0}::assert_type_eq_all` | ||
--> tests/ui/proc_macro_arc.rs:21:22 | ||
| | ||
21 | fn take_foo(foo: Arc<Foo>) { | ||
| ^^^ | ||
| | | ||
| required by a bound in this | ||
| required by this bound in `child::_::_::{closure#0}::assert_type_eq_all` | ||
= note: this error originates in the macro `::uniffi::deps::static_assertions::assert_type_eq_all` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
= help: the following other types implement trait `FfiConverter<UT>`: | ||
() | ||
Duration | ||
HashMap<K, V> | ||
Option<T> | ||
String | ||
SystemTime | ||
Vec<T> | ||
bool | ||
and $N others | ||
= note: this error originates in the attribute macro `uniffi::export` (in Nightly builds, run with -Z macro-backtrace for more info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.