| Crates.io | cargo-workspace-unused-pub |
| lib.rs | cargo-workspace-unused-pub |
| version | 0.1.0 |
| created_at | 2025-02-25 21:12:48.034098+00 |
| updated_at | 2025-02-25 21:12:48.034098+00 |
| description | Detect unused pub methods in a Rust workspace |
| homepage | |
| repository | https://github.com/cpg314/cargo-workspace-unused-pub |
| max_upload_size | |
| id | 1569673 |
| size | 45,876 |
This cargo subcommand tries to detect pub methods that are unused in an entire workspace, by performing workspace-wide analysis.
The dead_code Rust compiler lint ignores pub methods, given that:
pub methods could be used in another workspace crate, or be part of a public API.See also the following discussions about this problem:
$ cargo workspace-unused-pub --help
Detect unused pub methods in a workspace
Usage: cargo workspace-unused-pub [OPTIONS] [WORKSPACE]
Arguments:
[WORKSPACE] [default: current workspace]
Options:
--scip <SCIP>
--extensions <EXTENSIONS> [default: rs,html]
-h, --help Print help
-V, --version Print version
Detection is performed in multiple phases:
Open an SCIP code index, or generate one with rust-analyzer.
Opened SCIP file with 806 documents
Note that the index generation can take a significant amount of time on large workspaces.
Record methods and traits declarations.
Found 6722 declarations and 286 traits
Phase 1: Find all methods that are seem never used. The following phases aim at removing false positives.
Pass 1: 1419 candidates
Phase 2: Remove false positives stemming from main, tests and trait methods.
Pass 2 (mains, tests, trait methods): 189 candidates
Phase 3: Perform a text search to remove false positives due to e.g. use in HTML templates:
Pass 3 (search): 43 candidates
Found 43 possibly unused functions
The extensions that are searched are defined by the --extensions flag.
Display results:

The output of each phase (in the format above) can be viewed by setting the RUST_LOG=debug environment variable.
cargo-workspace-unused-pub was developed, warnalyzer relied on the removed nightly save-analysis feature, and therefore required an older nightly compiler (see https://github.com/est31/warnalyzer/issues/9). This issue is now addressed, and warnanalyzer has a SCIP backend.