Skip to content

fix: use auto_impl to simplify trait implemention for (&, Box, Arc)#6742

Merged
LesnyRumcajs merged 1 commit intomainfrom
hm/auto-impl
Mar 16, 2026
Merged

fix: use auto_impl to simplify trait implemention for (&, Box, Arc)#6742
LesnyRumcajs merged 1 commit intomainfrom
hm/auto-impl

Conversation

@hanabi1224
Copy link
Contributor

@hanabi1224 hanabi1224 commented Mar 16, 2026

Summary of changes

Changes introduced in this pull request:

Reference issue to close (if applicable)

Closes

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Outside contributions

  • I have read and agree to the CONTRIBUTING document.
  • I have read and agree to the AI Policy document. I understand that failure to comply with the guidelines will lead to rejection of the pull request.

Summary by CodeRabbit

  • Chores
    • Added a new build dependency.
    • Internal code refactored to reduce boilerplate implementations across multiple modules while preserving all existing functionality.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b8b2c0e3-dc43-4601-ab51-c221381e86ad

📥 Commits

Reviewing files that changed from the base of the PR and between c7d9ba6 and 4108dff.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • Cargo.toml
  • src/db/blockstore_with_read_cache.rs
  • src/db/car/forest/index/mod.rs
  • src/db/mod.rs
  • src/libp2p_bitswap/store.rs

Walkthrough

This change introduces the auto_impl crate as a dependency and applies the #[auto_impl] macro attribute to multiple traits across the codebase. Manual blanket trait implementations for Arc and reference types are replaced with automatic macro-generated implementations, eliminating boilerplate code while maintaining identical trait behavior.

Changes

Cohort / File(s) Summary
Dependency Addition
Cargo.toml
Added auto_impl = "1" dependency to enable procedural macro-based trait implementations.
Blockstore Trait Refactoring
src/db/blockstore_with_read_cache.rs
Added #[auto_impl::auto_impl(&, Arc)] to BlockstoreReadCache; added new put() method; removed manual blanket Arc implementation.
Writable Trait Refactoring
src/db/car/forest/index/mod.rs
Added #[auto_impl::auto_impl(&)] to Writable trait; added associated constant LEN: u64; removed manual blanket reference implementation for &T.
Database Traits Refactoring
src/db/mod.rs
Added #[auto_impl::auto_impl(&, Arc)] to five traits (SettingsStore, EthMappingsStore, PersistentStore, HeaviestTipsetKeyProvider, BlockstoreWriteOpsSubscribable); removed corresponding manual blanket Arc implementations.
Bitswap Store Traits Refactoring
src/libp2p_bitswap/store.rs
Added #[auto_impl::auto_impl(&, Arc)] to BitswapStoreRead and BitswapStoreReadWrite; removed manual blanket Arc implementations; added PhantomData import.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • LesnyRumcajs
  • sudo-shashank
  • akaladarshi
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: refactoring trait implementations to use the auto_impl crate for automatic implementations of (&, Box, Arc) instead of manual blanket implementations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hm/auto-impl
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch hm/auto-impl
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@hanabi1224 hanabi1224 marked this pull request as ready for review March 16, 2026 00:04
@hanabi1224 hanabi1224 requested a review from a team as a code owner March 16, 2026 00:04
@hanabi1224 hanabi1224 requested review from LesnyRumcajs and sudo-shashank and removed request for a team March 16, 2026 00:04
Copy link
Member

@LesnyRumcajs LesnyRumcajs left a comment

Choose a reason for hiding this comment

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

I like it

@LesnyRumcajs LesnyRumcajs added this pull request to the merge queue Mar 16, 2026
Merged via the queue into main with commit e2a5f15 Mar 16, 2026
40 checks passed
@LesnyRumcajs LesnyRumcajs deleted the hm/auto-impl branch March 16, 2026 09:10
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.

2 participants