Skip to content

Commit 0dee4b4

Browse files
authored
Merge pull request #555 from dtolnay/impl
Limit instantiation of Vec and Box shims to local element type
2 parents 8801e60 + 1acc8a0 commit 0dee4b4

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

macro/src/expand.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,8 @@ fn expand_rust_box(ident: &RustName, types: &Types) -> TokenStream {
960960

961961
let span = ident.span();
962962
quote_spanned! {span=>
963+
#[doc(hidden)]
964+
unsafe impl ::cxx::private::ImplBox for #ident {}
963965
#[doc(hidden)]
964966
#[export_name = #link_uninit]
965967
unsafe extern "C" fn #local_uninit(
@@ -999,6 +1001,8 @@ fn expand_rust_vec(elem: &RustName, types: &Types) -> TokenStream {
9991001

10001002
let span = elem.span();
10011003
quote_spanned! {span=>
1004+
#[doc(hidden)]
1005+
unsafe impl ::cxx::private::ImplVec for #elem {}
10021006
#[doc(hidden)]
10031007
#[export_name = #link_new]
10041008
unsafe extern "C" fn #local_new(this: *mut ::cxx::private::RustVec<#elem>) {

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ pub mod private {
448448
pub use crate::rust_slice::RustSlice;
449449
pub use crate::rust_str::RustStr;
450450
pub use crate::rust_string::RustString;
451-
pub use crate::rust_type::RustType;
451+
pub use crate::rust_type::{ImplBox, ImplVec, RustType};
452452
pub use crate::rust_vec::RustVec;
453453
pub use crate::shared_ptr::SharedPtrTarget;
454454
pub use crate::unique_ptr::UniquePtrTarget;

src/rust_type.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
pub unsafe trait RustType {}
2+
pub unsafe trait ImplBox {}
3+
pub unsafe trait ImplVec {}

0 commit comments

Comments
 (0)