Skip to content

chore: declare rust-version and forbid unsafe_code in manifests#352

Open
e-desouza wants to merge 3 commits into
mainfrom
fix/issue-350-351-cargo-hygiene
Open

chore: declare rust-version and forbid unsafe_code in manifests#352
e-desouza wants to merge 3 commits into
mainfrom
fix/issue-350-351-cargo-hygiene

Conversation

@e-desouza

Copy link
Copy Markdown
Collaborator

Why

Two hardening gaps were identified in the manifest files:

  1. No declared MSRVCargo.toml had no rust-version field, so the documented MSRV of 1.87 was unenforced. xrpl-rust-macros uses edition = "2024" (requires Rust ≥ 1.85) with no corresponding guard. Downstream users on older toolchains received cryptic proc-macro errors instead of a clear MSRV message. Closes chore: declare rust-version = "1.87" in Cargo.toml (MSRV enforcement) #351.

  2. No unsafe_code lint guard — The crate contains no unsafe blocks, but without forbid(unsafe_code) nothing prevents a future contribution from silently adding raw pointer operations into deserialization paths that process untrusted XRPL network data. Closes chore: add [lints] table with unsafe_code = "forbid" to Cargo.toml #350.

What changed

  • Cargo.toml: added rust-version = "1.87" and [lints.rust] unsafe_code = "forbid"
  • xrpl-rust-macros/Cargo.toml: added rust-version = "1.85" (matches edition = "2024" requirement)

How to validate

# MSRV guard works
rustup toolchain install 1.86
cargo +1.86 check 2>&1 | grep "rust-version"
# → error: package `xrpl-rust v1.2.0` cannot be built because it requires rustc >= 1.87.0

# unsafe_code guard works
# Add `unsafe { }` anywhere in src/ and verify:
# → error: usage of an `unsafe` block

# Normal build still works
cargo check --all-features
cargo clippy --all-features -- -D warnings

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.71%. Comparing base (c83df4f) to head (01f4002).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #352   +/-   ##
=======================================
  Coverage   86.71%   86.71%           
=======================================
  Files         252      252           
  Lines       32630    32630           
=======================================
  Hits        28296    28296           
  Misses       4334     4334           
Flag Coverage Δ
integration 71.32% <ø> (ø)
unit 87.33% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the crate manifests by enforcing explicit MSRV constraints via rust-version and preventing introduction of unsafe blocks via Cargo’s manifest lint configuration.

Changes:

  • Added rust-version = "1.87" to the root xrpl-rust manifest to enforce the documented MSRV.
  • Added rust-version = "1.85" to xrpl-rust-macros to match the Rust 2024 edition minimum requirement.
  • Added [lints.rust] unsafe_code = "forbid" to the root manifest to prevent unsafe code from compiling.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
Cargo.toml Enforces MSRV 1.87 and forbids unsafe blocks via manifest lints.
xrpl-rust-macros/Cargo.toml Adds an explicit MSRV guard for the proc-macro crate (Rust 1.85 for edition 2024).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 3 to 6
version = "0.1.0"
edition = "2024"
rust-version = "1.85"
description = "XRPL Rust Macros"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 284aa4c: Added [lints.rust] unsafe_code = "forbid" to xrpl-rust-macros/Cargo.toml. Both crates now declare the lint gate.

Comment thread Cargo.toml
- Add rust-version = "1.87" to xrpl-rust (enforces documented MSRV at
  cargo level; downstream consumers get a clear error instead of cryptic
  proc-macro failures on older toolchains)
- Add rust-version = "1.85" to xrpl-rust-macros (edition = "2024"
  already requires 1.85; now declared explicitly)
- Add [lints.rust] unsafe_code = "forbid" to xrpl-rust (crate contains
  no unsafe code; guard prevents silent introduction into
  deserialization paths that process untrusted XRPL network data)

Closes #350, closes #351
@e-desouza
e-desouza force-pushed the fix/issue-350-351-cargo-hygiene branch from 01f4002 to 27741ca Compare July 15, 2026 16:28
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.

chore: declare rust-version = "1.87" in Cargo.toml (MSRV enforcement) chore: add [lints] table with unsafe_code = "forbid" to Cargo.toml

2 participants