Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/hyperlight_common/clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
disallowed-macros = [
{ path = "std::assert", reason = "no asserts in release builds" },
{ path = "std::assert_eq", reason = "no asserts in release builds" },
{ path = "std::assert_ne", reason = "no asserts in release builds" },
]
10 changes: 10 additions & 0 deletions src/hyperlight_common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ limitations under the License.
#![cfg_attr(not(any(test, debug_assertions)), warn(clippy::panic))]
#![cfg_attr(not(any(test, debug_assertions)), warn(clippy::expect_used))]
#![cfg_attr(not(any(test, debug_assertions)), warn(clippy::unwrap_used))]
// clippy.toml disallows assert!/assert_eq!/assert_ne! via disallowed-macros.
// That lint is active by default, so we suppress it globally here, then
// selectively re-enable it for release host builds (feature = "std").
// Guest targets (no std) are allowed asserts — panics are contained in the
// micro-VM and cannot crash the host. Tests and debug builds are also allowed.
#![allow(clippy::disallowed_macros)]
#![cfg_attr(
not(any(test, debug_assertions, not(feature = "std"))),
warn(clippy::disallowed_macros)
)]
// We use Arbitrary during fuzzing, which requires std
#![cfg_attr(not(feature = "fuzzing"), no_std)]

Expand Down
1 change: 1 addition & 0 deletions src/hyperlight_common/src/version_note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ impl<const NAME_SZ: usize, const DESC_SZ: usize> ElfNote<NAME_SZ, DESC_SZ> {
///
/// Panics at compile time if `NAME_SZ` or `DESC_SZ` don't match
/// `padded_name_size(name.len() + 1)` or `padded_desc_size(desc.len() + 1)`.
#[allow(clippy::disallowed_macros)] // These asserts are evaluated at compile time only (const fn).
pub const fn new(name: &str, desc: &str, n_type: u32) -> Self {
// NAME_SZ and DESC_SZ must match the padded sizes.
assert!(
Expand Down
Loading