summaryrefslogtreecommitdiffstats
path: root/third_party/rust/uniffi/tests
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/uniffi/tests')
-rw-r--r--third_party/rust/uniffi/tests/ui/proc_macro_arc.rs24
-rw-r--r--third_party/rust/uniffi/tests/ui/proc_macro_arc.stderr22
-rw-r--r--third_party/rust/uniffi/tests/ui/version_mismatch.rs4
-rw-r--r--third_party/rust/uniffi/tests/ui/version_mismatch.stderr7
4 files changed, 57 insertions, 0 deletions
diff --git a/third_party/rust/uniffi/tests/ui/proc_macro_arc.rs b/third_party/rust/uniffi/tests/ui/proc_macro_arc.rs
new file mode 100644
index 0000000000..9db3376594
--- /dev/null
+++ b/third_party/rust/uniffi/tests/ui/proc_macro_arc.rs
@@ -0,0 +1,24 @@
+use std::sync::Arc;
+
+fn main() {}
+
+// Normally this is defined by the scaffolding code, manually define it for the UI test
+pub struct UniFfiTag;
+
+pub struct Foo;
+
+#[uniffi::export]
+fn make_foo() -> Arc<Foo> {
+ Arc::new(Foo)
+}
+
+mod child {
+ use std::sync::Arc;
+
+ enum Foo {}
+
+ #[uniffi::export]
+ fn take_foo(foo: Arc<Foo>) {
+ match &*foo {}
+ }
+}
diff --git a/third_party/rust/uniffi/tests/ui/proc_macro_arc.stderr b/third_party/rust/uniffi/tests/ui/proc_macro_arc.stderr
new file mode 100644
index 0000000000..0654a29e25
--- /dev/null
+++ b/third_party/rust/uniffi/tests/ui/proc_macro_arc.stderr
@@ -0,0 +1,22 @@
+error[E0277]: the trait bound `Foo: FfiConverterArc<UniFfiTag>` is not satisfied
+ --> tests/ui/proc_macro_arc.rs:10:1
+ |
+10 | #[uniffi::export]
+ | ^^^^^^^^^^^^^^^^^ the trait `FfiConverterArc<UniFfiTag>` is not implemented for `Foo`
+ |
+ = help: the trait `LowerReturn<UT>` is implemented for `Arc<T>`
+ = note: required for `Arc<Foo>` to implement `FfiConverter<UniFfiTag>`
+ = note: required for `Arc<Foo>` to implement `Lower<UniFfiTag>`
+ = note: required for `Arc<Foo>` to implement `LowerReturn<UniFfiTag>`
+ = 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 `child::Foo: FfiConverterArc<UniFfiTag>` is not satisfied
+ --> tests/ui/proc_macro_arc.rs:20:5
+ |
+20 | #[uniffi::export]
+ | ^^^^^^^^^^^^^^^^^ the trait `FfiConverterArc<UniFfiTag>` is not implemented for `child::Foo`
+ |
+ = help: the trait `Lift<UT>` is implemented for `Arc<T>`
+ = note: required for `Arc<child::Foo>` to implement `FfiConverter<UniFfiTag>`
+ = note: required for `Arc<child::Foo>` to implement `Lift<UniFfiTag>`
+ = note: this error originates in the attribute macro `uniffi::export` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/third_party/rust/uniffi/tests/ui/version_mismatch.rs b/third_party/rust/uniffi/tests/ui/version_mismatch.rs
new file mode 100644
index 0000000000..6a7edb891d
--- /dev/null
+++ b/third_party/rust/uniffi/tests/ui/version_mismatch.rs
@@ -0,0 +1,4 @@
+// This should fail with a version mismatch.
+uniffi::assert_compatible_version!("0.0.1"); // An error message would go here.
+
+fn main() {}
diff --git a/third_party/rust/uniffi/tests/ui/version_mismatch.stderr b/third_party/rust/uniffi/tests/ui/version_mismatch.stderr
new file mode 100644
index 0000000000..bc30714099
--- /dev/null
+++ b/third_party/rust/uniffi/tests/ui/version_mismatch.stderr
@@ -0,0 +1,7 @@
+error[E0080]: evaluation of constant value failed
+ --> tests/ui/version_mismatch.rs:2:1
+ |
+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 the macro `uniffi::deps::static_assertions::const_assert` which comes from the expansion of the macro `uniffi::assert_compatible_version` (in Nightly builds, run with -Z macro-backtrace for more info)