rust/compiler
bors 9062b780b3 Auto merge of #101558 - JhonnyBillM:session-diagnostic-to-diagnostic-handler-refactor, r=davidtwco
Move and rename `SessionDiagnostic` & `SessionSubdiagnostic` traits and macros

After PR #101434, we want to:
- [x] Move `SessionDiagnostic` to `rustc_errors`.
- [x] Add `emit_` methods that accept `impl SessionDiagnostic` to `Handler`.
- [x] _(optional)_ Rename trait `SessionDiagnostic` to `DiagnosticHandler`.
- [x] _(optional)_ Rename macro `SessionDiagnostic` to `DiagnosticHandler`.
- [x] Update Rustc Dev Guide and Docs to reflect these changes. https://github.com/rust-lang/rustc-dev-guide/pull/1460

Now I am having build issues getting the compiler to build when trying to rename the macro.

<details>
  <summary>See diagnostics errors and context when building.</summary>

```
error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
  --> compiler/rustc_attr/src/session_diagnostics.rs:13:10
   |
13 |   #[derive(DiagnosticHandler)]
   |            ^^^^^^^^^^^^^^^^^ in this derive macro expansion
   |
  ::: /Users/jhonny/.cargo/registry/src/github.com-1ecc6299db9ec823/synstructure-0.12.6/src/macros.rs:94:9
   |
94 | /         pub fn $derives(
95 | |             i: $crate::macros::TokenStream
96 | |         ) -> $crate::macros::TokenStream {
   | |________________________________________- in this expansion of `#[derive(DiagnosticHandler)]`
   |
note: the lint level is defined here
  --> compiler/rustc_attr/src/lib.rs:10:9
   |
10 | #![deny(rustc::diagnostic_outside_of_impl)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

```

And also this one:

```
error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
   --> compiler/rustc_attr/src/session_diagnostics.rs:213:32
    |
213 |         let mut diag = handler.struct_span_err_with_code(
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^
```

> **Note**
> Can't find where this message is coming from, because you can see in [this experimental branch](https://github.com/JhonnyBillM/rust/tree/experimental/trying-to-rename-session-diagnostic-macro)  that I updated all errors and diags to say:
> error: diagnostics should only be created in **`DiagnosticHandler`**/`AddSubdiagnostic` impls
> and not:
> error: diagnostics should only be created in **`SessionDiagnostic`**/`AddSubdiagnostic` impls

</details>

I tried building the compiler in different ways (playing with the stages etc), but nothing worked.

## Question

**Do we need to build or do something different when renaming a macro and identifiers?**

For context, see experimental commit f2193a98b4 where the macro and symbols are renamed, but it doesn't compile.
2022-09-21 19:58:39 +00:00
..
rustc
rustc_apfloat
rustc_arena
rustc_ast
rustc_ast_lowering FIX - adopt new Diagnostic naming in newly migrated modules 2022-09-21 11:43:22 -04:00
rustc_ast_passes UPDATE - rename SessionSubdiagnostic macro to Subdiagnostic 2022-09-21 11:39:53 -04:00
rustc_ast_pretty
rustc_attr FIX - adopt new Diagnostic naming in newly migrated modules 2022-09-21 11:43:22 -04:00
rustc_borrowck UPDATE - rename SessionSubdiagnostic macro to Subdiagnostic 2022-09-21 11:39:53 -04:00
rustc_builtin_macros UPDATE - rename DiagnosticHandler macro to Diagnostic 2022-09-21 11:39:53 -04:00
rustc_codegen_cranelift Auto merge of #99806 - oli-obk:unconstrained_opaque_type, r=estebank 2022-09-20 12:09:52 +00:00
rustc_codegen_gcc
rustc_codegen_llvm
rustc_codegen_ssa Auto merge of #99806 - oli-obk:unconstrained_opaque_type, r=estebank 2022-09-20 12:09:52 +00:00
rustc_const_eval UPDATE - rename DiagnosticHandler macro to Diagnostic 2022-09-21 11:39:53 -04:00
rustc_data_structures
rustc_driver UPDATE - rename DiagnosticHandler macro to Diagnostic 2022-09-21 11:39:53 -04:00
rustc_error_codes
rustc_error_messages UPDATE - rename SessionSubdiagnostic macro to Subdiagnostic 2022-09-21 11:39:53 -04:00
rustc_errors FIX - adopt new Diagnostic naming in newly migrated modules 2022-09-21 11:43:22 -04:00
rustc_expand FIX - adopt new Diagnostic naming in newly migrated modules 2022-09-21 11:43:22 -04:00
rustc_feature
rustc_fs_util
rustc_graphviz
rustc_hir
rustc_hir_pretty
rustc_incremental
rustc_index
rustc_infer Auto merge of #101558 - JhonnyBillM:session-diagnostic-to-diagnostic-handler-refactor, r=davidtwco 2022-09-21 19:58:39 +00:00
rustc_interface UPDATE - rename DiagnosticHandler macro to Diagnostic 2022-09-21 11:39:53 -04:00
rustc_lexer
rustc_lint FIX - adopt new Diagnostic naming in newly migrated modules 2022-09-21 11:43:22 -04:00
rustc_lint_defs
rustc_llvm
rustc_log
rustc_macros FIX - adopt new Diagnostic naming in newly migrated modules 2022-09-21 11:43:22 -04:00
rustc_metadata Auto merge of #101558 - JhonnyBillM:session-diagnostic-to-diagnostic-handler-refactor, r=davidtwco 2022-09-21 19:58:39 +00:00
rustc_middle FIX - adopt new Diagnostic naming in newly migrated modules 2022-09-21 11:43:22 -04:00
rustc_mir_build Rollup merge of #102021 - lcnr:tyConst-fun, r=b-naber,BoxyUwU 2022-09-20 10:13:01 -07:00
rustc_mir_dataflow UPDATE - rename DiagnosticHandler macro to Diagnostic 2022-09-21 11:39:53 -04:00
rustc_mir_transform Rollup merge of #102045 - RalfJung:const-prop-regression-fix, r=oli-obk 2022-09-21 19:01:08 +05:30
rustc_monomorphize FIX - adopt new Diagnostic naming in newly migrated modules 2022-09-21 11:43:22 -04:00
rustc_parse FIX - adopt new Diagnostic naming in newly migrated modules 2022-09-21 11:43:22 -04:00
rustc_parse_format
rustc_passes FIX - adopt new Diagnostic naming in newly migrated modules 2022-09-21 11:43:22 -04:00
rustc_plugin_impl UPDATE - rename DiagnosticHandler macro to Diagnostic 2022-09-21 11:39:53 -04:00
rustc_privacy UPDATE - rename SessionSubdiagnostic macro to Subdiagnostic 2022-09-21 11:39:53 -04:00
rustc_query_impl
rustc_query_system FIX - adopt new Diagnostic naming in newly migrated modules 2022-09-21 11:43:22 -04:00
rustc_resolve
rustc_save_analysis UPDATE - rename DiagnosticHandler macro to Diagnostic 2022-09-21 11:39:53 -04:00
rustc_serialize Rollup merge of #101014 - isikkema:fix-zmeta-stats-file-encoder-no-read-perms, r=isikkema 2022-09-20 10:12:57 -07:00
rustc_session FIX - adopt new Diagnostic naming in newly migrated modules 2022-09-21 11:43:22 -04:00
rustc_smir
rustc_span FIX - adopt new Diagnostic naming in newly migrated modules 2022-09-21 11:43:22 -04:00
rustc_symbol_mangling UPDATE - rename DiagnosticHandler trait to IntoDiagnostic 2022-09-21 11:39:52 -04:00
rustc_target Auto merge of #101329 - QuinnPainter:armv5te-targets, r=nagisa 2022-09-21 09:36:21 +00:00
rustc_trait_selection FIX - adopt new Diagnostic naming in newly migrated modules 2022-09-21 11:43:22 -04:00
rustc_traits remove the Subst trait, always use EarlyBinder 2022-09-19 11:37:27 +02:00
rustc_transmute
rustc_ty_utils UPDATE - rename SessionSubdiagnostic macro to Subdiagnostic 2022-09-21 11:39:53 -04:00
rustc_type_ir
rustc_typeck UPDATE - rename SessionSubdiagnostic macro to Subdiagnostic 2022-09-21 11:39:53 -04:00