From 831b99436c3dc47eafdaf363acd1d4e9e230551d Mon Sep 17 00:00:00 2001 From: mejrs <> Date: Wed, 19 Oct 2022 00:08:20 +0200 Subject: [PATCH 1/4] Implement -Ztrack-diagnostics --- clippy_lints/src/doc.rs | 1 + src/driver.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index 36dc7e3396b..9e2facf0f63 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -691,6 +691,7 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) { false, None, false, + false, ); let handler = Handler::with_emitter(false, None, Box::new(emitter)); let sess = ParseSess::with_span_handler(handler, sm); diff --git a/src/driver.rs b/src/driver.rs index b12208ac62a..ae54b2078a6 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -179,6 +179,7 @@ fn report_clippy_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { false, None, false, + false, )); let handler = rustc_errors::Handler::with_emitter(true, None, emitter); From beae0d298e5682f12bbf09ba12619751ec9548ea Mon Sep 17 00:00:00 2001 From: mejrs <> Date: Mon, 24 Oct 2022 20:52:51 +0200 Subject: [PATCH 2/4] Address some comments --- tests/ui/track-diagnostics.rs | 8 ++++++++ tests/ui/track-diagnostics.stderr | 10 ++++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/ui/track-diagnostics.rs create mode 100644 tests/ui/track-diagnostics.stderr diff --git a/tests/ui/track-diagnostics.rs b/tests/ui/track-diagnostics.rs new file mode 100644 index 00000000000..8c96f46d57a --- /dev/null +++ b/tests/ui/track-diagnostics.rs @@ -0,0 +1,8 @@ +// compile-flags: -Z track-diagnostics +// error-pattern: created at + +struct A; +struct B; +const S: A = B; + +fn main() {} diff --git a/tests/ui/track-diagnostics.stderr b/tests/ui/track-diagnostics.stderr new file mode 100644 index 00000000000..76453cfe220 --- /dev/null +++ b/tests/ui/track-diagnostics.stderr @@ -0,0 +1,10 @@ +error[E0308]: mismatched types + --> $DIR/track-diagnostics.rs:6:14 + | +LL | const S: A = B; + | ^ expected struct `A`, found struct `B` +-Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:2275:31 + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. From 48edc83526d9cd674ecef44d3022980408868a18 Mon Sep 17 00:00:00 2001 From: mejrs <> Date: Mon, 24 Oct 2022 23:19:48 +0200 Subject: [PATCH 3/4] Add more normalization and tests --- tests/ui/track-diagnostics.rs | 4 ++++ tests/ui/track-diagnostics.stderr | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/ui/track-diagnostics.rs b/tests/ui/track-diagnostics.rs index 8c96f46d57a..550ccd7b3d3 100644 --- a/tests/ui/track-diagnostics.rs +++ b/tests/ui/track-diagnostics.rs @@ -1,6 +1,10 @@ // compile-flags: -Z track-diagnostics // error-pattern: created at +// Normalize the emitted location so this doesn't need +// updating everytime someone adds or removes a line. +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL" + struct A; struct B; const S: A = B; diff --git a/tests/ui/track-diagnostics.stderr b/tests/ui/track-diagnostics.stderr index 76453cfe220..5a0982ff731 100644 --- a/tests/ui/track-diagnostics.stderr +++ b/tests/ui/track-diagnostics.stderr @@ -1,9 +1,9 @@ error[E0308]: mismatched types - --> $DIR/track-diagnostics.rs:6:14 + --> $DIR/track-diagnostics.rs:$LINE::$COL | LL | const S: A = B; | ^ expected struct `A`, found struct `B` --Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:2275:31 +-Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:$LINE::$COL error: aborting due to previous error From 4b1cebbc1868253bdeed54c3b1b1c5bc5ef8807c Mon Sep 17 00:00:00 2001 From: mejrs <> Date: Wed, 26 Oct 2022 13:41:57 +0200 Subject: [PATCH 4/4] Adjust normalization --- tests/ui/track-diagnostics.rs | 2 +- tests/ui/track-diagnostics.stderr | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ui/track-diagnostics.rs b/tests/ui/track-diagnostics.rs index 550ccd7b3d3..fa9221ed02d 100644 --- a/tests/ui/track-diagnostics.rs +++ b/tests/ui/track-diagnostics.rs @@ -3,7 +3,7 @@ // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. -// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:$$LINE::$$COL" +// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC" struct A; struct B; diff --git a/tests/ui/track-diagnostics.stderr b/tests/ui/track-diagnostics.stderr index 5a0982ff731..ec303186253 100644 --- a/tests/ui/track-diagnostics.stderr +++ b/tests/ui/track-diagnostics.stderr @@ -1,9 +1,9 @@ error[E0308]: mismatched types - --> $DIR/track-diagnostics.rs:$LINE::$COL + --> $DIR/track-diagnostics.rs:LL:CC | LL | const S: A = B; | ^ expected struct `A`, found struct `B` --Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:$LINE::$COL +-Ztrack-diagnostics: created at compiler/rustc_infer/src/infer/error_reporting/mod.rs:LL:CC error: aborting due to previous error