Skip to content

Enable additional clippy unsafe lints in SDK (Fixes #172)#356

Open
anand9125 wants to merge 2 commits intoanza-xyz:mainfrom
anand9125:issue-172-unsafe-lints
Open

Enable additional clippy unsafe lints in SDK (Fixes #172)#356
anand9125 wants to merge 2 commits intoanza-xyz:mainfrom
anand9125:issue-172-unsafe-lints

Conversation

@anand9125
Copy link

Fixes #172

Summary

Enables additional Clippy safety lints for the pinocchio SDK and updates the library code to satisfy them.

What was done

1. Clippy lints enabled (SDK only)

In sdk/Cargo.toml, the pinocchio crate now enables:

  • clippy::undocumented_unsafe_blocks = "warn"
  • clippy::multiple_unsafe_ops_per_block = "warn"

2. SDK updated to satisfy lints

  • Added safety comments to unsafe blocks/impls across SDK modules:

    • entrypoint
    • sysvars
    • instructions
    • slot_hashes
  • Split blocks containing multiple unsafe operations where required
    (notably in instructions.rs and slot_hashes/mod.rs)

  • Updated deprecated logic:

    • Rent::is_exempt now uses try_minimum_balance instead of minimum_balance

3. Tests handling

Test-only code is excluded from these lints via module-level:

#![allow(clippy::undocumented_unsafe_blocks, clippy::multiple_unsafe_ops_per_block)]

Applied in SDK test modules to keep lint enforcement focused on library code.

Scope

Lints are enabled only for the SDK (pinocchio crate).
Program crates remain unchanged to keep this PR focused on the core library.

Verification

  • cargo test (full workspace) → passes
  • cargo +nightly-2025-02-16 clippy --workspace --all-targets --all-features --no-deps -- -D warnings → passes

Notes

No functional behavior changes intended.
This PR focuses on lint enforcement, safety documentation, and code clarity.

@anand9125
Copy link
Author

Opened PR implementing the additional SDK clippy lints. Happy to revise if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider enabling more lints

1 participant