about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2021-06-29 08:46:14 +0900
committerGitHub <noreply@github.com>2021-06-29 08:46:14 +0900
commit14f333597ed7307f8d6956eadc03ce09f284da82 (patch)
tree0013df49c95419114de2e9c2c789bdf778d90ff6 /compiler/rustc_middle/src
parent22f2332b353c9522b31d004887dd6500aae55901 (diff)
parent934e6058eb5b051eac862d611cbc73e58a09e6dd (diff)
downloadrust-14f333597ed7307f8d6956eadc03ce09f284da82.tar.gz
rust-14f333597ed7307f8d6956eadc03ce09f284da82.zip
Rollup merge of #86671 - m-ou-se:non-fmt-panic-future-incompatible, r=nikomatsakis
Turn non_fmt_panic into a future_incompatible edition lint.

This turns the `non_fmt_panic` lint into a future_incompatible edition lint, so it becomes part of the `rust_2021_compatibility` group. See https://github.com/rust-lang/rust/issues/85894.

This lint produces both warnings about semantical changes (e.g. `panic!("{{")`) and things that will become hard errors (e.g. `panic!("{")`). So I added a `explain_reason: false` that supresses the default "this will become a hard error" or "the semantics will change" message, and instead added a note depending on the situation. (cc `@rylev)`

r? `@nikomatsakis`
Diffstat (limited to 'compiler/rustc_middle/src')
-rw-r--r--compiler/rustc_middle/src/lint.rs11
1 files changed, 8 insertions, 3 deletions
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.