rust-lang / rust-lang/rust-clippy

Suggest opportunities for type size reduction by boxing enum content

Open
#4,831 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lint
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

I have a huge Rust project which is using a lot of RAM unnecessarily and there are no RAM profilers for Windows that show what the memory is used for, but I found out the huge RAM usage is because I have a lot of struct instances containing large fixed size arrays/vecs of Option<T> where T is potentially huge (because it itself contains fixed size arrays and other such types etc.).
It would be very useful to be able to find out opportunities for type size reduction by boxing, e.g. changing a struct member from Vec<Option<Huge>> to Vec<Option<box Huge>>.
Could this kind of suggestion be added to clippy? :)
So that it's easier to track down all such instances of this situation..
It should be able to detect this for other enums than Option as well.

In addition to that, it would be nice if there was a way to output a list of the largest types (structs/enums) in a crate, descending by size, to get an overview..

Contributor guide

Open the contributing guide

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

No files, tests, or entry points are named. Start by narrowing the request to either enum-boxing suggestions or largest-type reporting, then define the expected output and tests for the selected feature.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.