Skip to content

Commit

Permalink
1. Fixing compilation for the code generator
Browse files Browse the repository at this point in the history
2. Improving documentation
3. Fixing rustfmt for code sections
  • Loading branch information
denisandroid committed Jul 6, 2024
1 parent f85fea5 commit 3f5e456
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
3 changes: 2 additions & 1 deletion src/core/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ fn test_flag_is_safe_mode() {

#[cfg(all(feature = "always_check_in_case_debug_assertions", debug_assertions))]
{
#![allow(clippy::assertions_on_constants)] // why? it's part of this test, it's okay.
// clippy::assertions_on_constants why? it's part of this test, it's okay.
#![allow(clippy::assertions_on_constants)]
assert!(IS_SAFE_MODE);

is_checked_c = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/core/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl StateManuallyDropData {
}

impl StateManuallyDrop {
// why?: This constant is only used for initialization, no one is going to constantly access it for use.
// clippy::declare_interior_mutable_const why?: This constant is only used for initialization, no one is going to constantly access it for use.
#[allow(clippy::declare_interior_mutable_const)]
/// Empty state, needed only for some implementations of const functions.
pub const EMPTY_STATE: StateManuallyDrop = StateManuallyDrop::__empty();
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ features = [
use crate::beh::auto::cfg_if_safemode;

/// The insecure standard version of ManuallyDrop
#[rustfmt::skip] // why?: the oddity forces fmt to convert ::core to core, breaking the library.
// rustfmt::skip why?: the oddity forces fmt to convert ::core to core, breaking the library.
#[rustfmt::skip]
pub use ::core::mem::ManuallyDrop as UnsafeStdManuallyDrop;

/// The core of the library that defines the basic primitives.
Expand Down
16 changes: 8 additions & 8 deletions src/macro_codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ macro_rules! __codegen {
/// Takes the value from the ManuallyDrop<T> container out.
#[inline(always)]
pub fn take(slot: &mut $current_type<T, Trig>) -> T {
$crate::__if_codegen! {
$crate::macro_codegen::__if_codegen! {
if (#$is_safe) {
slot.state.to_takemode_or_trig::<Trig>();
}
Expand Down Expand Up @@ -353,7 +353,7 @@ macro_rules! __codegen {
/// Get reference to value.
#[inline(always)]
pub fn as_value(&self) -> &T {
$crate::__if_codegen! {
$crate::macro_codegen::__if_codegen! {
if (#$is_safe) {
self.state.deref_or_trig::<Trig>();
}
Expand All @@ -367,7 +367,7 @@ macro_rules! __codegen {
/// Get a mutable reference to a value.
#[inline(always)]
pub fn as_mut_value(&mut self) -> &mut T {
$crate::__if_codegen! {
$crate::macro_codegen::__if_codegen! {
if (#$is_safe) {
self.state.deref_or_trig::<Trig>();
}
Expand Down Expand Up @@ -399,7 +399,7 @@ macro_rules! __codegen {
/// Manually drops the contained value.
#[inline(always)]
pub fn drop(slot: &mut $current_type<T, Trig>) {
$crate::__if_codegen! {
$crate::macro_codegen::__if_codegen! {
if (#$is_safe) {
slot.state.to_dropmode_or_trig::<Trig>();
}
Expand All @@ -410,7 +410,7 @@ macro_rules! __codegen {
}
}

$crate::__if_codegen! {
$crate::macro_codegen::__if_codegen! {
if (#$is_safe) {
/// Note that the safe ManuallyDrop checks to see if the value is freed when the safe ManuallyDrop struct dies.
/// The version of mem::forget is adapted for safe and insecure ManuallyDrop.
Expand Down Expand Up @@ -631,7 +631,7 @@ macro_rules! __codegen {
PartialEq::eq(value, a)
}

// why?: We make a complete redirect to another trait, even if this function is not implemented, it is better to leave it as it is for now.
// clippy::partialeq_ne_impl why?: We make a complete redirect to another trait, even if this function is not implemented, it is better to leave it as it is for now.
#[allow(clippy::partialeq_ne_impl)]
#[inline]
fn ne(&self, a: &Self) -> bool {
Expand All @@ -646,7 +646,7 @@ macro_rules! __codegen {
PartialEq::eq(self as &T, a)
}

// why?: We make a complete redirect to another trait, even if this function is not implemented, it is better to leave it as it is for now.
// clippy::partialeq_ne_impl why?: We make a complete redirect to another trait, even if this function is not implemented, it is better to leave it as it is for now.
#[allow(clippy::partialeq_ne_impl)]
#[inline]
fn ne(&self, a: &T) -> bool {
Expand All @@ -660,7 +660,7 @@ macro_rules! __codegen {
PartialEq::eq(self as &T, a)
}

// why?: We make a complete redirect to another trait, even if this function is not implemented, it is better to leave it as it is for now.
// clippy::partialeq_ne_impl why?: We make a complete redirect to another trait, even if this function is not implemented, it is better to leave it as it is for now.
#[allow(clippy::partialeq_ne_impl)]
#[inline]
fn ne(&self, a: &UnsafeStdManuallyDrop<T>) -> bool {
Expand Down
14 changes: 5 additions & 9 deletions tests/all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,23 +188,19 @@ fn test_panic_mode() {

// Start test panic methods
// START POS
// why?: this is only needed for internal tests, the logic can be traced, there should be no other meaning here
// clippy::type_complexity why?: this is only needed for internal tests, the logic can be traced, there should be no other meaning here
#[allow(clippy::type_complexity)]
// rustfmt::skip why? rustfmt strangely formats this section of code, spreads it over several lines and adds commas
#[rustfmt::skip]
let arr_fn: &[(bool, fn(a: Vec<String>))] = &[
(true, panic_test_methods::test_combo_drop as _),
(true, panic_test_methods::test_drop_and_read as _),
(true, panic_test_methods::test_take_and_read as _),
(true, panic_test_methods::test_take_and_drop as _),
(true, panic_test_methods::test_drop_and_into_inner as _),
(true, panic_test_methods::test_expmanualdrop as _),
(
false,
panic_test_methods::test_expmanualdrop2_ignorepanic as _,
),
(
false,
panic_test_methods::test_expmanualdrop3_ignorepanic as _,
),
(false, panic_test_methods::test_expmanualdrop2_ignorepanic as _),
(false, panic_test_methods::test_expmanualdrop3_ignorepanic as _),
];

let mut c_ignore_panic = 0;
Expand Down

0 comments on commit 3f5e456

Please sign in to comment.