about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-07-31 23:39:40 +0200
committerGitHub <noreply@github.com>2022-07-31 23:39:40 +0200
commit9cc06eb54d53e9b29d7ddcf3b26274cef335b75b (patch)
tree9bd12b88cfaae3fc36b698e9a5ff4f700b64c3ac /src
parente820ecdba115e56d3d1cb0df169463a23a28fabd (diff)
parent6dea21a4a255fc246243fabc54436352b5f12c80 (diff)
downloadrust-9cc06eb54d53e9b29d7ddcf3b26274cef335b75b.tar.gz
rust-9cc06eb54d53e9b29d7ddcf3b26274cef335b75b.zip
Rollup merge of #99620 - hudson-ayers:fix-location-detail, r=davidtwco
`-Z location-detail`: provide option to disable all location details

As reported [here](https://github.com/rust-lang/rust/pull/89920#issuecomment-1190598924), when I first implemented the `-Z location-detail` flag there was a bug, where passing an empty list was not correctly supported, and instead rejected by the compiler. This PR fixes that such that passing an empty list results in no location details being tracked, as originally specified in https://github.com/rust-lang/rfcs/pull/2091 .

This PR also adds a test case to verify that this option continues to work as intended.
Diffstat (limited to 'src')
-rw-r--r--src/doc/unstable-book/src/compiler-flags/location-detail.md5
-rw-r--r--src/test/rustdoc-ui/z-help.stdout2
-rw-r--r--src/test/ui/panics/location-detail-panic-no-location-info.rs8
-rw-r--r--src/test/ui/panics/location-detail-panic-no-location-info.run.stderr2
4 files changed, 14 insertions, 3 deletions
diff --git a/src/doc/unstable-book/src/compiler-flags/location-detail.md b/src/doc/unstable-book/src/compiler-flags/location-detail.md
index 08d937cc282..db070619969 100644
--- a/src/doc/unstable-book/src/compiler-flags/location-detail.md
+++ b/src/doc/unstable-book/src/compiler-flags/location-detail.md
@@ -17,8 +17,9 @@ within this list are:
 - `line` - the source line of the panic will be included in the panic output
 - `column` - the source column of the panic will be included in the panic output
 
-Any combination of these three options are supported. If this option is not specified,
-all three are included by default.
+Any combination of these three options are supported. Alternatively, you can pass
+`none` to this option, which results in no location details being tracked.
+If this option is not specified, all three are included by default.
 
 An example of a panic output when using `-Z location-detail=line`:
 ```text
diff --git a/src/test/rustdoc-ui/z-help.stdout b/src/test/rustdoc-ui/z-help.stdout
index c8e5cac0594..6dc41231559 100644
--- a/src/test/rustdoc-ui/z-help.stdout
+++ b/src/test/rustdoc-ui/z-help.stdout
@@ -69,7 +69,7 @@
     -Z                               link-only=val -- link the `.rlink` file generated by `-Z no-link` (default: no)
     -Z                            llvm-plugins=val -- a list LLVM plugins to enable (space separated)
     -Z                         llvm-time-trace=val -- generate JSON tracing data file from LLVM data (default: no)
-    -Z                         location-detail=val -- comma separated list of location details to be tracked when using caller_location valid options are `file`, `line`, and `column` (default: all)
+    -Z                         location-detail=val -- what location details should be tracked when using caller_location, either `none`, or a comma separated list of location details, for which valid options are `file`, `line`, and `column` (default: `file,line,column`)
     -Z                                      ls=val -- list the symbols defined by a library crate (default: no)
     -Z                         macro-backtrace=val -- show macro backtraces (default: no)
     -Z                         merge-functions=val -- control the operation of the MergeFunctions LLVM pass, taking the same values as the target option of the same name
diff --git a/src/test/ui/panics/location-detail-panic-no-location-info.rs b/src/test/ui/panics/location-detail-panic-no-location-info.rs
new file mode 100644
index 00000000000..7b609145bad
--- /dev/null
+++ b/src/test/ui/panics/location-detail-panic-no-location-info.rs
@@ -0,0 +1,8 @@
+// run-fail
+// check-run-results
+// compile-flags: -Zlocation-detail=none
+// exec-env:RUST_BACKTRACE=0
+
+fn main() {
+    panic!("no location info");
+}
diff --git a/src/test/ui/panics/location-detail-panic-no-location-info.run.stderr b/src/test/ui/panics/location-detail-panic-no-location-info.run.stderr
new file mode 100644
index 00000000000..d1c3108643c
--- /dev/null
+++ b/src/test/ui/panics/location-detail-panic-no-location-info.run.stderr
@@ -0,0 +1,2 @@
+thread 'main' panicked at 'no location info', <redacted>:0:0
+note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace