File tree 3 files changed +10
-9
lines changed 3 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -677,19 +677,20 @@ fn expand_rust_type_import(ety: &ExternType) -> TokenStream {
677
677
678
678
fn expand_rust_type_impl ( ety : & ExternType ) -> TokenStream {
679
679
let ident = & ety. name . rust ;
680
+ let generics = & ety. generics ;
680
681
let span = ident. span ( ) ;
681
682
let unsafe_impl = quote_spanned ! ( ety. type_token. span=> unsafe impl ) ;
682
683
683
684
let mut impls = quote_spanned ! { span=>
684
- #unsafe_impl :: cxx:: private:: RustType for #ident { }
685
+ #unsafe_impl #generics :: cxx:: private:: RustType for #ident #generics { }
685
686
} ;
686
687
687
688
for derive in & ety. derives {
688
689
if derive. what == Trait :: ExternType {
689
690
let type_id = type_id ( & ety. name ) ;
690
691
let span = derive. span ;
691
692
impls. extend ( quote_spanned ! { span=>
692
- unsafe impl :: cxx:: ExternType for #ident {
693
+ unsafe impl #generics :: cxx:: ExternType for #ident #generics {
693
694
type Id = #type_id;
694
695
type Kind = :: cxx:: kind:: Opaque ;
695
696
}
Original file line number Diff line number Diff line change @@ -335,13 +335,6 @@ fn check_api_type(cx: &mut Check, ety: &ExternType) {
335
335
cx. error ( derive, msg) ;
336
336
}
337
337
338
- if let Some ( lifetime) = ety. generics . lifetimes . first ( ) {
339
- if ety. lang == Lang :: Rust {
340
- let msg = "extern Rust type with lifetimes is not supported yet" ;
341
- cx. error ( lifetime, msg) ;
342
- }
343
- }
344
-
345
338
if !ety. bounds . is_empty ( ) {
346
339
let bounds = & ety. bounds ;
347
340
let span = quote ! ( #( #bounds) * ) ;
Original file line number Diff line number Diff line change @@ -210,6 +210,11 @@ pub mod ffi {
210
210
type Job = crate :: module:: ffi:: Job ;
211
211
}
212
212
213
+ extern "Rust" {
214
+ #[ derive( ExternType ) ]
215
+ type Reference < ' a > ;
216
+ }
217
+
213
218
unsafe extern "C++" {
214
219
type Borrow < ' a > ;
215
220
@@ -377,6 +382,8 @@ impl R {
377
382
}
378
383
}
379
384
385
+ pub struct Reference < ' a > ( & ' a String ) ;
386
+
380
387
impl ffi:: Shared {
381
388
fn r_method_on_shared ( & self ) -> String {
382
389
"2020" . to_owned ( )
You can’t perform that action at this time.
0 commit comments