Vendor dependencies

Let's see how I like this workflow.
This commit is contained in:
John Doty 2022-12-19 08:27:18 -08:00
parent 34d1830413
commit 9c435dc440
7500 changed files with 1665121 additions and 99 deletions

57
vendor/cxx/tests/BUCK vendored Normal file
View file

@ -0,0 +1,57 @@
load("//tools/buck:rust_cxx_bridge.bzl", "rust_cxx_bridge")
rust_test(
name = "test",
srcs = ["test.rs"],
edition = "2018",
deps = [
":ffi",
"//:cxx",
],
)
rust_library(
name = "ffi",
srcs = [
"ffi/cast.rs",
"ffi/lib.rs",
"ffi/module.rs",
],
crate = "cxx_test_suite",
edition = "2018",
deps = [
":impl",
"//:cxx",
],
)
cxx_library(
name = "impl",
srcs = [
"ffi/tests.cc",
":bridge/source",
":module/source",
],
exported_deps = ["//:core"],
exported_headers = {
"ffi/lib.rs.h": ":bridge/header",
"ffi/module.rs.h": ":module/header",
"ffi/tests.h": "ffi/tests.h",
},
)
rust_cxx_bridge(
name = "bridge",
src = "ffi/lib.rs",
deps = [
":impl",
],
)
rust_cxx_bridge(
name = "module",
src = "ffi/module.rs",
deps = [
":impl",
],
)

55
vendor/cxx/tests/BUILD vendored Normal file
View file

@ -0,0 +1,55 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
load("//tools/bazel:rust_cxx_bridge.bzl", "rust_cxx_bridge")
rust_test(
name = "test",
size = "small",
srcs = ["test.rs"],
edition = "2018",
deps = [
":cxx_test_suite",
"//:cxx",
],
)
rust_library(
name = "cxx_test_suite",
srcs = [
"ffi/cast.rs",
"ffi/lib.rs",
"ffi/module.rs",
],
edition = "2018",
deps = [
":impl",
"//:cxx",
],
)
cc_library(
name = "impl",
srcs = [
"ffi/tests.cc",
":bridge/source",
":module/source",
],
hdrs = ["ffi/tests.h"],
deps = [
":bridge/include",
":module/include",
"//:core",
],
)
rust_cxx_bridge(
name = "bridge",
src = "ffi/lib.rs",
deps = [":impl"],
)
rust_cxx_bridge(
name = "module",
src = "ffi/module.rs",
deps = [":impl"],
)

9
vendor/cxx/tests/compiletest.rs vendored Normal file
View file

@ -0,0 +1,9 @@
#[allow(unused_attributes)]
#[rustversion::attr(not(nightly), ignore)]
#[cfg_attr(skip_ui_tests, ignore)]
#[cfg_attr(miri, ignore)]
#[test]
fn ui() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/*.rs");
}

34
vendor/cxx/tests/cxx_gen.rs vendored Normal file
View file

@ -0,0 +1,34 @@
#![allow(clippy::field_reassign_with_default)]
use cxx_gen::{generate_header_and_cc, Opt};
use std::str;
const BRIDGE0: &str = r#"
#[cxx::bridge]
mod ffi {
unsafe extern "C++" {
pub fn do_cpp_thing(foo: &str);
}
}
"#;
#[test]
fn test_extern_c_function() {
let opt = Opt::default();
let source = BRIDGE0.parse().unwrap();
let generated = generate_header_and_cc(source, &opt).unwrap();
let output = str::from_utf8(&generated.implementation).unwrap();
// To avoid continual breakage we won't test every byte.
// Let's look for the major features.
assert!(output.contains("void cxxbridge1$do_cpp_thing(::rust::Str foo)"));
}
#[test]
fn test_impl_annotation() {
let mut opt = Opt::default();
opt.cxx_impl_annotations = Some("ANNOTATION".to_owned());
let source = BRIDGE0.parse().unwrap();
let generated = generate_header_and_cc(source, &opt).unwrap();
let output = str::from_utf8(&generated.implementation).unwrap();
assert!(output.contains("ANNOTATION void cxxbridge1$do_cpp_thing(::rust::Str foo)"));
}

15
vendor/cxx/tests/cxx_string.rs vendored Normal file
View file

@ -0,0 +1,15 @@
use cxx::{let_cxx_string, CxxString};
#[test]
fn test_async_cxx_string() {
async fn f() {
let_cxx_string!(s = "...");
async fn g(_: &CxxString) {}
g(&s).await;
}
// https://github.com/dtolnay/cxx/issues/693
fn assert_send(_: impl Send) {}
assert_send(f());
}

380
vendor/cxx/tests/test.rs vendored Normal file
View file

@ -0,0 +1,380 @@
#![allow(
clippy::assertions_on_constants,
clippy::assertions_on_result_states,
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::float_cmp,
clippy::needless_pass_by_value,
clippy::unit_cmp,
clippy::unseparated_literal_suffix
)]
use cxx::SharedPtr;
use cxx_test_suite::module::ffi2;
use cxx_test_suite::{cast, ffi, R};
use std::cell::Cell;
use std::ffi::CStr;
thread_local! {
static CORRECT: Cell<bool> = Cell::new(false);
}
#[no_mangle]
extern "C" fn cxx_test_suite_set_correct() {
CORRECT.with(|correct| correct.set(true));
}
macro_rules! check {
($run:expr) => {{
CORRECT.with(|correct| correct.set(false));
$run;
assert!(CORRECT.with(Cell::get), "{}", stringify!($run));
}};
}
#[test]
fn test_c_return() {
let shared = ffi::Shared { z: 2020 };
let ns_shared = ffi::AShared { z: 2020 };
let nested_ns_shared = ffi::ABShared { z: 2020 };
assert_eq!(2020, ffi::c_return_primitive());
assert_eq!(2020, ffi::c_return_shared().z);
assert_eq!(2020, ffi::c_return_box().0);
ffi::c_return_unique_ptr();
ffi2::c_return_ns_unique_ptr();
assert_eq!(2020, *ffi::c_return_ref(&shared));
assert_eq!(2020, *ffi::c_return_ns_ref(&ns_shared));
assert_eq!(2020, *ffi::c_return_nested_ns_ref(&nested_ns_shared));
assert_eq!("2020", ffi::c_return_str(&shared));
assert_eq!(
b"2020\0",
cast::c_char_to_unsigned(ffi::c_return_slice_char(&shared)),
);
assert_eq!("2020", ffi::c_return_rust_string());
assert_eq!("Hello \u{fffd}World", ffi::c_return_rust_string_lossy());
assert_eq!("2020", ffi::c_return_unique_ptr_string().to_str().unwrap());
assert_eq!(4, ffi::c_return_unique_ptr_vector_u8().len());
assert_eq!(
200_u8,
ffi::c_return_unique_ptr_vector_u8().into_iter().sum(),
);
assert_eq!(
200.5_f64,
ffi::c_return_unique_ptr_vector_f64().into_iter().sum(),
);
assert_eq!(2, ffi::c_return_unique_ptr_vector_shared().len());
assert_eq!(
2021_usize,
ffi::c_return_unique_ptr_vector_shared()
.into_iter()
.map(|o| o.z)
.sum(),
);
assert_eq!(b"\x02\0\x02\0"[..], ffi::c_return_rust_vec_u8());
assert_eq!([true, true, false][..], ffi::c_return_rust_vec_bool());
assert_eq!(2020, ffi::c_return_identity(2020));
assert_eq!(2021, ffi::c_return_sum(2020, 1));
match ffi::c_return_enum(0) {
enm @ ffi::Enum::AVal => assert_eq!(0, enm.repr),
_ => assert!(false),
}
match ffi::c_return_enum(1) {
enm @ ffi::Enum::BVal => assert_eq!(2020, enm.repr),
_ => assert!(false),
}
match ffi::c_return_enum(2021) {
enm @ ffi::Enum::LastVal => assert_eq!(2021, enm.repr),
_ => assert!(false),
}
match ffi::c_return_ns_enum(0) {
enm @ ffi::AEnum::AAVal => assert_eq!(0, enm.repr),
_ => assert!(false),
}
match ffi::c_return_nested_ns_enum(0) {
enm @ ffi::ABEnum::ABAVal => assert_eq!(0, enm.repr),
_ => assert!(false),
}
}
#[test]
fn test_c_try_return() {
assert_eq!((), ffi::c_try_return_void().unwrap());
assert_eq!(2020, ffi::c_try_return_primitive().unwrap());
assert_eq!(
"logic error",
ffi::c_fail_return_primitive().unwrap_err().what(),
);
assert_eq!(2020, ffi::c_try_return_box().unwrap().0);
assert_eq!("2020", *ffi::c_try_return_ref(&"2020".to_owned()).unwrap());
assert_eq!("2020", ffi::c_try_return_str("2020").unwrap());
assert_eq!(b"2020", ffi::c_try_return_sliceu8(b"2020").unwrap());
assert_eq!("2020", ffi::c_try_return_rust_string().unwrap());
assert_eq!("2020", &*ffi::c_try_return_unique_ptr_string().unwrap());
}
#[test]
fn test_c_take() {
let unique_ptr = ffi::c_return_unique_ptr();
let unique_ptr_ns = ffi2::c_return_ns_unique_ptr();
check!(ffi::c_take_primitive(2020));
check!(ffi::c_take_shared(ffi::Shared { z: 2020 }));
check!(ffi::c_take_ns_shared(ffi::AShared { z: 2020 }));
check!(ffi::ns_c_take_ns_shared(ffi::AShared { z: 2020 }));
check!(ffi::c_take_nested_ns_shared(ffi::ABShared { z: 2020 }));
check!(ffi::c_take_box(Box::new(R(2020))));
check!(ffi::c_take_ref_c(&unique_ptr));
check!(ffi2::c_take_ref_ns_c(&unique_ptr_ns));
check!(cxx_test_suite::module::ffi::c_take_unique_ptr(unique_ptr));
check!(ffi::c_take_str("2020"));
check!(ffi::c_take_slice_char(cast::unsigned_to_c_char(b"2020")));
check!(ffi::c_take_slice_shared(&[
ffi::Shared { z: 2020 },
ffi::Shared { z: 2021 },
]));
let shared_sort_slice = &mut [
ffi::Shared { z: 2 },
ffi::Shared { z: 0 },
ffi::Shared { z: 7 },
ffi::Shared { z: 4 },
];
check!(ffi::c_take_slice_shared_sort(shared_sort_slice));
assert_eq!(shared_sort_slice[0].z, 0);
assert_eq!(shared_sort_slice[1].z, 2);
assert_eq!(shared_sort_slice[2].z, 4);
assert_eq!(shared_sort_slice[3].z, 7);
let r_sort_slice = &mut [R(2020), R(2050), R(2021)];
check!(ffi::c_take_slice_r(r_sort_slice));
check!(ffi::c_take_slice_r_sort(r_sort_slice));
assert_eq!(r_sort_slice[0].0, 2020);
assert_eq!(r_sort_slice[1].0, 2021);
assert_eq!(r_sort_slice[2].0, 2050);
check!(ffi::c_take_rust_string("2020".to_owned()));
check!(ffi::c_take_unique_ptr_string(
ffi::c_return_unique_ptr_string()
));
let mut vector = ffi::c_return_unique_ptr_vector_u8();
assert_eq!(vector.pin_mut().pop(), Some(9));
check!(ffi::c_take_unique_ptr_vector_u8(vector));
let mut vector = ffi::c_return_unique_ptr_vector_f64();
vector.pin_mut().push(9.0);
check!(ffi::c_take_unique_ptr_vector_f64(vector));
let mut vector = ffi::c_return_unique_ptr_vector_shared();
vector.pin_mut().push(ffi::Shared { z: 9 });
check!(ffi::c_take_unique_ptr_vector_shared(vector));
check!(ffi::c_take_ref_vector(&ffi::c_return_unique_ptr_vector_u8()));
let test_vec = [86_u8, 75_u8, 30_u8, 9_u8].to_vec();
check!(ffi::c_take_rust_vec(test_vec.clone()));
check!(ffi::c_take_rust_vec_index(test_vec.clone()));
let shared_test_vec = vec![ffi::Shared { z: 1010 }, ffi::Shared { z: 1011 }];
check!(ffi::c_take_rust_vec_shared(shared_test_vec.clone()));
check!(ffi::c_take_rust_vec_shared_index(shared_test_vec.clone()));
check!(ffi::c_take_rust_vec_shared_push(shared_test_vec.clone()));
check!(ffi::c_take_rust_vec_shared_truncate(
shared_test_vec.clone()
));
check!(ffi::c_take_rust_vec_shared_clear(shared_test_vec.clone()));
check!(ffi::c_take_rust_vec_shared_forward_iterator(
shared_test_vec,
));
let shared_sort_vec = vec![
ffi::Shared { z: 2 },
ffi::Shared { z: 0 },
ffi::Shared { z: 7 },
ffi::Shared { z: 4 },
];
check!(ffi::c_take_rust_vec_shared_sort(shared_sort_vec));
check!(ffi::c_take_ref_rust_vec(&test_vec));
check!(ffi::c_take_ref_rust_vec_index(&test_vec));
check!(ffi::c_take_ref_rust_vec_copy(&test_vec));
check!(ffi::c_take_ref_shared_string(&ffi::SharedString {
msg: "2020".to_owned()
}));
let ns_shared_test_vec = vec![ffi::AShared { z: 1010 }, ffi::AShared { z: 1011 }];
check!(ffi::c_take_rust_vec_ns_shared(ns_shared_test_vec));
let nested_ns_shared_test_vec = vec![ffi::ABShared { z: 1010 }, ffi::ABShared { z: 1011 }];
check!(ffi::c_take_rust_vec_nested_ns_shared(
nested_ns_shared_test_vec
));
check!(ffi::c_take_enum(ffi::Enum::AVal));
check!(ffi::c_take_ns_enum(ffi::AEnum::AAVal));
check!(ffi::c_take_nested_ns_enum(ffi::ABEnum::ABAVal));
}
#[test]
fn test_c_callback() {
fn callback(s: String) -> usize {
if s == "2020" {
cxx_test_suite_set_correct();
}
0
}
#[allow(clippy::ptr_arg)]
fn callback_ref(s: &String) {
if s == "2020" {
cxx_test_suite_set_correct();
}
}
fn callback_mut(s: &mut String) {
if s == "2020" {
cxx_test_suite_set_correct();
}
}
check!(ffi::c_take_callback(callback));
check!(ffi::c_take_callback_ref(callback_ref));
check!(ffi::c_take_callback_ref_lifetime(callback_ref));
check!(ffi::c_take_callback_mut(callback_mut));
}
#[test]
fn test_c_call_r() {
fn cxx_run_test() {
extern "C" {
fn cxx_run_test() -> *const i8;
}
let failure = unsafe { cxx_run_test() };
if !failure.is_null() {
let msg = unsafe { CStr::from_ptr(failure as *mut std::os::raw::c_char) };
eprintln!("{}", msg.to_string_lossy());
}
}
check!(cxx_run_test());
}
#[test]
fn test_c_method_calls() {
let mut unique_ptr = ffi::c_return_unique_ptr();
let old_value = unique_ptr.get();
assert_eq!(2020, old_value);
assert_eq!(2021, unique_ptr.pin_mut().set(2021));
assert_eq!(2021, unique_ptr.get());
assert_eq!(2021, unique_ptr.get2());
assert_eq!(2021, *unique_ptr.getRef());
assert_eq!(2021, *unique_ptr.pin_mut().getMut());
assert_eq!(2022, unique_ptr.pin_mut().set_succeed(2022).unwrap());
assert!(unique_ptr.pin_mut().get_fail().is_err());
assert_eq!(2021, ffi::Shared { z: 0 }.c_method_on_shared());
assert_eq!(2022, *ffi::Shared { z: 2022 }.c_method_ref_on_shared());
assert_eq!(2023, *ffi::Shared { z: 2023 }.c_method_mut_on_shared());
let val = 42;
let mut array = ffi::Array {
a: [0, 0, 0, 0],
b: ffi::Buffer::default(),
};
array.c_set_array(val);
assert_eq!(array.a.len() as i32 * val, array.r_get_array_sum());
}
#[test]
fn test_shared_ptr_weak_ptr() {
let shared_ptr = ffi::c_return_shared_ptr();
let weak_ptr = SharedPtr::downgrade(&shared_ptr);
assert_eq!(1, ffi::c_get_use_count(&weak_ptr));
assert!(!weak_ptr.upgrade().is_null());
assert_eq!(1, ffi::c_get_use_count(&weak_ptr));
drop(shared_ptr);
assert_eq!(0, ffi::c_get_use_count(&weak_ptr));
assert!(weak_ptr.upgrade().is_null());
}
#[test]
fn test_c_ns_method_calls() {
let unique_ptr = ffi2::ns_c_return_unique_ptr_ns();
let old_value = unique_ptr.get();
assert_eq!(1000, old_value);
}
#[test]
fn test_enum_representations() {
assert_eq!(0, ffi::Enum::AVal.repr);
assert_eq!(2020, ffi::Enum::BVal.repr);
assert_eq!(2021, ffi::Enum::LastVal.repr);
}
#[test]
fn test_debug() {
assert_eq!("Shared { z: 1 }", format!("{:?}", ffi::Shared { z: 1 }));
assert_eq!("BVal", format!("{:?}", ffi::Enum::BVal));
assert_eq!("Enum(9)", format!("{:?}", ffi::Enum { repr: 9 }));
}
#[no_mangle]
extern "C" fn cxx_test_suite_get_box() -> *mut R {
Box::into_raw(Box::new(R(2020usize)))
}
#[no_mangle]
unsafe extern "C" fn cxx_test_suite_r_is_correct(r: *const R) -> bool {
(*r).0 == 2020
}
#[test]
fn test_rust_name_attribute() {
assert_eq!("2020", ffi::i32_overloaded_function(2020));
assert_eq!("2020", ffi::str_overloaded_function("2020"));
let unique_ptr = ffi::c_return_unique_ptr();
assert_eq!("2020", unique_ptr.i32_overloaded_method(2020));
assert_eq!("2020", unique_ptr.str_overloaded_method("2020"));
}
#[test]
fn test_extern_trivial() {
let mut d = ffi2::c_return_trivial();
check!(ffi2::c_take_trivial_ref(&d));
check!(d.c_take_trivial_ref_method());
check!(d.c_take_trivial_mut_ref_method());
check!(ffi2::c_take_trivial(d));
let mut d = ffi2::c_return_trivial_ptr();
check!(d.c_take_trivial_ref_method());
check!(d.c_take_trivial_mut_ref_method());
check!(ffi2::c_take_trivial_ptr(d));
cxx::UniquePtr::new(ffi2::D { d: 42 });
let d = ffi2::ns_c_return_trivial();
check!(ffi2::ns_c_take_trivial(d));
let g = ffi2::c_return_trivial_ns();
check!(ffi2::c_take_trivial_ns_ref(&g));
check!(ffi2::c_take_trivial_ns(g));
let g = ffi2::c_return_trivial_ns_ptr();
check!(ffi2::c_take_trivial_ns_ptr(g));
cxx::UniquePtr::new(ffi2::G { g: 42 });
}
#[test]
fn test_extern_opaque() {
let mut e = ffi2::c_return_opaque_ptr();
check!(ffi2::c_take_opaque_ref(e.as_ref().unwrap()));
check!(e.c_take_opaque_ref_method());
check!(e.pin_mut().c_take_opaque_mut_ref_method());
check!(ffi2::c_take_opaque_ptr(e));
let f = ffi2::c_return_ns_opaque_ptr();
check!(ffi2::c_take_opaque_ns_ref(f.as_ref().unwrap()));
check!(ffi2::c_take_opaque_ns_ptr(f));
}
#[test]
fn test_raw_ptr() {
let c = ffi::c_return_mut_ptr(2023);
let mut c_unique = unsafe { cxx::UniquePtr::from_raw(c) };
assert_eq!(2023, c_unique.pin_mut().set_succeed(2023).unwrap());
// c will be dropped as it's now in a UniquePtr
let c2 = ffi::c_return_mut_ptr(2024);
assert_eq!(2024, unsafe { ffi::c_take_const_ptr(c2) });
assert_eq!(2024, unsafe { ffi::c_take_mut_ptr(c2) }); // deletes c2
let c3 = ffi::c_return_const_ptr(2025);
assert_eq!(2025, unsafe { ffi::c_take_const_ptr(c3) });
assert_eq!(2025, unsafe { ffi::c_take_mut_ptr(c3 as *mut ffi::C) }); // deletes c3
}

10
vendor/cxx/tests/ui/array_len_expr.rs vendored Normal file
View file

@ -0,0 +1,10 @@
#[cxx::bridge]
mod ffi {
struct Shared {
arraystr: [String; "13"],
arraysub: [String; 15 - 1],
arrayzero: [String; 0],
}
}
fn main() {}

View file

@ -0,0 +1,17 @@
error: array length must be an integer literal
--> tests/ui/array_len_expr.rs:4:28
|
4 | arraystr: [String; "13"],
| ^^^^
error: unsupported expression, array length must be an integer literal
--> tests/ui/array_len_expr.rs:5:28
|
5 | arraysub: [String; 15 - 1],
| ^^^^^^
error: array with zero size is not supported
--> tests/ui/array_len_expr.rs:6:20
|
6 | arrayzero: [String; 0],
| ^^^^^^^^^^^

View file

@ -0,0 +1,8 @@
#[cxx::bridge]
mod ffi {
unsafe extern "C++" {
fn array() -> [String; 12u16];
}
}
fn main() {}

View file

@ -0,0 +1,10 @@
error[E0308]: mismatched types
--> tests/ui/array_len_suffix.rs:4:32
|
4 | fn array() -> [String; 12u16];
| ^^^^^ expected `usize`, found `u16`
|
help: change the type of the numeric literal from `u16` to `usize`
|
4 | fn array() -> [String; 12usize];
| ~~~~~

14
vendor/cxx/tests/ui/async_fn.rs vendored Normal file
View file

@ -0,0 +1,14 @@
#[cxx::bridge]
mod ffi {
extern "Rust" {
async fn f();
}
extern "C++" {
async fn g();
}
}
async fn f() {}
fn main() {}

11
vendor/cxx/tests/ui/async_fn.stderr vendored Normal file
View file

@ -0,0 +1,11 @@
error: async function is not directly supported yet, but see https://cxx.rs/async.html for a working approach, and https://github.com/pcwalton/cxx-async for some helpers; eventually what you wrote will work but it isn't integrated into the cxx::bridge macro yet
--> tests/ui/async_fn.rs:4:9
|
4 | async fn f();
| ^^^^^^^^^^^^^
error: async function is not directly supported yet, but see https://cxx.rs/async.html for a working approach, and https://github.com/pcwalton/cxx-async for some helpers; eventually what you wrote will work but it isn't integrated into the cxx::bridge macro yet
--> tests/ui/async_fn.rs:8:9
|
8 | async fn g();
| ^^^^^^^^^^^^^

View file

@ -0,0 +1,10 @@
#[cxx::bridge]
mod ffi {
struct S {
x: u8,
}
impl fn() -> &S {}
}
fn main() {}

View file

@ -0,0 +1,5 @@
error: unsupported Self type of explicit impl
--> tests/ui/bad_explicit_impl.rs:7:5
|
7 | impl fn() -> &S {}
| ^^^^^^^^^^^^^^^^^^

View file

@ -0,0 +1,22 @@
#[cxx::bridge]
mod ffi {
struct S {
c: C,
r: R,
s: CxxString,
}
extern "C++" {
type C;
}
extern "Rust" {
type R;
fn f(c: C) -> C;
fn g(r: R) -> R;
fn h(s: CxxString) -> CxxString;
}
}
fn main() {}

View file

@ -0,0 +1,59 @@
error: using opaque C++ type by value is not supported
--> tests/ui/by_value_not_supported.rs:4:9
|
4 | c: C,
| ^^^^
error: using opaque Rust type by value is not supported
--> tests/ui/by_value_not_supported.rs:5:9
|
5 | r: R,
| ^^^^
error: using C++ string by value is not supported
--> tests/ui/by_value_not_supported.rs:6:9
|
6 | s: CxxString,
| ^^^^^^^^^^^^
error: needs a cxx::ExternType impl in order to be used as a field of `S`, argument of `f` or return value of `f`
--> tests/ui/by_value_not_supported.rs:10:9
|
10 | type C;
| ^^^^^^
error: passing opaque C++ type by value is not supported
--> tests/ui/by_value_not_supported.rs:16:14
|
16 | fn f(c: C) -> C;
| ^^^^
error: returning opaque C++ type by value is not supported
--> tests/ui/by_value_not_supported.rs:16:23
|
16 | fn f(c: C) -> C;
| ^
error: passing opaque Rust type by value is not supported
--> tests/ui/by_value_not_supported.rs:17:14
|
17 | fn g(r: R) -> R;
| ^^^^
error: returning opaque Rust type by value is not supported
--> tests/ui/by_value_not_supported.rs:17:23
|
17 | fn g(r: R) -> R;
| ^
error: passing C++ string by value is not supported
--> tests/ui/by_value_not_supported.rs:18:14
|
18 | fn h(s: CxxString) -> CxxString;
| ^^^^^^^^^^^^
error: returning C++ string by value is not supported
--> tests/ui/by_value_not_supported.rs:18:31
|
18 | fn h(s: CxxString) -> CxxString;
| ^^^^^^^^^

10
vendor/cxx/tests/ui/const_fn.rs vendored Normal file
View file

@ -0,0 +1,10 @@
#[cxx::bridge]
mod ffi {
extern "Rust" {
const fn f();
}
}
const fn f() {}
fn main() {}

5
vendor/cxx/tests/ui/const_fn.stderr vendored Normal file
View file

@ -0,0 +1,5 @@
error: const extern function is not supported
--> tests/ui/const_fn.rs:4:9
|
4 | const fn f();
| ^^^^^^^^^^^^^

8
vendor/cxx/tests/ui/data_enums.rs vendored Normal file
View file

@ -0,0 +1,8 @@
#[cxx::bridge]
mod ffi {
enum A {
Field(u64),
}
}
fn main() {}

5
vendor/cxx/tests/ui/data_enums.stderr vendored Normal file
View file

@ -0,0 +1,5 @@
error: enums with data are not supported yet
--> tests/ui/data_enums.rs:4:9
|
4 | Field(u64),
| ^^^^^^^^^^

View file

@ -0,0 +1,27 @@
#![deny(elided_lifetimes_in_paths)]
#[cxx::bridge]
mod ffi {
#[derive(PartialEq, PartialOrd, Hash)]
struct Struct<'a> {
reference: &'a i32,
}
extern "Rust" {
type Rust<'a>;
}
unsafe extern "C++" {
type Cpp<'a>;
fn lifetime_named<'a>(s: &'a i32) -> UniquePtr<Cpp<'a>>;
fn lifetime_underscore(s: &i32) -> UniquePtr<Cpp<'_>>;
fn lifetime_elided(s: &i32) -> UniquePtr<Cpp>;
}
}
pub struct Rust<'a>(&'a i32);
fn main() {}

View file

@ -0,0 +1,15 @@
error: hidden lifetime parameters in types are deprecated
--> tests/ui/deny_elided_lifetimes.rs:21:50
|
21 | fn lifetime_elided(s: &i32) -> UniquePtr<Cpp>;
| ^^^ expected lifetime parameter
|
note: the lint level is defined here
--> tests/ui/deny_elided_lifetimes.rs:1:9
|
1 | #![deny(elided_lifetimes_in_paths)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
help: indicate the anonymous lifetime
|
21 | fn lifetime_elided(s: &i32) -> UniquePtr<Cpp<'_>>;
| ++++

View file

@ -0,0 +1,94 @@
// TODO: More work is needed so that the missing_docs lints produced by rustc
// are properly positioned inside of the bridge.
//! ...
#![deny(missing_docs)]
/// ...
#[cxx::bridge]
pub mod ffi {
pub struct UndocumentedStruct {
pub undocumented_field: u8,
}
/// ...
pub struct DocumentedStruct {
/// ...
pub documented_field: u8,
}
pub enum UndocumentedEnum {
UndocumentedVariant = 0,
}
/// ...
pub enum DocumentedEnum {
/// ...
DocumentedVariant = 0,
}
extern "Rust" {
pub type UndocumentedRustType;
/// ...
pub type DocumentedRustType;
pub fn undocumented_rust_fn() -> u8;
/// ...
pub fn documented_rust_fn() -> u8;
}
unsafe extern "C++" {
pub type UndocumentedForeignType;
/// ...
pub type DocumentedForeignType;
pub type UndocumentedTypeAlias = crate::bindgen::UndocumentedTypeAlias;
/// ...
pub type DocumentedTypeAlias = crate::bindgen::DocumentedTypeAlias;
pub fn undocumented_foreign_fn() -> u8;
/// ...
pub fn documented_foreign_fn() -> u8;
}
#[allow(missing_docs)]
pub struct SuppressUndocumentedStruct {
pub undocumented_field: u8,
}
}
struct UndocumentedRustType;
struct DocumentedRustType;
mod bindgen {
use cxx::{type_id, ExternType};
pub struct UndocumentedTypeAlias;
pub struct DocumentedTypeAlias;
unsafe impl ExternType for UndocumentedTypeAlias {
type Id = type_id!("UndocumentedTypeAlias");
type Kind = cxx::kind::Opaque;
}
unsafe impl ExternType for DocumentedTypeAlias {
type Id = type_id!("DocumentedTypeAlias");
type Kind = cxx::kind::Opaque;
}
}
fn undocumented_rust_fn() -> u8 {
0
}
fn documented_rust_fn() -> u8 {
0
}
fn main() {}

View file

@ -0,0 +1,47 @@
error: missing documentation for a struct
--> tests/ui/deny_missing_docs.rs:11:5
|
11 | pub struct UndocumentedStruct {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> tests/ui/deny_missing_docs.rs:6:9
|
6 | #![deny(missing_docs)]
| ^^^^^^^^^^^^
error: missing documentation for a struct field
--> tests/ui/deny_missing_docs.rs:12:9
|
12 | pub undocumented_field: u8,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: missing documentation for a struct
--> tests/ui/deny_missing_docs.rs:21:5
|
21 | pub enum UndocumentedEnum {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: missing documentation for an associated constant
--> tests/ui/deny_missing_docs.rs:22:9
|
22 | UndocumentedVariant = 0,
| ^^^^^^^^^^^^^^^^^^^
error: missing documentation for a struct
--> tests/ui/deny_missing_docs.rs:44:9
|
44 | pub type UndocumentedForeignType;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: missing documentation for a type alias
--> tests/ui/deny_missing_docs.rs:49:9
|
49 | pub type UndocumentedTypeAlias = crate::bindgen::UndocumentedTypeAlias;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: missing documentation for a function
--> tests/ui/deny_missing_docs.rs:54:9
|
54 | pub fn undocumented_foreign_fn() -> u8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -0,0 +1,9 @@
#[cxx::bridge]
mod ffi {
#[derive(Clone, Clone)]
struct Struct {
x: usize,
}
}
fn main() {}

View file

@ -0,0 +1,7 @@
error[E0119]: conflicting implementations of trait `Clone` for type `Struct`
--> tests/ui/derive_duplicate.rs:3:21
|
3 | #[derive(Clone, Clone)]
| ----- ^^^^^ conflicting implementation for `Struct`
| |
| first implementation here

13
vendor/cxx/tests/ui/derive_noncopy.rs vendored Normal file
View file

@ -0,0 +1,13 @@
#[cxx::bridge]
mod ffi {
#[derive(Copy)]
struct TryCopy {
other: Other,
}
struct Other {
x: usize,
}
}
fn main() {}

View file

@ -0,0 +1,7 @@
error[E0204]: the trait `Copy` may not be implemented for this type
--> tests/ui/derive_noncopy.rs:4:12
|
4 | struct TryCopy {
| ^^^^^^^
5 | other: Other,
| ------------ this field does not implement `Copy`

14
vendor/cxx/tests/ui/drop_shared.rs vendored Normal file
View file

@ -0,0 +1,14 @@
#[cxx::bridge]
mod ffi {
struct Shared {
fd: i32,
}
}
impl Drop for ffi::Shared {
fn drop(&mut self) {
println!("close({})", self.fd);
}
}
fn main() {}

View file

@ -0,0 +1,8 @@
error[E0119]: conflicting implementations of trait `forbid::Drop` for type `Shared`
--> tests/ui/drop_shared.rs:3:5
|
1 | #[cxx::bridge]
| -------------- first implementation here
2 | mod ffi {
3 | struct Shared {
| ^^^^^^^^^^^^^ conflicting implementation for `Shared`

6
vendor/cxx/tests/ui/empty_enum.rs vendored Normal file
View file

@ -0,0 +1,6 @@
#[cxx::bridge]
mod ffi {
enum A {}
}
fn main() {}

5
vendor/cxx/tests/ui/empty_enum.stderr vendored Normal file
View file

@ -0,0 +1,5 @@
error: explicit #[repr(...)] is required for enum without any variants
--> tests/ui/empty_enum.rs:3:5
|
3 | enum A {}
| ^^^^^^^^^

6
vendor/cxx/tests/ui/empty_struct.rs vendored Normal file
View file

@ -0,0 +1,6 @@
#[cxx::bridge]
mod ffi {
struct Empty {}
}
fn main() {}

View file

@ -0,0 +1,5 @@
error: structs without any fields are not supported
--> tests/ui/empty_struct.rs:3:5
|
3 | struct Empty {}
| ^^^^^^^^^^^^^^^

View file

@ -0,0 +1,9 @@
#[cxx::bridge]
mod ffi {
enum Bad {
A = 1u16,
B = 2i64,
}
}
fn main() {}

View file

@ -0,0 +1,5 @@
error: expected u16, found i64
--> tests/ui/enum_inconsistent.rs:5:9
|
5 | B = 2i64,
| ^^^^^^^^

View file

@ -0,0 +1,16 @@
#[cxx::bridge]
mod ffi {
enum A {
FieldA,
FieldB,
}
}
fn main() {}
fn matcher(a: ffi::A) -> u32 {
match a {
ffi::A::FieldA => 2020,
ffi::A::FieldB => 2021,
}
}

View file

@ -0,0 +1,17 @@
error[E0004]: non-exhaustive patterns: `ffi::A { repr: 2_u8..=u8::MAX }` not covered
--> tests/ui/enum_match_without_wildcard.rs:12:11
|
12 | match a {
| ^ pattern `ffi::A { repr: 2_u8..=u8::MAX }` not covered
|
note: `ffi::A` defined here
--> tests/ui/enum_match_without_wildcard.rs:3:10
|
3 | enum A {
| ^
= note: the matched value is of type `ffi::A`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
|
14 ~ ffi::A::FieldB => 2021,
15 ~ ffi::A { repr: 2_u8..=u8::MAX } => todo!(),
|

View file

@ -0,0 +1,13 @@
#[cxx::bridge]
mod ffi {
#[repr(u32)]
enum Bad1 {
A = 0xFFFF_FFFF_FFFF_FFFF,
}
enum Bad2 {
A = 2000,
B = 1u8,
}
}
fn main() {}

View file

@ -0,0 +1,11 @@
error: discriminant value `18446744073709551615` is outside the limits of u32
--> tests/ui/enum_out_of_bounds.rs:5:9
|
5 | A = 0xFFFF_FFFF_FFFF_FFFF,
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: discriminant value `2000` is outside the limits of u8
--> tests/ui/enum_out_of_bounds.rs:9:9
|
9 | B = 1u8,
| ^^^^^^^

17
vendor/cxx/tests/ui/enum_overflows.rs vendored Normal file
View file

@ -0,0 +1,17 @@
#[cxx::bridge]
mod ffi {
enum Good1 {
A = 0xFFFF_FFFF_FFFF_FFFF,
}
enum Good2 {
B = 0xFFFF_FFFF_FFFF_FFFF,
C = 2020,
}
enum Bad {
D = 0xFFFF_FFFF_FFFF_FFFE,
E,
F,
}
}
fn main() {}

View file

@ -0,0 +1,5 @@
error: discriminant overflow on value after 18446744073709551615
--> tests/ui/enum_overflows.rs:13:9
|
13 | F,
| ^

11
vendor/cxx/tests/ui/enum_receiver.rs vendored Normal file
View file

@ -0,0 +1,11 @@
#[cxx::bridge]
mod ffi {
enum Enum {
Variant,
}
extern "Rust" {
fn f(self: &Enum);
}
}
fn main() {}

View file

@ -0,0 +1,5 @@
error: unsupported receiver type; C++ does not allow member functions on enums
--> tests/ui/enum_receiver.rs:7:20
|
7 | fn f(self: &Enum);
| ^^^^^

View file

@ -0,0 +1,9 @@
#[cxx::bridge]
mod ffi {
enum Bad {
A = -0xFFFF_FFFF_FFFF_FFFF,
B = 0xFFFF_FFFF_FFFF_FFFF,
}
}
fn main() {}

View file

@ -0,0 +1,8 @@
error: these discriminant values do not fit in any supported enum repr type
--> tests/ui/enum_unsatisfiable.rs:3:5
|
3 | / enum Bad {
4 | | A = -0xFFFF_FFFF_FFFF_FFFF,
5 | | B = 0xFFFF_FFFF_FFFF_FFFF,
6 | | }
| |_____^

9
vendor/cxx/tests/ui/expected_named.rs vendored Normal file
View file

@ -0,0 +1,9 @@
#[cxx::bridge]
mod ffi {
unsafe extern "C++" {
type Borrowed<'a>;
fn borrowed() -> UniquePtr<Borrowed>;
}
}
fn main() {}

View file

@ -0,0 +1,11 @@
error[E0106]: missing lifetime specifier
--> tests/ui/expected_named.rs:5:36
|
5 | fn borrowed() -> UniquePtr<Borrowed>;
| ^^^^^^^^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
help: consider using the `'static` lifetime
|
5 | fn borrowed() -> UniquePtr<Borrowed<'static>>;
| +++++++++

8
vendor/cxx/tests/ui/extern_fn_abi.rs vendored Normal file
View file

@ -0,0 +1,8 @@
#[cxx::bridge]
mod ffi {
extern "C++" {
extern "Java" fn f();
}
}
fn main() {}

View file

@ -0,0 +1,5 @@
error: explicit ABI on extern function is not supported
--> tests/ui/extern_fn_abi.rs:4:9
|
4 | extern "Java" fn f();
| ^^^^^^^^^^^^^

View file

@ -0,0 +1,15 @@
#[cxx::bridge]
mod ffi {
extern "C++" {
type Opaque: PartialEq + PartialOrd;
}
}
#[cxx::bridge]
mod ffi {
extern "C++" {
type Opaque: for<'de> Deserialize<'de>;
}
}
fn main() {}

View file

@ -0,0 +1,11 @@
error: extern type bounds are not implemented yet
--> tests/ui/extern_type_bound.rs:4:22
|
4 | type Opaque: PartialEq + PartialOrd;
| ^^^^^^^^^^^^^^^^^^^^^^
error: unsupported trait
--> tests/ui/extern_type_bound.rs:11:22
|
11 | type Opaque: for<'de> Deserialize<'de>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -0,0 +1,8 @@
#[cxx::bridge]
mod ffi {
extern "C++" {
type Generic<T>;
}
}
fn main() {}

View file

@ -0,0 +1,5 @@
error: extern type with generic type parameter is not supported yet
--> tests/ui/extern_type_generic.rs:4:22
|
4 | type Generic<T>;
| ^

View file

@ -0,0 +1,8 @@
#[cxx::bridge]
mod ffi {
extern "C++" {
type Complex<'a, 'b: 'a>;
}
}
fn main() {}

View file

@ -0,0 +1,5 @@
error: lifetime parameter with bounds is not supported yet
--> tests/ui/extern_type_lifetime_bound.rs:4:26
|
4 | type Complex<'a, 'b: 'a>;
| ^^^^^^

8
vendor/cxx/tests/ui/fallible_fnptr.rs vendored Normal file
View file

@ -0,0 +1,8 @@
#[cxx::bridge]
mod ffi {
unsafe extern "C++" {
fn f(callback: fn() -> Result<()>);
}
}
fn main() {}

View file

@ -0,0 +1,5 @@
error: function pointer returning Result is not supported yet
--> tests/ui/fallible_fnptr.rs:4:24
|
4 | fn f(callback: fn() -> Result<()>);
| ^^^^^^^^^^^^^^^^^^

View file

@ -0,0 +1,8 @@
#[cxx::bridge]
mod ffi {
unsafe extern "C++" {
fn f() {}
}
}
fn main() {}

View file

@ -0,0 +1,5 @@
error: expected `;`
--> tests/ui/function_with_body.rs:4:16
|
4 | fn f() {}
| ^

16
vendor/cxx/tests/ui/generic_enum.rs vendored Normal file
View file

@ -0,0 +1,16 @@
#[cxx::bridge]
mod ffi {
enum A<T> {
Field,
}
enum B<T> where T: Copy {
Field,
}
enum C where void: Copy {
Field,
}
}
fn main() {}

17
vendor/cxx/tests/ui/generic_enum.stderr vendored Normal file
View file

@ -0,0 +1,17 @@
error: enum with generic parameters is not supported
--> tests/ui/generic_enum.rs:3:5
|
3 | enum A<T> {
| ^^^^^^^^^
error: enum with generic parameters is not supported
--> tests/ui/generic_enum.rs:7:5
|
7 | enum B<T> where T: Copy {
| ^^^^^^^^^
error: enum with where-clause is not supported
--> tests/ui/generic_enum.rs:11:12
|
11 | enum C where void: Copy {
| ^^^^^^^^^^^^^^^^

View file

@ -0,0 +1,10 @@
#[cxx::bridge]
mod ffi {
struct S {
x: u8,
}
impl UniquePtrTarget for S {}
}
fn main() {}

View file

@ -0,0 +1,5 @@
error: unexpected impl, expected something like `impl UniquePtr<T> {}`
--> tests/ui/impl_trait_for_type.rs:7:10
|
7 | impl UniquePtrTarget for S {}
| ^^^^^^^^^^^^^^^^^^^^^

12
vendor/cxx/tests/ui/include.rs vendored Normal file
View file

@ -0,0 +1,12 @@
#[cxx::bridge]
mod ffi {
extern "C++" {
include!("path/to" what);
include!(<path/to> what);
include!(<path/to);
include!(<path[to]>);
include!(...);
}
}
fn main() {}

29
vendor/cxx/tests/ui/include.stderr vendored Normal file
View file

@ -0,0 +1,29 @@
error: unexpected token
--> tests/ui/include.rs:4:28
|
4 | include!("path/to" what);
| ^^^^
error: unexpected token
--> tests/ui/include.rs:5:28
|
5 | include!(<path/to> what);
| ^^^^
error: expected `>`
--> tests/ui/include.rs:6:17
|
6 | include!(<path/to);
| ^^^^^^^^^^
error: unexpected token in include path
--> tests/ui/include.rs:7:23
|
7 | include!(<path[to]>);
| ^^^^
error: expected "quoted/path/to" or <bracketed/path/to>
--> tests/ui/include.rs:8:18
|
8 | include!(...);
| ^

View file

@ -0,0 +1,9 @@
#[cxx::bridge]
mod ffi {
extern "C++" {
type Opaque;
unsafe fn f<'a>(&'a self, arg: &str) -> &'a str;
}
}
fn main() {}

View file

@ -0,0 +1,5 @@
error: extern C++ function with lifetimes must be declared in `unsafe extern "C++"` block
--> tests/ui/lifetime_extern_cxx.rs:5:9
|
5 | unsafe fn f<'a>(&'a self, arg: &str) -> &'a str;
| ^^^^^^^^^^^^^^^

View file

@ -0,0 +1,17 @@
#[cxx::bridge]
mod ffi {
extern "Rust" {
type Opaque;
fn f<'a>(&'a self, arg: &str) -> &'a str;
}
}
pub struct Opaque;
impl Opaque {
fn f(&self, _arg: &str) -> &str {
""
}
}
fn main() {}

View file

@ -0,0 +1,5 @@
error: must be `unsafe fn f` in order to expose explicit lifetimes to C++
--> tests/ui/lifetime_extern_rust.rs:5:9
|
5 | fn f<'a>(&'a self, arg: &str) -> &'a str;
| ^^^^^^^^

10
vendor/cxx/tests/ui/missing_unsafe.rs vendored Normal file
View file

@ -0,0 +1,10 @@
#[cxx::bridge]
mod ffi {
extern "Rust" {
fn f(x: i32);
}
}
unsafe fn f(_x: i32) {}
fn main() {}

View file

@ -0,0 +1,9 @@
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
--> tests/ui/missing_unsafe.rs:4:12
|
4 | fn f(x: i32);
| ^ - items do not inherit unsafety from separate enclosing items
| |
| call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior

View file

@ -0,0 +1,8 @@
#[cxx::bridge]
mod ffi {
struct Monad<T>;
extern "Haskell" {}
}
fn main() {}

View file

@ -0,0 +1,11 @@
error: unit structs are not supported
--> tests/ui/multiple_parse_error.rs:3:5
|
3 | struct Monad<T>;
| ^^^^^^^^^^^^^^^^
error: unrecognized ABI, requires either "C++" or "Rust"
--> tests/ui/multiple_parse_error.rs:5:5
|
5 | extern "Haskell" {}
| ^^^^^^^^^^^^^^^^

18
vendor/cxx/tests/ui/mut_return.rs vendored Normal file
View file

@ -0,0 +1,18 @@
#[cxx::bridge]
mod ffi {
extern "Rust" {
type Mut<'a>;
}
unsafe extern "C++" {
type Thing;
fn f(t: &Thing) -> Pin<&mut CxxString>;
unsafe fn g(t: &Thing) -> Pin<&mut CxxString>;
fn h(t: Box<Mut>) -> Pin<&mut CxxString>;
fn i<'a>(t: Box<Mut<'a>>) -> Pin<&'a mut CxxString>;
fn j(t: &Thing) -> &mut [u8];
}
}
fn main() {}

11
vendor/cxx/tests/ui/mut_return.stderr vendored Normal file
View file

@ -0,0 +1,11 @@
error: &mut return type is not allowed unless there is a &mut argument
--> tests/ui/mut_return.rs:10:9
|
10 | fn f(t: &Thing) -> Pin<&mut CxxString>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: &mut return type is not allowed unless there is a &mut argument
--> tests/ui/mut_return.rs:14:9
|
14 | fn j(t: &Thing) -> &mut [u8];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -0,0 +1,8 @@
#[cxx::bridge]
mod ffi {
enum A {
Field = 2020 + 1,
}
}
fn main() {}

View file

@ -0,0 +1,5 @@
error: enums with non-integer literal discriminants are not supported yet
--> tests/ui/non_integer_discriminant_enum.rs:4:9
|
4 | Field = 2020 + 1,
| ^^^^^^^^^^^^^^^^

View file

@ -0,0 +1,12 @@
#[cxx::bridge]
mod ffi {
struct S {
x: u8,
}
impl UniquePtr<S> {
fn new() -> Self;
}
}
fn main() {}

View file

@ -0,0 +1,8 @@
error: expected an empty impl block
--> tests/ui/nonempty_impl_block.rs:7:23
|
7 | impl UniquePtr<S> {
| _______________________^
8 | | fn new() -> Self;
9 | | }
| |_____^

View file

@ -0,0 +1,18 @@
pub struct MyBuilder<'a> {
_s: &'a str,
}
type OptBuilder<'a> = Option<MyBuilder<'a>>;
#[cxx::bridge]
mod ffi {
extern "Rust" {
type OptBuilder<'a>;
}
struct MyBuilder<'a> {
rs: Box<OptBuilder<'a>>,
}
}
fn main() {}

View file

@ -0,0 +1,21 @@
error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
--> tests/ui/nonlocal_rust_type.rs:10:9
|
10 | type OptBuilder<'a>;
| ^^^^^--------------
| | |
| | `Option` is not defined in the current crate
| impl doesn't use only types from inside the current crate
|
= note: define and implement a trait or new type instead
error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
--> tests/ui/nonlocal_rust_type.rs:14:13
|
14 | rs: Box<OptBuilder<'a>>,
| ^^^^--------------
| | |
| | `Option` is not defined in the current crate
| impl doesn't use only types from inside the current crate
|
= note: define and implement a trait or new type instead

View file

@ -0,0 +1,16 @@
#[cxx::bridge]
mod ffi {
extern "C++" {
type Opaque;
}
}
fn assert_send<T: Send>() {}
fn assert_sync<T: Sync>() {}
fn assert_unpin<T: Unpin>() {}
fn main() {
assert_send::<ffi::Opaque>();
assert_sync::<ffi::Opaque>();
assert_unpin::<ffi::Opaque>();
}

View file

@ -0,0 +1,59 @@
error[E0277]: `*const cxx::void` cannot be sent between threads safely
--> tests/ui/opaque_autotraits.rs:13:19
|
13 | assert_send::<ffi::Opaque>();
| ^^^^^^^^^^^ `*const cxx::void` cannot be sent between threads safely
|
= help: within `ffi::Opaque`, the trait `Send` is not implemented for `*const cxx::void`
= note: required because it appears within the type `[*const cxx::void; 0]`
= note: required because it appears within the type `cxx::private::Opaque`
note: required because it appears within the type `ffi::Opaque`
--> tests/ui/opaque_autotraits.rs:4:14
|
4 | type Opaque;
| ^^^^^^
note: required by a bound in `assert_send`
--> tests/ui/opaque_autotraits.rs:8:19
|
8 | fn assert_send<T: Send>() {}
| ^^^^ required by this bound in `assert_send`
error[E0277]: `*const cxx::void` cannot be shared between threads safely
--> tests/ui/opaque_autotraits.rs:14:19
|
14 | assert_sync::<ffi::Opaque>();
| ^^^^^^^^^^^ `*const cxx::void` cannot be shared between threads safely
|
= help: within `ffi::Opaque`, the trait `Sync` is not implemented for `*const cxx::void`
= note: required because it appears within the type `[*const cxx::void; 0]`
= note: required because it appears within the type `cxx::private::Opaque`
note: required because it appears within the type `ffi::Opaque`
--> tests/ui/opaque_autotraits.rs:4:14
|
4 | type Opaque;
| ^^^^^^
note: required by a bound in `assert_sync`
--> tests/ui/opaque_autotraits.rs:9:19
|
9 | fn assert_sync<T: Sync>() {}
| ^^^^ required by this bound in `assert_sync`
error[E0277]: `PhantomPinned` cannot be unpinned
--> tests/ui/opaque_autotraits.rs:15:20
|
15 | assert_unpin::<ffi::Opaque>();
| ^^^^^^^^^^^ within `ffi::Opaque`, the trait `Unpin` is not implemented for `PhantomPinned`
|
= note: consider using `Box::pin`
= note: required because it appears within the type `PhantomData<PhantomPinned>`
= note: required because it appears within the type `cxx::private::Opaque`
note: required because it appears within the type `ffi::Opaque`
--> tests/ui/opaque_autotraits.rs:4:14
|
4 | type Opaque;
| ^^^^^^
note: required by a bound in `assert_unpin`
--> tests/ui/opaque_autotraits.rs:10:20
|
10 | fn assert_unpin<T: Unpin>() {}
| ^^^^^ required by this bound in `assert_unpin`

10
vendor/cxx/tests/ui/opaque_not_sized.rs vendored Normal file
View file

@ -0,0 +1,10 @@
#[cxx::bridge]
mod ffi {
extern "Rust" {
type TypeR;
}
}
struct TypeR(str);
fn main() {}

View file

@ -0,0 +1,17 @@
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> tests/ui/opaque_not_sized.rs:4:14
|
4 | type TypeR;
| ^^^^^ doesn't have a size known at compile-time
|
= help: within `TypeR`, the trait `Sized` is not implemented for `str`
note: required because it appears within the type `TypeR`
--> tests/ui/opaque_not_sized.rs:8:8
|
8 | struct TypeR(str);
| ^^^^^
note: required by a bound in `__AssertSized`
--> tests/ui/opaque_not_sized.rs:4:9
|
4 | type TypeR;
| ^^^^^^^^^^^ required by this bound in `__AssertSized`

14
vendor/cxx/tests/ui/pin_mut_opaque.rs vendored Normal file
View file

@ -0,0 +1,14 @@
#[cxx::bridge]
mod ffi {
unsafe extern "C++" {
type Opaque;
fn f(arg: &mut Opaque);
fn g(&mut self);
fn h(self: &mut Opaque);
fn s(s: &mut CxxString);
fn v(v: &mut CxxVector<u8>);
}
}
fn main() {}

View file

@ -0,0 +1,35 @@
error: mutable reference to C++ type requires a pin -- use Pin<&mut Opaque>
--> tests/ui/pin_mut_opaque.rs:5:19
|
5 | fn f(arg: &mut Opaque);
| ^^^^^^^^^^^
error: mutable reference to C++ type requires a pin -- use Pin<&mut CxxString>
--> tests/ui/pin_mut_opaque.rs:8:17
|
8 | fn s(s: &mut CxxString);
| ^^^^^^^^^^^^^^
error: mutable reference to C++ type requires a pin -- use Pin<&mut CxxVector<...>>
--> tests/ui/pin_mut_opaque.rs:9:17
|
9 | fn v(v: &mut CxxVector<u8>);
| ^^^^^^^^^^^^^^^^^^
error: needs a cxx::ExternType impl in order to be used as a non-pinned mutable reference in signature of `f`, `g`, `h`
--> tests/ui/pin_mut_opaque.rs:4:9
|
4 | type Opaque;
| ^^^^^^^^^^^
error: mutable reference to opaque C++ type requires a pin -- use `self: Pin<&mut Opaque>`
--> tests/ui/pin_mut_opaque.rs:6:14
|
6 | fn g(&mut self);
| ^^^^^^^^^
error: mutable reference to opaque C++ type requires a pin -- use `self: Pin<&mut Opaque>`
--> tests/ui/pin_mut_opaque.rs:7:20
|
7 | fn h(self: &mut Opaque);
| ^^^^^^^^^^^

8
vendor/cxx/tests/ui/ptr_in_fnptr.rs vendored Normal file
View file

@ -0,0 +1,8 @@
#[cxx::bridge]
mod ffi {
unsafe extern "C++" {
fn f(callback: fn(p: *const u8));
}
}
fn main() {}

View file

@ -0,0 +1,5 @@
error: pointer argument requires that the function pointer be marked unsafe
--> tests/ui/ptr_in_fnptr.rs:4:27
|
4 | fn f(callback: fn(p: *const u8));
| ^^^^^^^^^^^^

View file

@ -0,0 +1,10 @@
#[cxx::bridge]
mod ffi {
unsafe extern "C++" {
type C;
fn not_unsafe_ptr(c: *mut C);
}
}
fn main() {}

View file

@ -0,0 +1,5 @@
error: pointer argument requires that the function be marked unsafe
--> tests/ui/ptr_missing_unsafe.rs:6:27
|
6 | fn not_unsafe_ptr(c: *mut C);
| ^^^^^^^^^

10
vendor/cxx/tests/ui/ptr_no_const_mut.rs vendored Normal file
View file

@ -0,0 +1,10 @@
#[cxx::bridge]
mod ffi {
unsafe extern "C++" {
type C;
fn get_neither_const_nor_mut() -> *C;
}
}
fn main() {}

View file

@ -0,0 +1,18 @@
error: expected `mut` or `const` keyword in raw pointer type
--> tests/ui/ptr_no_const_mut.rs:6:43
|
6 | fn get_neither_const_nor_mut() -> *C;
| ^
|
help: add `mut` or `const` here
|
6 | fn get_neither_const_nor_mut() -> *const C;
| +++++
6 | fn get_neither_const_nor_mut() -> *mut C;
| +++
error: expected `const` or `mut`
--> tests/ui/ptr_no_const_mut.rs:6:44
|
6 | fn get_neither_const_nor_mut() -> *C;
| ^

12
vendor/cxx/tests/ui/ptr_unsupported.rs vendored Normal file
View file

@ -0,0 +1,12 @@
#[cxx::bridge]
mod ffi {
unsafe extern "C++" {
type C;
fn get_ptr_to_reference() -> *mut &C;
fn get_uniqueptr_to_ptr() -> UniquePtr<*mut C>;
fn get_vector_of_ptr() -> UniquePtr<CxxVector<*mut C>>;
}
}
fn main() {}

View file

@ -0,0 +1,17 @@
error: C++ does not allow pointer to reference as a type
--> tests/ui/ptr_unsupported.rs:6:38
|
6 | fn get_ptr_to_reference() -> *mut &C;
| ^^^^^^^
error: unsupported unique_ptr target type
--> tests/ui/ptr_unsupported.rs:7:38
|
7 | fn get_uniqueptr_to_ptr() -> UniquePtr<*mut C>;
| ^^^^^^^^^^^^^^^^^
error: unsupported vector element type
--> tests/ui/ptr_unsupported.rs:8:45
|
8 | fn get_vector_of_ptr() -> UniquePtr<CxxVector<*mut C>>;
| ^^^^^^^^^^^^^^^^^

View file

@ -0,0 +1,53 @@
use cxx::{type_id, ExternType};
#[repr(transparent)]
pub struct QuotedRaw(usize);
unsafe impl ExternType for QuotedRaw {
type Id = type_id!("org::r#box::implementation::QuotedRaw");
type Kind = cxx::kind::Trivial;
}
#[repr(transparent)]
pub struct QuotedKeyword(usize);
unsafe impl ExternType for QuotedKeyword {
type Id = type_id!("org::box::implementation::QuotedKeyword");
type Kind = cxx::kind::Trivial;
}
#[repr(transparent)]
pub struct UnquotedRaw(usize);
unsafe impl ExternType for UnquotedRaw {
type Id = type_id!(org::r#box::implementation::UnquotedRaw);
type Kind = cxx::kind::Trivial;
}
#[repr(transparent)]
pub struct UnquotedKeyword(usize);
unsafe impl ExternType for UnquotedKeyword {
type Id = type_id!(org::box::implementation::UnquotedKeyword);
type Kind = cxx::kind::Trivial;
}
#[cxx::bridge]
pub mod ffi {
extern "C++" {
#[namespace = "org::r#box::implementation"]
type QuotedRaw = crate::QuotedRaw;
#[namespace = "org::box::implementation"]
type QuotedKeyword = crate::QuotedKeyword;
#[namespace = org::r#box::implementation]
type UnquotedRaw = crate::UnquotedRaw;
// Not allowed by rustc (independent of cxx):
// #[namespace = org::box::implementation]
// type UnquotedKeyword = crate::UnquotedKeyword;
}
}
fn main() {}

View file

@ -0,0 +1,11 @@
error: raw identifier `r#box` is not allowed in a quoted namespace; use `box`, or remove quotes
--> tests/ui/raw_ident_namespace.rs:7:24
|
7 | type Id = type_id!("org::r#box::implementation::QuotedRaw");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: raw identifier `r#box` is not allowed in a quoted namespace; use `box`, or remove quotes
--> tests/ui/raw_ident_namespace.rs:38:23
|
38 | #[namespace = "org::r#box::implementation"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -0,0 +1,13 @@
#[cxx::bridge]
mod ffi {
unsafe extern "C++" {
type ThingC;
fn repro_c(t: &&ThingC);
}
extern "Rust" {
type ThingR;
fn repro_r(t: &&ThingR);
}
}
fn main() {}

View file

@ -0,0 +1,11 @@
error: C++ does not allow references to references
--> tests/ui/reference_to_reference.rs:5:23
|
5 | fn repro_c(t: &&ThingC);
| ^^^^^^^^
error: C++ does not allow references to references
--> tests/ui/reference_to_reference.rs:9:23
|
9 | fn repro_r(t: &&ThingR);
| ^^^^^^^^

Some files were not shown because too many files have changed in this diff Show more