rust/compiler/rustc_ty_utils/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
..
abi.rs Rollup merge of #119969 - compiler-errors:simplify-closure-env-ty, r=oli-obk 2024-01-16 17:55:23 +01:00
assoc.rs Move some methods from tcx.hir() to tcx 2023-12-12 06:40:29 -08:00
common_traits.rs Move expansion of query macros in rustc_middle to rustc_middle::query 2023-05-15 08:49:13 +02:00
consts.rs Rollup merge of #119307 - compiler-errors:pat-lifetimes, r=Nadrieril 2023-12-26 13:29:14 -05:00
errors.rs Stop using String for error codes. 2024-01-29 07:41:41 +11:00
implied_bounds.rs Move some methods from tcx.hir() to tcx 2023-12-12 06:40:29 -08:00
instance.rs Rollup merge of #120139 - compiler-errors:fnonce-shim, r=BoxyUwU 2024-01-23 21:53:56 +01:00
layout.rs Rollup merge of #119971 - compiler-errors:zip-eq, r=nnethercote 2024-01-15 08:44:49 +01:00
layout_sanity_check.rs fix failure to detect a too-big-type after adding padding 2023-10-27 18:07:53 +02:00
lib.rs Remove unused features 2024-01-25 14:01:33 +00:00
needs_drop.rs Remove movability from TyKind::Coroutine 2023-12-28 16:35:01 +00:00
opaque_types.rs Limit impl trait in assoc type defining scope 2024-01-22 14:35:46 +00:00
representability.rs Reduce exposure of some items. 2023-11-20 14:10:19 +11:00
sig_types.rs Move some methods from tcx.hir() to tcx 2023-12-12 06:40:29 -08:00
structural_match.rs remove StructuralEq trait 2024-01-24 07:56:23 +01:00
ty.rs Movability doesn't need to be a query anymore 2023-12-28 16:35:01 +00:00