rust-lang / rust-lang/team

Split long Rust files into focused submodules

Open
#2,566 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
363
Forks
369
Avg merge
1d 54m
Merged PRs (30d)
59

Description

Several Rust files are very long. This makes reviewing and editing the code harder.

We should refactor the longest files into smaller submodules based on responsibility.

Examples of long files

Current examples:

  • src/sync/github/mod.rs - ~2,839 lines
  • src/sync/github/tests/mod.rs - ~1,855 lines
  • src/validate.rs - ~1,515 lines
  • src/schema.rs - ~1,117 lines
  • src/sync/github/api/read.rs - ~845 lines
  • src/sync/github/api/mod.rs - ~807 lines
  • src/sync/github/api/write.rs - ~764 lines
  • src/main.rs - ~682 lines
  • src/static_api.rs - ~651 lines

Example: GitHub sync module

src/sync/github/mod.rs currently contains orchestration, repo diffs, team diffs, permissions, rulesets, pages, environments, custom properties, app installations, and formatting logic.
We should only keep the orchestration part.

A possible split:

src/sync/github/
  mod.rs                  # create_diff, SyncGitHub orchestration, shared exports
  apps.rs                 # GithubApp, app installation state/diffs
  teams.rs                # team diffing, team create/update/delete logic
  repos.rs                # RepoDiff, CreateRepoDiff, UpdateRepoDiff
  rulesets.rs             # construct_ruleset, RulesetDiff, ruleset formatting
  environments.rs         # EnvironmentDiff
  pages.rs                # PagesDiff and pages formatting
  custom_properties.rs    # CustomPropertyDiff and value matching
  api/
  tests/

How to solve this issue

Open small PRs that only extract one submodule at a time.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading src/sync/github/mod.rs and the related files under src/sync/github/tests/ to understand the existing responsibilities and module boundaries. Choose one proposed area, such as apps, teams, or repos, and extract only that submodule. The work is done when the original module retains orchestration, behavior remains unchanged, and the relevant tests still pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.