rust/compiler/rustc_codegen_ssa/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
..
back Stop using String for error codes. 2024-01-29 07:41:41 +11:00
debuginfo Auto merge of #119258 - compiler-errors:closure-kind, r=eholk 2023-12-26 04:25:53 +00:00
mir Do not normalize closure signature when building FnOnce shim 2024-01-22 16:50:30 +00:00
traits Auto merge of #118705 - WaffleLapkin:codegen-atomic-exhange-untuple, r=cjgillot 2023-12-30 07:42:19 +00:00
assert_module_sources.rs rustc_codegen_ssa: Enforce rustc::potential_query_instability lint 2024-01-13 16:05:53 +01:00
base.rs Auto merge of #119409 - Kobzol:rustc-codegen-ssa-query-instability, r=Nilstrieb 2024-01-13 18:07:59 +00:00
codegen_attrs.rs Stop using String for error codes. 2024-01-29 07:41:41 +11:00
common.rs move ConstValue into mir 2023-09-19 11:11:02 +02:00
errors.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
meth.rs cg_ssa: remove pointee types and pointercast/bitcast-of-ptr 2023-07-29 13:18:20 -04:00
mono_item.rs Fix clippy::needless_borrow in the compiler 2023-11-21 20:13:40 +01:00
size_of_val.rs fix computing the dynamic alignment of packed structs with dyn trait tails 2023-12-13 20:21:57 +01:00
target_features.rs Add check for ui_testing via promoting parameters from ParseSess to Session 2024-01-13 12:11:13 -05:00