From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../diplomat__tests__multilevel_borrows.snap | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 third_party/rust/diplomat/src/snapshots/diplomat__tests__multilevel_borrows.snap (limited to 'third_party/rust/diplomat/src/snapshots/diplomat__tests__multilevel_borrows.snap') diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__multilevel_borrows.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__multilevel_borrows.snap new file mode 100644 index 0000000000..f662608096 --- /dev/null +++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__multilevel_borrows.snap @@ -0,0 +1,45 @@ +--- +source: macro/src/lib.rs +expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n #[diplomat :: opaque] struct Foo < 'a > (& 'a str) ;\n #[diplomat :: opaque] struct Bar < 'b, 'a : 'b >\n (& 'b Foo < 'a >) ; struct Baz < 'x, 'y >\n { foo : & 'y Foo < 'x >, } impl < 'a > Foo < 'a >\n {\n pub fn new(x : & 'a str) -> Box < Foo < 'a >>\n { unimplemented! () } pub fn get_bar < 'b > (& 'b self) ->\n Box < Bar < 'b, 'a >> { unimplemented! () } pub fn get_baz <\n 'b > (& 'b self) -> Baz < 'b, 'a > { Bax { foo : self } }\n }\n }\n }).to_token_stream().to_string())" +--- +mod ffi { + struct Foo<'a>(&'a str); + struct Bar<'b, 'a: 'b>(&'b Foo<'a>); + #[repr(C)] + struct Baz<'x, 'y> { + foo: &'y Foo<'x>, + } + impl<'a> Foo<'a> { + pub fn new(x: &'a str) -> Box> { + unimplemented!() + } + pub fn get_bar<'b>(&'b self) -> Box> { + unimplemented!() + } + pub fn get_baz<'b>(&'b self) -> Baz<'b, 'a> { + Bax { foo: self } + } + } + #[no_mangle] + extern "C" fn Bar_destroy<'b, 'a: 'b>(this: Box>) {} + #[no_mangle] + extern "C" fn Baz_destroy<'x: 'y, 'y>(this: Box>) {} + #[no_mangle] + extern "C" fn Foo_new<'a>(x_diplomat_data: *const u8, x_diplomat_len: usize) -> Box> { + Foo::new(unsafe { + core::str::from_utf8(core::slice::from_raw_parts(x_diplomat_data, x_diplomat_len)) + .unwrap() + }) + } + #[no_mangle] + extern "C" fn Foo_get_bar<'a: 'b, 'b>(this: &'b Foo<'a>) -> Box> { + this.get_bar() + } + #[no_mangle] + extern "C" fn Foo_get_baz<'a: 'b, 'b>(this: &'b Foo<'a>) -> Baz<'b, 'a> { + this.get_baz() + } + #[no_mangle] + extern "C" fn Foo_destroy<'a>(this: Box>) {} +} + -- cgit v1.2.3