about summary refs log tree commit diff
diff options
context:
space:
mode:
authorjyn <github@jyn.dev>2023-04-29 06:29:07 -0500
committerjyn <github@jyn.dev>2023-05-01 21:44:04 -0500
commit34a71f67d1e28fe0bf13593e26b682d097678875 (patch)
tree0e0d094caab56d010bf7d7c2d0dde83fc290ef55
parentf4c9b4c26f7d28416031129f300b9a9bb5e68641 (diff)
downloadrust-34a71f67d1e28fe0bf13593e26b682d097678875.tar.gz
rust-34a71f67d1e28fe0bf13593e26b682d097678875.zip
Make the BUG_REPORT_URL configurable by tools
This greatly simplifies how hard it is to set a custom bug report url; previously tools had to copy
the entire hook implementation.

- Switch clippy to the new hook

  This also adds a `extra_info` callback so clippy can include its own version number, which differs
  from rustc's.

- Call `install_ice_hook` in rustfmt
-rw-r--r--src/bin/main.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/bin/main.rs b/src/bin/main.rs
index be64559e877..47846424b06 100644
--- a/src/bin/main.rs
+++ b/src/bin/main.rs
@@ -1,3 +1,5 @@
+#![feature(rustc_private)]
+
 use anyhow::{format_err, Result};
 
 use io::Error as IoError;
@@ -19,7 +21,14 @@ use crate::rustfmt::{
     FormatReportFormatterBuilder, Input, Session, Verbosity,
 };
 
+const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rustfmt/issues/new?labels=bug";
+
+// N.B. these crates are loaded from the sysroot, so they need extern crate.
+extern crate rustc_driver;
+
 fn main() {
+    rustc_driver::install_ice_hook(BUG_REPORT_URL, |_| ());
+
     env_logger::Builder::from_env("RUSTFMT_LOG").init();
     let opts = make_opts();