diff options
Diffstat (limited to 'bindgen/codegen')
-rw-r--r-- | bindgen/codegen/dyngen.rs | 12 | ||||
-rw-r--r-- | bindgen/codegen/mod.rs | 24 |
2 files changed, 26 insertions, 10 deletions
diff --git a/bindgen/codegen/dyngen.rs b/bindgen/codegen/dyngen.rs index d02c51e4..f310f14e 100644 --- a/bindgen/codegen/dyngen.rs +++ b/bindgen/codegen/dyngen.rs @@ -92,7 +92,9 @@ impl DynamicItems { ) -> Result<Self, ::libloading::Error> where P: AsRef<::std::ffi::OsStr> { let library = ::libloading::Library::new(path)?; - Self::from_library(library) + unsafe { + Self::from_library(library) + } } pub unsafe fn from_library<L>( @@ -157,7 +159,9 @@ impl DynamicItems { self.struct_implementation.push(quote! { #(#attributes)* pub unsafe fn #ident ( &self, #( #args ),* ) -> #ret_ty { - #call_body + unsafe { + #call_body + } } }); } @@ -166,11 +170,11 @@ impl DynamicItems { let ident_str = codegen::helpers::ast_ty::cstr_expr(ident.to_string()); self.constructor_inits.push(if is_required { quote! { - let #ident = __library.get(#ident_str).map(|sym| *sym)?; + let #ident = unsafe { __library.get(#ident_str) }.map(|sym| *sym)?; } } else { quote! { - let #ident = __library.get(#ident_str).map(|sym| *sym); + let #ident = unsafe { __library.get(#ident_str) }.map(|sym| *sym); } }); diff --git a/bindgen/codegen/mod.rs b/bindgen/codegen/mod.rs index d0c19136..e0d96cd1 100644 --- a/bindgen/codegen/mod.rs +++ b/bindgen/codegen/mod.rs @@ -2605,7 +2605,9 @@ impl MethodCodegen for Method { methods.push(quote! { #(#attrs)* pub unsafe fn #name ( #( #args ),* ) #ret { - #block + unsafe { + #block + } } }); } @@ -4263,7 +4265,9 @@ fn objc_method_codegen( methods.push(quote! { unsafe fn #method_name #sig where <Self as std::ops::Deref>::Target: objc::Message + Sized { - #body + unsafe { + #body + } } }); } @@ -4638,12 +4642,16 @@ pub mod utils { #[inline] pub unsafe fn as_ref(&self) -> &T { - ::#prefix::mem::transmute(self) + unsafe { + ::#prefix::mem::transmute(self) + } } #[inline] pub unsafe fn as_mut(&mut self) -> &mut T { - ::#prefix::mem::transmute(self) + unsafe { + ::#prefix::mem::transmute(self) + } } } }; @@ -4757,12 +4765,16 @@ pub mod utils { #[inline] pub unsafe fn as_slice(&self, len: usize) -> &[T] { - ::#prefix::slice::from_raw_parts(self.as_ptr(), len) + unsafe { + ::#prefix::slice::from_raw_parts(self.as_ptr(), len) + } } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { - ::#prefix::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + unsafe { + ::#prefix::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + } } } }; |