Open matthiaskrgr opened 9 months ago
13 of the panic!()
cases are in comments, 4 are not in .rs
files, and 2 are in rustc_codegen_cranelift
as example code.
That leaves 24 unlabeled panics, as far as I can tell:
rustc_expand/src/parse/tests.rs
325: let ast::ItemKind::Mod(_, mod_kind) = &item.kind else { panic!() };
rustc_hir_pretty/src/lib.rs
2182: _ => panic!(),
rustc_metadata/src/creader.rs
599: _ => panic!(),
rustc_resolve/src/late.rs
2540: panic!()
rustc_hir_analysis/src/collect/type_of.rs
23: let Node::AnonConst(_) = tcx.hir().get(hir_id) else { panic!() };
rustc_span/src/caching_source_map_view.rs
208: panic!();
rustc_middle/src/dep_graph/dep_node.rs
110: panic!();
rustc_ast_pretty/src/pprust/state.rs
1558: _ => panic!(),
rustc_ast_lowering/src/path.rs
288: Some(_) => panic!(),
rustc_abi/src/layout.rs
603: _ => panic!(),
631: panic!();
684: _ => panic!(),
761: _ => panic!(),
1157: _ => panic!(),
rustc_lint/src/early.rs
317: panic!()
rustc_lint/src/passes.rs
128: panic!()
243: panic!()
rustc_lint/src/late.rs
330: panic!()
rustc_query_system/src/query/plumbing.rs
174: QueryResult::Poisoned => panic!(),
195: QueryResult::Poisoned => panic!(),
rustc_codegen_gcc/src/common.rs
254: panic!()
rustc_codegen_gcc/src/builder.rs
1160: panic!();
1191: panic!();
I'll take a stab at annotating some of the ones in rustc_hir*
, rustc_trait*
, and rustc_infer
.
Assuming the currently outstanding PRs are accepted, the remaining unlabeled panic!()
instances are in rustc_codegen_gcc
, rustc_lint
, rustc_metadata
, rustc_query_system
, and rustc_resolve
.
I have not even glanced at where all the unreachable!()
instances are since there are... many.
would it be worth it to add an internal lint for this?
Update (2024-02-27):
git grep "[^e]bug\!()" compiler | count 111
git grep "panic\!()" compiler | count 30
git grep "unreachable\!()" compiler | count 358
I wonder if it makes sense to try to fill these up with at least somewhat contextual error/ice messages instead of just a "panicked at" or "impossible case reached"?
Unfortunately I could not find a rustc lint that warns on empty panics like these