From da3df9c2019beaa27da04ccf09f3a1dea6d46574 Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Tue, 12 Sep 2023 11:31:59 -0700 Subject: [PATCH] Add test for future-incompat diagnostics with json output --- tests/ui/lint/future-incompat-json-test.rs | 10 ++++++++++ tests/ui/lint/future-incompat-json-test.stderr | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/ui/lint/future-incompat-json-test.rs create mode 100644 tests/ui/lint/future-incompat-json-test.stderr diff --git a/tests/ui/lint/future-incompat-json-test.rs b/tests/ui/lint/future-incompat-json-test.rs new file mode 100644 index 0000000000000..6ccd670294c60 --- /dev/null +++ b/tests/ui/lint/future-incompat-json-test.rs @@ -0,0 +1,10 @@ +// compile-flags: -Zfuture-incompat-test --json=future-incompat --error-format=json +// check-pass + +// The `-Zfuture-incompat-test flag causes any normal warning to be included +// in the future-incompatible report. The stderr output here should mention +// the future incompatible report (as extracted by compiletest). + +fn main() { + let x = 1; +} diff --git a/tests/ui/lint/future-incompat-json-test.stderr b/tests/ui/lint/future-incompat-json-test.stderr new file mode 100644 index 0000000000000..c7db650e6e3d0 --- /dev/null +++ b/tests/ui/lint/future-incompat-json-test.stderr @@ -0,0 +1,10 @@ +{"type":"future_incompat","future_incompat_report":[{"diagnostic":{"type":"diagnostic","message":"unused variable: `x`","code":{"code":"unused_variables","explanation":null},"level":"warning","spans":[{"file_name":"$DIR/future-incompat-json-test.rs","byte_start":338,"byte_end":339,"line_start":9,"line_end":9,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":" let x = 1;","highlight_start":9,"highlight_end":10}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`-A unused-variables` implied by `-A unused`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"to override `-A unused` add `#[allow(unused_variables)]`","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"if this is intentional, prefix it with an underscore","code":null,"level":"help","spans":[{"file_name":"$DIR/future-incompat-json-test.rs","byte_start":338,"byte_end":339,"line_start":9,"line_end":9,"column_start":9,"column_end":10,"is_primary":true,"text":[{"text":" let x = 1;","highlight_start":9,"highlight_end":10}],"label":null,"suggested_replacement":"_x","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: unused variable: `x` + --> $DIR/future-incompat-json-test.rs:9:9 + | +LL | let x = 1; + | ^ help: if this is intentional, prefix it with an underscore: `_x` + | + = note: `-A unused-variables` implied by `-A unused` + = help: to override `-A unused` add `#[allow(unused_variables)]` + +"}}]}