about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Wood <david.wood@huawei.com>2022-03-30 10:04:03 +0100
committerDavid Wood <david.wood@huawei.com>2022-04-05 07:01:03 +0100
commitf0de7df2048497cd701ee9a88ec44e9ac00e282e (patch)
treef6b6fd76d486afe5f66c1381d7f421db72eb6803
parenta52b5072ac9644ce4f8e336c9c1d79f7afe16f9f (diff)
downloadrust-f0de7df2048497cd701ee9a88ec44e9ac00e282e.tar.gz
rust-f0de7df2048497cd701ee9a88ec44e9ac00e282e.zip
macros: update session diagnostic errors
Small commit adding backticks around types and annotations in the error
messages from the session diagnostic derive.

Signed-off-by: David Wood <david.wood@huawei.com>
-rw-r--r--compiler/rustc_macros/src/session_diagnostic.rs18
-rw-r--r--src/test/ui-fulldeps/session-derive-errors.rs16
-rw-r--r--src/test/ui-fulldeps/session-derive-errors.stderr16
3 files changed, 25 insertions, 25 deletions
diff --git a/compiler/rustc_macros/src/session_diagnostic.rs b/compiler/rustc_macros/src/session_diagnostic.rs
index e5376418124..4430e1cdfc5 100644
--- a/compiler/rustc_macros/src/session_diagnostic.rs
+++ b/compiler/rustc_macros/src/session_diagnostic.rs
@@ -224,7 +224,7 @@ impl<'a> SessionDiagnosticDerive<'a> {
                 match builder.kind {
                     None => {
                         span_err(ast.span().unwrap(), "`code` not specified")
-                        .help("use the [code = \"...\"] attribute to set this diagnostic's error code ")
+                        .help("use the `#[code = \"...\"]` attribute to set this diagnostic's error code ")
                         .emit();
                         SessionDiagnosticDeriveError::ErrorHandled.to_compile_error()
                     }
@@ -338,7 +338,7 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
                     other => throw_span_err!(
                         attr.span().unwrap(),
                         &format!(
-                            "`#[{} = ...]` is not a valid SessionDiagnostic struct attribute",
+                            "`#[{} = ...]` is not a valid `SessionDiagnostic` struct attribute",
                             other
                         )
                     ),
@@ -429,7 +429,7 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
                         } else {
                             throw_span_err!(
                                 attr.span().unwrap(),
-                                "the `#[message = \"...\"]` attribute can only be applied to fields of type Span"
+                                "the `#[message = \"...\"]` attribute can only be applied to fields of type `Span`"
                             );
                         }
                     }
@@ -441,14 +441,14 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
                         } else {
                             throw_span_err!(
                                 attr.span().unwrap(),
-                                "The `#[label = ...]` attribute can only be applied to fields of type Span"
+                                "The `#[label = ...]` attribute can only be applied to fields of type `Span`"
                             );
                         }
                     }
                     other => throw_span_err!(
                         attr.span().unwrap(),
                         &format!(
-                            "`#[{} = ...]` is not a valid SessionDiagnostic field attribute",
+                            "`#[{} = ...]` is not a valid `SessionDiagnostic` field attribute",
                             other
                         )
                     ),
@@ -505,7 +505,7 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
                                 list.span().unwrap(),
                                 "missing suggestion message",
                                 |diag| {
-                                    diag.help("provide a suggestion message using #[suggestion(message = \"...\")]")
+                                    diag.help("provide a suggestion message using `#[suggestion(message = \"...\")]`")
                                 }
                             );
                         };
@@ -549,7 +549,7 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
                         } else {
                             throw_span_err!(
                                 info.span.unwrap(),
-                                "type of field annotated with `#[suggestion(...)]` contains more than one Span"
+                                "type of field annotated with `#[suggestion(...)]` contains more than one `Span`"
                             );
                         }
                     } else if type_matches_path(elem, &["rustc_errors", "Applicability"]) {
@@ -575,12 +575,12 @@ impl<'a> SessionDiagnosticDeriveBuilder<'a> {
                 }
 
                 throw_span_err!(info.span.unwrap(), "wrong types for suggestion", |diag| {
-                    diag.help("#[suggestion(...)] on a tuple field must be applied to fields of type `(Span, Applicability)`")
+                    diag.help("`#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`")
                 });
             }
             // If `ty` isn't a `Span` or `(Span, Applicability)` then emit an error.
             _ => throw_span_err!(info.span.unwrap(), "wrong field type for suggestion", |diag| {
-                diag.help("#[suggestion(...)] should be applied to fields of type `Span` or `(Span, Applicability)`")
+                diag.help("`#[suggestion(...)]` should be applied to fields of type `Span` or `(Span, Applicability)`")
             }),
         }
     }
diff --git a/src/test/ui-fulldeps/session-derive-errors.rs b/src/test/ui-fulldeps/session-derive-errors.rs
index 715d0a0490f..05adb35951e 100644
--- a/src/test/ui-fulldeps/session-derive-errors.rs
+++ b/src/test/ui-fulldeps/session-derive-errors.rs
@@ -41,14 +41,14 @@ enum SessionDiagnosticOnEnum {
 #[derive(SessionDiagnostic)]
 #[error = "E0123"]
 #[label = "This is in the wrong place"]
-//~^ ERROR `#[label = ...]` is not a valid SessionDiagnostic struct attribute
+//~^ ERROR `#[label = ...]` is not a valid `SessionDiagnostic` struct attribute
 struct WrongPlace {}
 
 #[derive(SessionDiagnostic)]
 #[error = "E0123"]
 struct WrongPlaceField {
     #[suggestion = "this is the wrong kind of attribute"]
-//~^ ERROR `#[suggestion = ...]` is not a valid SessionDiagnostic field attribute
+    //~^ ERROR `#[suggestion = ...]` is not a valid `SessionDiagnostic` field attribute
     sp: Span,
 }
 
@@ -92,14 +92,14 @@ struct ErrorSpecifiedAfterLint {}
 struct ErrorWithField {
     name: String,
     #[message = "This error has a field, and references {name}"]
-    span: Span
+    span: Span,
 }
 
 #[derive(SessionDiagnostic)]
 #[error = "E0123"]
 struct ErrorWithMessageAppliedToField {
     #[message = "this message is applied to a String field"]
-    //~^ ERROR the `#[message = "..."]` attribute can only be applied to fields of type Span
+    //~^ ERROR the `#[message = "..."]` attribute can only be applied to fields of type `Span`
     name: String,
 }
 
@@ -134,7 +134,7 @@ struct ErrorMissingOpeningBrace {
 #[message = "Something something"]
 struct LabelOnSpan {
     #[label = "See here"]
-    sp: Span
+    sp: Span,
 }
 
 #[derive(SessionDiagnostic)]
@@ -142,7 +142,7 @@ struct LabelOnSpan {
 #[message = "Something something"]
 struct LabelOnNonSpan {
     #[label = "See here"]
-    //~^ ERROR The `#[label = ...]` attribute can only be applied to fields of type Span
+    //~^ ERROR The `#[label = ...]` attribute can only be applied to fields of type `Span`
     id: u32,
 }
 
@@ -204,7 +204,7 @@ struct SuggestWithWrongTypeApplicabilityOnly {
 
 #[derive(SessionDiagnostic)]
 #[error = "E0123"]
-struct SuggestWithSpanOnly{
+struct SuggestWithSpanOnly {
     #[suggestion(message = "This is a message", code = "This is suggested code")]
     suggestion: Span,
 }
@@ -213,7 +213,7 @@ struct SuggestWithSpanOnly{
 #[error = "E0123"]
 struct SuggestWithDuplicateSpanAndApplicability {
     #[suggestion(message = "This is a message", code = "This is suggested code")]
-    //~^ ERROR type of field annotated with `#[suggestion(...)]` contains more than one Span
+    //~^ ERROR type of field annotated with `#[suggestion(...)]` contains more than one `Span`
     suggestion: (Span, Span, Applicability),
 }
 
diff --git a/src/test/ui-fulldeps/session-derive-errors.stderr b/src/test/ui-fulldeps/session-derive-errors.stderr
index c7853f5275e..afe941e2527 100644
--- a/src/test/ui-fulldeps/session-derive-errors.stderr
+++ b/src/test/ui-fulldeps/session-derive-errors.stderr
@@ -9,13 +9,13 @@ LL | |     Bar,
 LL | | }
    | |_^
 
-error: `#[label = ...]` is not a valid SessionDiagnostic struct attribute
+error: `#[label = ...]` is not a valid `SessionDiagnostic` struct attribute
   --> $DIR/session-derive-errors.rs:43:1
    |
 LL | #[label = "This is in the wrong place"]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-error: `#[suggestion = ...]` is not a valid SessionDiagnostic field attribute
+error: `#[suggestion = ...]` is not a valid `SessionDiagnostic` field attribute
   --> $DIR/session-derive-errors.rs:50:5
    |
 LL |     #[suggestion = "this is the wrong kind of attribute"]
@@ -39,9 +39,9 @@ error: `code` not specified
 LL | struct ErrorCodeNotProvided {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: use the [code = "..."] attribute to set this diagnostic's error code 
+   = help: use the `#[code = "..."]` attribute to set this diagnostic's error code 
 
-error: the `#[message = "..."]` attribute can only be applied to fields of type Span
+error: the `#[message = "..."]` attribute can only be applied to fields of type `Span`
   --> $DIR/session-derive-errors.rs:101:5
    |
 LL |     #[message = "this message is applied to a String field"]
@@ -78,7 +78,7 @@ LL | #[message = "This is missing an opening brace: name}"]
    = note: if you intended to print `}`, you can escape it using `}}`
    = note: this error originates in the derive macro `SessionDiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error: The `#[label = ...]` attribute can only be applied to fields of type Span
+error: The `#[label = ...]` attribute can only be applied to fields of type `Span`
   --> $DIR/session-derive-errors.rs:144:5
    |
 LL |     #[label = "See here"]
@@ -102,7 +102,7 @@ error: missing suggestion message
 LL |     #[suggestion(code = "This is suggested code")]
    |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: provide a suggestion message using #[suggestion(message = "...")]
+   = help: provide a suggestion message using `#[suggestion(message = "...")]`
 
 error: wrong field type for suggestion
   --> $DIR/session-derive-errors.rs:200:5
@@ -112,9 +112,9 @@ LL | |
 LL | |     suggestion: Applicability,
    | |_____________________________^
    |
-   = help: #[suggestion(...)] should be applied to fields of type Span or (Span, Applicability)
+   = help: `#[suggestion(...)]` should be applied to fields of type `Span` or `(Span, Applicability)`
 
-error: type of field annotated with `#[suggestion(...)]` contains more than one Span
+error: type of field annotated with `#[suggestion(...)]` contains more than one `Span`
   --> $DIR/session-derive-errors.rs:215:5
    |
 LL | /     #[suggestion(message = "This is a message", code = "This is suggested code")]