about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-07-20 01:29:17 +0000
committerbors <bors@rust-lang.org>2023-07-20 01:29:17 +0000
commita6cdd81eff52566542cecdc1ce381dbe42cf77fb (patch)
treed8c79736ebadbccb2caf9477add711b55a7c6151 /src
parent39f42ad9e8430a8abb06c262346e89593278c515 (diff)
parent217d97adb85d072c3d567cd8801021d3dc96223c (diff)
downloadrust-a6cdd81eff52566542cecdc1ce381dbe42cf77fb.tar.gz
rust-a6cdd81eff52566542cecdc1ce381dbe42cf77fb.zip
Auto merge of #108714 - estebank:ice_dump, r=oli-obk
On nightly, dump ICE backtraces to disk

Implement rust-lang/compiler-team#578.

When an ICE is encountered on nightly releases, the new rustc panic handler will also write the contents of the backtrace to disk. If any `delay_span_bug`s are encountered, their backtrace is also added to the file. The platform and rustc version will also be collected.

<img width="1032" alt="Screenshot 2023-03-03 at 2 13 25 PM" src="https://user-images.githubusercontent.com/1606434/222842420-8e039740-4042-4563-b31d-599677171acf.png">

The current behavior will *always* write to disk on nightly builds, regardless of whether the backtrace is printed to the terminal, unless the environment variable `RUSTC_ICE_DISK_DUMP` is set to `0`. This is a compromise and can be changed.
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/core.rs2
-rw-r--r--src/librustdoc/doctest.rs5
-rw-r--r--src/librustdoc/passes/lint/check_code_block_syntax.rs2
-rw-r--r--src/tools/clippy/clippy_lints/src/doc.rs2
-rw-r--r--src/tools/compiletest/src/header.rs2
-rw-r--r--src/tools/rustfmt/src/parse/session.rs3
-rw-r--r--src/tools/tidy/src/deps.rs3
7 files changed, 13 insertions, 6 deletions
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs
index 82a1fe310b3..7fb069d6e70 100644
--- a/src/librustdoc/core.rs
+++ b/src/librustdoc/core.rs
@@ -176,6 +176,7 @@ pub(crate) fn new_handler(
     rustc_errors::Handler::with_emitter_and_flags(
         emitter,
         unstable_opts.diagnostic_handler_flags(true),
+        None,
     )
 }
 
@@ -296,6 +297,7 @@ pub(crate) fn create_config(
         }),
         make_codegen_backend: None,
         registry: rustc_driver::diagnostics_registry(),
+        ice_file: None,
     }
 }
 
diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs
index 6047cf23350..6766dcba18a 100644
--- a/src/librustdoc/doctest.rs
+++ b/src/librustdoc/doctest.rs
@@ -108,6 +108,7 @@ pub(crate) fn run(options: RustdocOptions) -> Result<(), ErrorGuaranteed> {
         override_queries: None,
         make_codegen_backend: None,
         registry: rustc_driver::diagnostics_registry(),
+        ice_file: None,
     };
 
     let test_args = options.test_args.clone();
@@ -586,7 +587,7 @@ pub(crate) fn make_test(
             );
 
             // FIXME(misdreavus): pass `-Z treat-err-as-bug` to the doctest parser
-            let handler = Handler::with_emitter(false, None, Box::new(emitter));
+            let handler = Handler::with_emitter(false, None, Box::new(emitter), None);
             let sess = ParseSess::with_span_handler(handler, sm);
 
             let mut found_main = false;
@@ -773,7 +774,7 @@ fn check_if_attr_is_complete(source: &str, edition: Edition) -> bool {
                 TerminalUrl::No,
             );
 
-            let handler = Handler::with_emitter(false, None, Box::new(emitter));
+            let handler = Handler::with_emitter(false, None, Box::new(emitter), None);
             let sess = ParseSess::with_span_handler(handler, sm);
             let mut parser =
                 match maybe_new_parser_from_source_str(&sess, filename, source.to_owned()) {
diff --git a/src/librustdoc/passes/lint/check_code_block_syntax.rs b/src/librustdoc/passes/lint/check_code_block_syntax.rs
index 369a8069593..c82f2bc987a 100644
--- a/src/librustdoc/passes/lint/check_code_block_syntax.rs
+++ b/src/librustdoc/passes/lint/check_code_block_syntax.rs
@@ -40,7 +40,7 @@ fn check_rust_syntax(
     let emitter = BufferEmitter { buffer: Lrc::clone(&buffer), fallback_bundle };
 
     let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
-    let handler = Handler::with_emitter(false, None, Box::new(emitter));
+    let handler = Handler::with_emitter(false, None, Box::new(emitter), None);
     let source = dox[code_block.code].to_owned();
     let sess = ParseSess::with_span_handler(handler, sm);
 
diff --git a/src/tools/clippy/clippy_lints/src/doc.rs b/src/tools/clippy/clippy_lints/src/doc.rs
index e5f39d102cd..8879c529262 100644
--- a/src/tools/clippy/clippy_lints/src/doc.rs
+++ b/src/tools/clippy/clippy_lints/src/doc.rs
@@ -729,7 +729,7 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) {
                     false,
                     TerminalUrl::No,
                 );
-                let handler = Handler::with_emitter(false, None, Box::new(emitter));
+                let handler = Handler::with_emitter(false, None, Box::new(emitter), None);
                 let sess = ParseSess::with_span_handler(handler, sm);
 
                 let mut parser = match maybe_new_parser_from_source_str(&sess, filename, code) {
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index d67e9aaaa6e..4ae2249097f 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -232,7 +232,7 @@ impl TestProps {
             aux_builds: vec![],
             aux_crates: vec![],
             revisions: vec![],
-            rustc_env: vec![],
+            rustc_env: vec![("RUSTC_ICE".to_string(), "0".to_string())],
             unset_rustc_env: vec![],
             exec_env: vec![],
             unset_exec_env: vec![],
diff --git a/src/tools/rustfmt/src/parse/session.rs b/src/tools/rustfmt/src/parse/session.rs
index 81b5015dde3..92d2425cd3b 100644
--- a/src/tools/rustfmt/src/parse/session.rs
+++ b/src/tools/rustfmt/src/parse/session.rs
@@ -162,6 +162,7 @@ fn default_handler(
             ignore_path_set,
             can_reset,
         }),
+        None,
     )
 }
 
@@ -233,7 +234,7 @@ impl ParseSess {
     }
 
     pub(crate) fn set_silent_emitter(&mut self) {
-        self.parse_sess.span_diagnostic = Handler::with_emitter(true, None, silent_emitter());
+        self.parse_sess.span_diagnostic = Handler::with_emitter(true, None, silent_emitter(), None);
     }
 
     pub(crate) fn span_to_filename(&self, span: Span) -> FileName {
diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs
index 9f0f0d86c8b..2be369d2b74 100644
--- a/src/tools/tidy/src/deps.rs
+++ b/src/tools/tidy/src/deps.rs
@@ -253,6 +253,9 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
     "thiserror-impl",
     "thorin-dwp",
     "thread_local",
+    "time",
+    "time-core",
+    "time-macros",
     "tinystr",
     "tinyvec",
     "tinyvec_macros",