summaryrefslogtreecommitdiffstats
path: root/third_party/rust/uniffi/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/uniffi/tests
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/uniffi/tests')
-rw-r--r--third_party/rust/uniffi/tests/ui/proc_macro_arc.rs25
-rw-r--r--third_party/rust/uniffi/tests/ui/proc_macro_arc.stderr31
-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, 67 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..bdffc020e0
--- /dev/null
+++ b/third_party/rust/uniffi/tests/ui/proc_macro_arc.rs
@@ -0,0 +1,25 @@
+use std::sync::Arc;
+
+fn main() {}
+
+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 {}
+ }
+}
+
+mod uniffi_types {
+ pub use super::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..9e89f7bccf
--- /dev/null
+++ b/third_party/rust/uniffi/tests/ui/proc_macro_arc.stderr
@@ -0,0 +1,31 @@
+error[E0271]: type mismatch resolving `<Arc<child::Foo> as child::_::_::{closure#0}::TypeEq>::This == Arc<Foo>`
+ --> tests/ui/proc_macro_arc.rs:18:22
+ |
+18 | fn take_foo(foo: Arc<Foo>) {
+ | ^^^^^^^^ type mismatch resolving `<Arc<child::Foo> as child::_::_::{closure#0}::TypeEq>::This == Arc<Foo>`
+ |
+note: expected this to be `Arc<Foo>`
+ --> tests/ui/proc_macro_arc.rs:18:22
+ |
+18 | 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:15:5
+ |
+15 | enum Foo {}
+ | ^^^^^^^^
+note: struct `Foo` is defined in module `crate` of the current crate
+ --> tests/ui/proc_macro_arc.rs:5:1
+ |
+5 | pub struct Foo;
+ | ^^^^^^^^^^^^^^
+note: required by a bound in `child::_::_::{closure#0}::assert_type_eq_all`
+ --> tests/ui/proc_macro_arc.rs:18:22
+ |
+18 | 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)
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)