diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /third_party/rust/uniffi/tests/ui | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/uniffi/tests/ui')
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) |