From d2bc80c323328f8131b765958508530cc8b9bf20 Mon Sep 17 00:00:00 2001 From: Bryan Henry Date: Fri, 2 Oct 2020 13:53:53 -0700 Subject: [PATCH] Add ui tests for missing UniquePtr and CxxVector impls with aliases --- tests/ui/alias_missing_cxx_vector_impl.rs | 27 +++++++++++++++++++ tests/ui/alias_missing_cxx_vector_impl.stderr | 25 +++++++++++++++++ tests/ui/alias_missing_unique_ptr_impl.rs | 27 +++++++++++++++++++ tests/ui/alias_missing_unique_ptr_impl.stderr | 21 +++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 tests/ui/alias_missing_cxx_vector_impl.rs create mode 100644 tests/ui/alias_missing_cxx_vector_impl.stderr create mode 100644 tests/ui/alias_missing_unique_ptr_impl.rs create mode 100644 tests/ui/alias_missing_unique_ptr_impl.stderr diff --git a/tests/ui/alias_missing_cxx_vector_impl.rs b/tests/ui/alias_missing_cxx_vector_impl.rs new file mode 100644 index 000000000..f11fd3309 --- /dev/null +++ b/tests/ui/alias_missing_cxx_vector_impl.rs @@ -0,0 +1,27 @@ +#[cxx::bridge] +mod here { + struct Shared { + z: usize, + } + + extern "C" { + type C; + } +} + +// Rustfmt mangles the extern type alias. +// https://github.com/rust-lang/rustfmt/issues/4159 +#[rustfmt::skip] +#[cxx::bridge] +mod there { + type Shared = crate::here::Shared; + + extern "C" { + type C = crate::here::C; + + fn c_take_unique_ptr_vector(s: UniquePtr>); + fn c_take_unique_ptr_vector_shared(s: UniquePtr>); + } +} + +fn main() {} diff --git a/tests/ui/alias_missing_cxx_vector_impl.stderr b/tests/ui/alias_missing_cxx_vector_impl.stderr new file mode 100644 index 000000000..b13eb182f --- /dev/null +++ b/tests/ui/alias_missing_cxx_vector_impl.stderr @@ -0,0 +1,25 @@ +error[E0277]: the trait bound `here::C: VectorElement` is not satisfied + --> $DIR/alias_missing_cxx_vector_impl.rs:15:1 + | +15 | #[cxx::bridge] + | ^^^^^^^^^^^^^^ the trait `VectorElement` is not implemented for `here::C` + | + ::: $WORKSPACE/src/unique_ptr.rs + | + | T: UniquePtrTarget, + | --------------- required by this bound in `UniquePtr` + | + = note: required because of the requirements on the impl of `UniquePtrTarget` for `CxxVector` + +error[E0277]: the trait bound `here::Shared: VectorElement` is not satisfied + --> $DIR/alias_missing_cxx_vector_impl.rs:15:1 + | +15 | #[cxx::bridge] + | ^^^^^^^^^^^^^^ the trait `VectorElement` is not implemented for `here::Shared` + | + ::: $WORKSPACE/src/unique_ptr.rs + | + | T: UniquePtrTarget, + | --------------- required by this bound in `UniquePtr` + | + = note: required because of the requirements on the impl of `UniquePtrTarget` for `CxxVector` diff --git a/tests/ui/alias_missing_unique_ptr_impl.rs b/tests/ui/alias_missing_unique_ptr_impl.rs new file mode 100644 index 000000000..dd3cab9ee --- /dev/null +++ b/tests/ui/alias_missing_unique_ptr_impl.rs @@ -0,0 +1,27 @@ +#[cxx::bridge] +mod here { + struct Shared { + z: usize, + } + + extern "C" { + type C; + } +} + +// Rustfmt mangles the extern type alias. +// https://github.com/rust-lang/rustfmt/issues/4159 +#[rustfmt::skip] +#[cxx::bridge] +mod there { + type Shared = crate::here::Shared; + + extern "C" { + type C = crate::here::C; + + fn c_take_unique_ptr(s: UniquePtr); + fn c_take_unique_ptr_shared(s: UniquePtr); + } +} + +fn main() {} diff --git a/tests/ui/alias_missing_unique_ptr_impl.stderr b/tests/ui/alias_missing_unique_ptr_impl.stderr new file mode 100644 index 000000000..b5497d362 --- /dev/null +++ b/tests/ui/alias_missing_unique_ptr_impl.stderr @@ -0,0 +1,21 @@ +error[E0277]: the trait bound `here::C: UniquePtrTarget` is not satisfied + --> $DIR/alias_missing_unique_ptr_impl.rs:15:1 + | +15 | #[cxx::bridge] + | ^^^^^^^^^^^^^^ the trait `UniquePtrTarget` is not implemented for `here::C` + | + ::: $WORKSPACE/src/unique_ptr.rs + | + | T: UniquePtrTarget, + | --------------- required by this bound in `UniquePtr` + +error[E0277]: the trait bound `here::Shared: UniquePtrTarget` is not satisfied + --> $DIR/alias_missing_unique_ptr_impl.rs:15:1 + | +15 | #[cxx::bridge] + | ^^^^^^^^^^^^^^ the trait `UniquePtrTarget` is not implemented for `here::Shared` + | + ::: $WORKSPACE/src/unique_ptr.rs + | + | T: UniquePtrTarget, + | --------------- required by this bound in `UniquePtr`