secp256k1: Document safety constraints

Add a `# Safety` section to all unsafe traits, methods, and functions.

Remove the clippy attribute for `missing_safety_doc`.
This commit is contained in:
Tobin C. Harding 2022-11-22 08:28:57 +11:00
parent 85681cece7
commit 6d747301e8
2 changed files with 8 additions and 1 deletions

View File

@ -62,12 +62,20 @@ pub mod global {
/// A trait for all kinds of contexts that lets you define the exact flags and a function to
/// deallocate memory. It isn't possible to implement this for types outside this crate.
///
/// # Safety
///
/// This trait is marked unsafe to allow unsafe implementations of `deallocate`.
pub unsafe trait Context: private::Sealed {
/// Flags for the ffi.
const FLAGS: c_uint;
/// A constant description of the context.
const DESCRIPTION: &'static str;
/// A function to deallocate the memory when the context is dropped.
///
/// # Safety
///
/// `ptr` must be valid. Further safety constraints may be imposed by [`std::alloc::dealloc`].
unsafe fn deallocate(ptr: *mut u8, size: usize);
}

View File

@ -152,7 +152,6 @@
// Coding conventions
#![deny(non_upper_case_globals, non_camel_case_types, non_snake_case)]
#![warn(missing_docs, missing_copy_implementations, missing_debug_implementations)]
#![allow(clippy::missing_safety_doc)]
#![cfg_attr(all(not(test), not(feature = "std")), no_std)]
// Experimental features we need.
#![cfg_attr(docsrs, feature(doc_cfg))]