about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-09-21 19:58:39 +0000
committerbors <bors@rust-lang.org>2022-09-21 19:58:39 +0000
commit9062b780b32d2eab060b4432863e085d9504ca5c (patch)
tree5b2ed54bf5b205ef5a580b3afa387f5a7532d209 /compiler/rustc_trait_selection/src
parentdb4b4d3becf257e7b1c051540fc7e317958d8d2d (diff)
parente52e2344dc574922ce4f8ddfd508f8bfdec3f404 (diff)
downloadrust-9062b780b32d2eab060b4432863e085d9504ca5c.tar.gz
rust-9062b780b32d2eab060b4432863e085d9504ca5c.zip
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 https://github.com/JhonnyBillM/rust/commit/f2193a98b44db3f2af77a878824b152cdf0d34a5 where the macro and symbols are renamed, but it doesn't compile.
Diffstat (limited to 'compiler/rustc_trait_selection/src')
-rw-r--r--compiler/rustc_trait_selection/src/errors.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/compiler/rustc_trait_selection/src/errors.rs b/compiler/rustc_trait_selection/src/errors.rs
index ab0afc54514..5e1b80eae39 100644
--- a/compiler/rustc_trait_selection/src/errors.rs
+++ b/compiler/rustc_trait_selection/src/errors.rs
@@ -1,10 +1,10 @@
-use rustc_errors::{fluent, ErrorGuaranteed, Handler};
-use rustc_macros::SessionDiagnostic;
+use rustc_errors::{fluent, ErrorGuaranteed, Handler, IntoDiagnostic};
+use rustc_macros::Diagnostic;
 use rustc_middle::ty::{PolyTraitRef, Ty, Unevaluated};
-use rustc_session::{Limit, SessionDiagnostic};
+use rustc_session::Limit;
 use rustc_span::{Span, Symbol};
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(trait_selection::dump_vtable_entries)]
 pub struct DumpVTableEntries<'a> {
     #[primary_span]
@@ -13,7 +13,7 @@ pub struct DumpVTableEntries<'a> {
     pub entries: String,
 }
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(trait_selection::unable_to_construct_constant_value)]
 pub struct UnableToConstructConstantValue<'a> {
     #[primary_span]
@@ -21,7 +21,7 @@ pub struct UnableToConstructConstantValue<'a> {
     pub unevaluated: Unevaluated<'a>,
 }
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[help]
 #[diag(trait_selection::auto_deref_reached_recursion_limit, code = "E0055")]
 pub struct AutoDerefReachedRecursionLimit<'a> {
@@ -33,7 +33,7 @@ pub struct AutoDerefReachedRecursionLimit<'a> {
     pub crate_name: Symbol,
 }
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(trait_selection::empty_on_clause_in_rustc_on_unimplemented, code = "E0232")]
 pub struct EmptyOnClauseInOnUnimplemented {
     #[primary_span]
@@ -41,7 +41,7 @@ pub struct EmptyOnClauseInOnUnimplemented {
     pub span: Span,
 }
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(trait_selection::invalid_on_clause_in_rustc_on_unimplemented, code = "E0232")]
 pub struct InvalidOnClauseInOnUnimplemented {
     #[primary_span]
@@ -49,7 +49,7 @@ pub struct InvalidOnClauseInOnUnimplemented {
     pub span: Span,
 }
 
-#[derive(SessionDiagnostic)]
+#[derive(Diagnostic)]
 #[diag(trait_selection::no_value_in_rustc_on_unimplemented, code = "E0232")]
 #[note]
 pub struct NoValueInOnUnimplemented {
@@ -66,7 +66,7 @@ pub struct NegativePositiveConflict<'a> {
     pub positive_impl_span: Result<Span, Symbol>,
 }
 
-impl SessionDiagnostic<'_> for NegativePositiveConflict<'_> {
+impl IntoDiagnostic<'_> for NegativePositiveConflict<'_> {
     fn into_diagnostic(
         self,
         handler: &Handler,