about summary refs log tree commit diff
path: root/compiler/rustc_macros/src/diagnostics/utils.rs
diff options
context:
space:
mode:
authorXiretza <xiretza@xiretza.xyz>2022-10-20 21:17:14 +0200
committerXiretza <xiretza@xiretza.xyz>2022-10-26 15:04:09 +0200
commit20f2958b8af32dd08173272a7ede09aaa255c980 (patch)
treeb5b1a6ccb04f195519a69912baad8ec6e2609e2c /compiler/rustc_macros/src/diagnostics/utils.rs
parent29334b951a6ab997d63d72a496454a0455ce5ee2 (diff)
downloadrust-20f2958b8af32dd08173272a7ede09aaa255c980.tar.gz
rust-20f2958b8af32dd08173272a7ede09aaa255c980.zip
Add "tool-only" suggestion style
Diffstat (limited to 'compiler/rustc_macros/src/diagnostics/utils.rs')
-rw-r--r--compiler/rustc_macros/src/diagnostics/utils.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/compiler/rustc_macros/src/diagnostics/utils.rs b/compiler/rustc_macros/src/diagnostics/utils.rs
index aaeb0e1aba9..99ecaaae0e8 100644
--- a/compiler/rustc_macros/src/diagnostics/utils.rs
+++ b/compiler/rustc_macros/src/diagnostics/utils.rs
@@ -474,14 +474,11 @@ pub(super) fn build_suggestion_code(
 /// Possible styles for suggestion subdiagnostics.
 #[derive(Clone, Copy, PartialEq)]
 pub(super) enum SuggestionKind {
-    /// `#[suggestion]`
     Normal,
-    /// `#[suggestion_short]`
     Short,
-    /// `#[suggestion_hidden]`
     Hidden,
-    /// `#[suggestion_verbose]`
     Verbose,
+    ToolOnly,
 }
 
 impl FromStr for SuggestionKind {
@@ -493,6 +490,7 @@ impl FromStr for SuggestionKind {
             "short" => Ok(SuggestionKind::Short),
             "hidden" => Ok(SuggestionKind::Hidden),
             "verbose" => Ok(SuggestionKind::Verbose),
+            "tool-only" => Ok(SuggestionKind::ToolOnly),
             _ => Err(()),
         }
     }
@@ -513,6 +511,9 @@ impl SuggestionKind {
             SuggestionKind::Verbose => {
                 quote! { rustc_errors::SuggestionStyle::ShowAlways }
             }
+            SuggestionKind::ToolOnly => {
+                quote! { rustc_errors::SuggestionStyle::CompletelyHidden }
+            }
         }
     }
 
@@ -583,6 +584,8 @@ impl SubdiagnosticKind {
             "help" => SubdiagnosticKind::Help,
             "warning" => SubdiagnosticKind::Warn,
             _ => {
+                // FIXME(#100717): remove #[suggestion_{short,verbose,hidden}] attributes, use
+                // #[suggestion(style = "...")] instead
                 if let Some(suggestion_kind) =
                     name.strip_prefix("suggestion").and_then(SuggestionKind::from_suffix)
                 {
@@ -719,7 +722,7 @@ impl SubdiagnosticKind {
 
                     let value = value.value().parse().unwrap_or_else(|()| {
                         span_err(value.span().unwrap(), "invalid suggestion style")
-                            .help("valid styles are `normal`, `short`, `hidden` and `verbose`")
+                            .help("valid styles are `normal`, `short`, `hidden`, `verbose` and `tool-only`")
                             .emit();
                         SuggestionKind::Normal
                     });