Skip to content

Remove dead diagnostic structs.#155319

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
nnethercote:rm-dead-error-structs
Apr 15, 2026
Merged

Remove dead diagnostic structs.#155319
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
nnethercote:rm-dead-error-structs

Conversation

@nnethercote
Copy link
Copy Markdown
Contributor

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

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.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 14, 2026
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 14, 2026
@nnethercote
Copy link
Copy Markdown
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
done

Catches some false positives, but still very useful.

cc @mejrs

@Kivooeo
Copy link
Copy Markdown
Member

Kivooeo commented Apr 15, 2026

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 15, 2026

📌 Commit f093767 has been approved by Kivooeo

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 15, 2026
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.)
rust-timer added a commit that referenced this pull request Apr 15, 2026
Rollup merge of #155319 - nnethercote:rm-dead-error-structs, r=Kivooeo

Remove dead diagnostic structs.

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
@rust-bors rust-bors bot merged commit aeaa849 into rust-lang:main Apr 15, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 15, 2026
@nnethercote nnethercote deleted the rm-dead-error-structs branch April 15, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants