rust/compiler/rustc_middle/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
..
dep_graph Reduce exposure of things. 2023-11-16 16:49:22 +11:00
hir Get rid of the hir_owner query. 2024-01-16 23:49:38 +00:00
hooks Rename hook. 2023-11-01 16:49:18 +00:00
infer don't store const var origins for known vars 2024-01-16 11:06:42 +01:00
middle ScopeTree: remove destruction_scopes as unused 2024-01-26 19:45:00 +03:00
mir interpret: project_downcast: do not ICE for uninhabited variants 2024-01-26 09:01:56 +01:00
query Auto merge of #116167 - RalfJung:structural-eq, r=lcnr 2024-01-26 00:17:00 +00:00
thir Remove thir::Guard 2024-01-05 10:56:59 +00:00
traits Correctly handle normalization in implied bounds 2024-01-17 21:27:34 -05:00
ty Auto merge of #116167 - RalfJung:structural-eq, r=lcnr 2024-01-26 00:17:00 +00:00
util compiler: Lower fn call arg spans down to MIR 2024-01-15 19:07:11 +01:00
arena.rs Make crate_inherent_impls fallible and stop using track_errors for it 2024-01-17 10:02:29 +00:00
error.rs Stop using String for error codes. 2024-01-29 07:41:41 +11:00
lib.rs Remove unused features 2024-01-25 14:01:33 +00:00
lint.rs Rename struct_lint_level as lint_level. 2024-01-23 08:09:08 +11:00
macros.rs Remove Session methods that duplicate DiagCtxt methods. 2023-12-24 08:05:28 +11:00
metadata.rs rustc_metadata: Remove Span from ModChild 2023-04-18 17:25:04 +03:00
tests.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
thir.rs Don't populate yield and resume types after the fact 2024-01-06 18:03:01 +00:00
values.rs Stop using String for error codes. 2024-01-29 07:41:41 +11:00