File tree Expand file tree Collapse file tree 3 files changed +6
-18
lines changed Expand file tree Collapse file tree 3 files changed +6
-18
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ pub use gc_derive::{Finalize, Trace};
3535// We re-export the Trace method, as well as some useful internal methods for
3636// managing collections or configuring the garbage collector.
3737pub use crate :: gc:: { finalizer_safe, force_collect} ;
38- pub use crate :: trace:: { Finalize , Trace , TriviallyDrop } ;
38+ pub use crate :: trace:: { Finalize , Trace } ;
3939
4040////////
4141// Gc //
Original file line number Diff line number Diff line change @@ -17,12 +17,6 @@ pub trait Finalize {
1717 fn finalize ( & self ) { }
1818}
1919
20- /// Ensures type has no custom Drop implementation, without implementing it itself
21- /// In case of Drop implementation present, obscure compilation error will be raised
22- pub unsafe trait TriviallyDrop {
23- unsafe fn guard ( self ) ;
24- }
25-
2620#[ cfg( feature = "nightly" ) ]
2721impl < T : ?Sized > Finalize for T {
2822 // XXX: Should this function somehow tell its caller (which is presumably
Original file line number Diff line number Diff line change @@ -76,25 +76,19 @@ fn derive_trace(mut s: Structure<'_>) -> proc_macro2::TokenStream {
7676 #drop_impl
7777 }
7878 } else {
79- let finalize_impl = derive_finalize ( s. clone ( ) ) ;
80-
8179 s. bind_with ( |_| BindStyle :: Move ) ;
82- let trivially_drop_body = s. each ( |bi| quote ! ( drop( #bi) ) ) ;
83-
84- let trivially_drop_impl = s. unsafe_bound_impl (
85- quote ! ( :: gc:: TriviallyDrop ) ,
80+ let trivially_drop_body = s. each ( |_| quote ! { } ) ;
81+ let finalize_impl = s. bound_impl (
82+ quote ! ( :: gc:: Finalize ) ,
8683 quote ! (
87- unsafe fn guard( self ) {
88- match self {
89- #trivially_drop_body
90- }
84+ fn finalize( & self ) {
85+ let _trivially_drop = |t: Self | match t { #trivially_drop_body } ;
9186 }
9287 ) ,
9388 ) ;
9489
9590 quote ! {
9691 #trace_impl
97- #trivially_drop_impl
9892 #finalize_impl
9993 }
10094 }
You can’t perform that action at this time.
0 commit comments