Remove dead diagnostic structs.#155319
Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom Apr 15, 2026
Merged
Conversation
One of these has a "FIXME(autodiff): I should get used somewhere" comment, but I figure YAGNI applies and it's so small that reinstating it if necessary would be trivial.
Contributor
Author
|
#155301 inspired me to write the following script to find other dead diagnostics: #! /bin/sh
#
# Find potentially dead error types in rustc.
#
# Searches compiler/**/errors.rs for structs and enums that are unused outside
# of the defining file.
#
# False positives can occur for types that are used meaningfully but only
# within the defining file. This is moderately common.
#
# False negatives can occur if there are two or more types with the same name
# in different files. This is rarer?
# Find all `.rs` files containing `#[derive(Diagnostic)]`.
fs=`git grep -l '#\[derive(Diagnostic)\]' 'compiler/**/*.rs'`
for f in $fs; do
echo "---------"
echo $f
# Find all structs and enums in these files.
ts=`sed -n 's/^pub.*\(struct\|enum\) \([A-Za-z0-9_]*\).*/\2/p' $f`
# For each struct/enum, search for a use outside the defining file. If
# none, it might be dead.
for t in $ts ; do
#echo "*** $t"
m=`git grep "\b$t\b" -- ":!$f"`
#echo "^^^ $m"
if [ -z "$m" ] ; then
echo "DEAD? $t"
fi
done
doneCatches some false positives, but still very useful. cc @mejrs |
Member
|
@bors r+ rollup |
Contributor
rust-bors bot
pushed a commit
that referenced
this pull request
Apr 15, 2026
Rollup of 13 pull requests Successful merges: - #154882 (Gate tuple const params behind `min_adt_const_params` feature) - #155259 (explicit-tail-calls: disable two tests on LoongArch) - #155293 (fix arch names in cfg pretty printer) - #155314 (`BorrowedBuf`: Update outdated safety comments in `set_init` users.) - #153469 (docs: clarify path search behavior in std::process::Command::new) - #154765 (Clarify ascii whitespace exclusion of vertical tab in the doc) - #155172 (Some small nits for supertrait_item_shadowing, and additional testing) - #155279 (Test/lexer unicode pattern white space) - #155280 (Tests for precise-capture through RPIT and TAIT) - #155301 (Delete unused `rustc_trait_selection` errors.) - #155303 (remove ibraheemdev from review rotation) - #155304 (remove PointeeParser) - #155319 (Remove dead diagnostic structs.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One of these has a "FIXME(autodiff): I should get used somewhere" comment, but I figure YAGNI applies and it's so small that reinstating it if necessary would be trivial.
r? @Kivooeo