From b802629311ee9873978e91f185657fd6ae3cba28 Mon Sep 17 00:00:00 2001 From: Hudson Ayers Date: Fri, 15 Oct 2021 08:58:28 -0700 Subject: [PATCH] add tests for -Zlocation-detail --- compiler/rustc_interface/src/tests.rs | 5 ++++- src/test/ui/panics/location-detail-panic-no-column.rs | 7 +++++++ .../ui/panics/location-detail-panic-no-column.run.stderr | 2 ++ src/test/ui/panics/location-detail-panic-no-file.rs | 7 +++++++ .../ui/panics/location-detail-panic-no-file.run.stderr | 2 ++ src/test/ui/panics/location-detail-panic-no-line.rs | 7 +++++++ .../ui/panics/location-detail-panic-no-line.run.stderr | 2 ++ src/test/ui/panics/location-detail-unwrap-no-file.rs | 8 ++++++++ .../ui/panics/location-detail-unwrap-no-file.run.stderr | 2 ++ 9 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/panics/location-detail-panic-no-column.rs create mode 100644 src/test/ui/panics/location-detail-panic-no-column.run.stderr create mode 100644 src/test/ui/panics/location-detail-panic-no-file.rs create mode 100644 src/test/ui/panics/location-detail-panic-no-file.run.stderr create mode 100644 src/test/ui/panics/location-detail-panic-no-line.rs create mode 100644 src/test/ui/panics/location-detail-panic-no-line.run.stderr create mode 100644 src/test/ui/panics/location-detail-unwrap-no-file.rs create mode 100644 src/test/ui/panics/location-detail-unwrap-no-file.run.stderr diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 844e5ab56a420..dab4d485e2d0b 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -5,7 +5,9 @@ use rustc_errors::{emitter::HumanReadableErrorType, registry, ColorConfig}; use rustc_session::config::InstrumentCoverage; use rustc_session::config::Strip; use rustc_session::config::{build_configuration, build_session_options, to_crate_config}; -use rustc_session::config::{rustc_optgroups, ErrorOutputType, ExternLocation, Options, Passes}; +use rustc_session::config::{ + rustc_optgroups, ErrorOutputType, ExternLocation, LocationDetail, Options, Passes, +}; use rustc_session::config::{CFGuard, ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath}; use rustc_session::config::{ Externs, OutputType, OutputTypes, SymbolManglingVersion, WasiExecModel, @@ -733,6 +735,7 @@ fn test_debugging_options_tracking_hash() { tracked!(instrument_mcount, true); tracked!(link_only, true); tracked!(llvm_plugins, vec![String::from("plugin_name")]); + tracked!(location_detail, LocationDetail { file: true, line: false, column: false }); tracked!(merge_functions, Some(MergeFunctions::Disabled)); tracked!(mir_emit_retag, true); tracked!(mir_opt_level, Some(4)); diff --git a/src/test/ui/panics/location-detail-panic-no-column.rs b/src/test/ui/panics/location-detail-panic-no-column.rs new file mode 100644 index 0000000000000..673e638ca0d6b --- /dev/null +++ b/src/test/ui/panics/location-detail-panic-no-column.rs @@ -0,0 +1,7 @@ +// run-fail +// check-run-results +// compile-flags: -Zlocation-detail=line,file + +fn main() { + panic!("column-redacted"); +} diff --git a/src/test/ui/panics/location-detail-panic-no-column.run.stderr b/src/test/ui/panics/location-detail-panic-no-column.run.stderr new file mode 100644 index 0000000000000..9f35623fba392 --- /dev/null +++ b/src/test/ui/panics/location-detail-panic-no-column.run.stderr @@ -0,0 +1,2 @@ +thread 'main' panicked at 'column-redacted', $DIR/location-detail-panic-no-column.rs:6:0 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/src/test/ui/panics/location-detail-panic-no-file.rs b/src/test/ui/panics/location-detail-panic-no-file.rs new file mode 100644 index 0000000000000..0e5d52cfd1534 --- /dev/null +++ b/src/test/ui/panics/location-detail-panic-no-file.rs @@ -0,0 +1,7 @@ +// run-fail +// check-run-results +// compile-flags: -Zlocation-detail=line,column + +fn main() { + panic!("file-redacted"); +} diff --git a/src/test/ui/panics/location-detail-panic-no-file.run.stderr b/src/test/ui/panics/location-detail-panic-no-file.run.stderr new file mode 100644 index 0000000000000..1e07e3a07afd5 --- /dev/null +++ b/src/test/ui/panics/location-detail-panic-no-file.run.stderr @@ -0,0 +1,2 @@ +thread 'main' panicked at 'file-redacted', :6:5 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/src/test/ui/panics/location-detail-panic-no-line.rs b/src/test/ui/panics/location-detail-panic-no-line.rs new file mode 100644 index 0000000000000..57f6d0ebcb9fa --- /dev/null +++ b/src/test/ui/panics/location-detail-panic-no-line.rs @@ -0,0 +1,7 @@ +// run-fail +// check-run-results +// compile-flags: -Zlocation-detail=file,column + +fn main() { + panic!("line-redacted"); +} diff --git a/src/test/ui/panics/location-detail-panic-no-line.run.stderr b/src/test/ui/panics/location-detail-panic-no-line.run.stderr new file mode 100644 index 0000000000000..cc3f1624c49ab --- /dev/null +++ b/src/test/ui/panics/location-detail-panic-no-line.run.stderr @@ -0,0 +1,2 @@ +thread 'main' panicked at 'line-redacted', $DIR/location-detail-panic-no-line.rs:0:5 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/src/test/ui/panics/location-detail-unwrap-no-file.rs b/src/test/ui/panics/location-detail-unwrap-no-file.rs new file mode 100644 index 0000000000000..d7f96f058e082 --- /dev/null +++ b/src/test/ui/panics/location-detail-unwrap-no-file.rs @@ -0,0 +1,8 @@ +// run-fail +// check-run-results +// compile-flags: -Zlocation-detail=line,column + +fn main() { + let opt: Option = None; + opt.unwrap(); +} diff --git a/src/test/ui/panics/location-detail-unwrap-no-file.run.stderr b/src/test/ui/panics/location-detail-unwrap-no-file.run.stderr new file mode 100644 index 0000000000000..f8f84b5c49a22 --- /dev/null +++ b/src/test/ui/panics/location-detail-unwrap-no-file.run.stderr @@ -0,0 +1,2 @@ +thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', :7:9 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace