about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2021-06-27 14:45:54 +0000
committerMara Bos <m-ou.se@m-ou.se>2021-06-27 15:04:49 +0000
commit4645679d35378a7134cd8d77e0b2a5164f6ea127 (patch)
treef7105af6e1d844e0c095f08496c6df7050abe14b
parent543ab9964065dc2b4e47d7bff5e83c84519f265e (diff)
downloadrust-4645679d35378a7134cd8d77e0b2a5164f6ea127.tar.gz
rust-4645679d35378a7134cd8d77e0b2a5164f6ea127.zip
Add `explain_reason: false` in future_incompatible.
This allows supressing the default warning message for future
incompatible ints, for lints that already provide a more detailed
warning.
-rw-r--r--compiler/rustc_lint_defs/src/lib.rs6
-rw-r--r--compiler/rustc_middle/src/lint.rs11
2 files changed, 14 insertions, 3 deletions
diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs
index b3d98747dcf..98e3a7069c2 100644
--- a/compiler/rustc_lint_defs/src/lib.rs
+++ b/compiler/rustc_lint_defs/src/lib.rs
@@ -145,6 +145,11 @@ pub struct FutureIncompatibleInfo {
     /// The reason for the lint used by diagnostics to provide
     /// the right help message
     pub reason: FutureIncompatibilityReason,
+    /// Whether to explain the reason to the user.
+    ///
+    /// Set to false for lints that already include a more detailed
+    /// explanation.
+    pub explain_reason: bool,
     /// Information about a future breakage, which will
     /// be emitted in JSON messages to be displayed by Cargo
     /// for upstream deps
@@ -185,6 +190,7 @@ impl FutureIncompatibleInfo {
         FutureIncompatibleInfo {
             reference: "",
             reason: FutureIncompatibilityReason::FutureReleaseError,
+            explain_reason: true,
             future_breakage: None,
         }
     }
diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs
index 8180d853f60..8d0fdf9128a 100644
--- a/compiler/rustc_middle/src/lint.rs
+++ b/compiler/rustc_middle/src/lint.rs
@@ -398,9 +398,14 @@ pub fn struct_lint_level<'s, 'd>(
                  it will become a hard error in a future release!"
                     .to_owned()
             };
-            let citation = format!("for more information, see {}", future_incompatible.reference);
-            err.warn(&explanation);
-            err.note(&citation);
+            if future_incompatible.explain_reason {
+                err.warn(&explanation);
+            }
+            if !future_incompatible.reference.is_empty() {
+                let citation =
+                    format!("for more information, see {}", future_incompatible.reference);
+                err.note(&citation);
+            }
         }
 
         // Finally, run `decorate`. This function is also responsible for emitting the diagnostic.