rust/compiler/rustc_passes/src
Nicholas Nethercote 5d9dfbd08f Stop using String for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!

This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.

With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123)  // macro call

struct_span_code_err!(dcx, span, E0123, "msg");  // bare ident arg to macro call

\#[diag(name, code = "E0123")]  // string
struct Diag;
```

With the new code, they all use the `E0123` constant.
```
E0123  // constant

struct_span_code_err!(dcx, span, E0123, "msg");  // constant

\#[diag(name, code = E0123)]  // constant
struct Diag;
```

The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
  used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
  moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
  code constants and the `DIAGNOSTIC_TABLES`. This is in its new
  `codes.rs` file.
2024-01-29 07:41:41 +11:00
..
liveness Match unmatched backticks in compiler/ that are part of rustdoc 2023-03-03 08:39:00 +01:00
abi_test.rs Remove Session methods that duplicate DiagCtxt methods. 2023-12-24 08:05:28 +11:00
check_attr.rs Rename TyCtxt::emit_spanned_lint as TyCtxt::emit_node_span_lint. 2024-01-23 08:09:05 +11:00
check_const.rs Add check for ui_testing via promoting parameters from ParseSess to Session 2024-01-13 12:11:13 -05:00
dead.rs Rebase slice_group_by stabilization PR 2024-01-25 22:20:59 -08:00
debugger_visualizer.rs Add check for ui_testing via promoting parameters from ParseSess to Session 2024-01-13 12:11:13 -05:00
diagnostic_items.rs Remove Session methods that duplicate DiagCtxt methods. 2023-12-24 08:05:28 +11:00
entry.rs Stop using String for error codes. 2024-01-29 07:41:41 +11:00
errors.rs Stop using String for error codes. 2024-01-29 07:41:41 +11:00
hir_id_validator.rs Add DiagCtxt::delayed_bug. 2024-01-10 07:33:07 +11:00
hir_stats.rs Add PatKind::Err 2024-01-17 03:14:16 +01:00
lang_items.rs Delegation implementation: step 1 2024-01-12 14:11:16 +03:00
layout_test.rs Remove Session methods that duplicate DiagCtxt methods. 2023-12-24 08:05:28 +11:00
lib.rs Rebase slice_group_by stabilization PR 2024-01-25 22:20:59 -08:00
lib_features.rs Remove Session methods that duplicate DiagCtxt methods. 2023-12-24 08:05:28 +11:00
liveness.rs Rename TyCtxt::emit_spanned_lint as TyCtxt::emit_node_span_lint. 2024-01-23 08:09:05 +11:00
loops.rs Auto merge of #119258 - compiler-errors:closure-kind, r=eholk 2023-12-26 04:25:53 +00:00
naked_functions.rs Rename TyCtxt::emit_spanned_lint as TyCtxt::emit_node_span_lint. 2024-01-23 08:09:05 +11:00
reachable.rs Move some methods from tcx.hir() to tcx 2023-12-12 06:40:29 -08:00
stability.rs Rename TyCtxt::emit_spanned_lint as TyCtxt::emit_node_span_lint. 2024-01-23 08:09:05 +11:00
upvars.rs is_coroutine -> is_coroutine_or_closure 2023-12-30 15:24:15 +00:00
weak_lang_items.rs Stop mentioning internal lang items in no_std binary errors 2024-01-10 21:18:54 +01:00